31.6 C
Canberra
Monday, February 24, 2025

Posit AI Weblog: Hugging Face Integrations



Posit AI Weblog: Hugging Face Integrations

We’re joyful to announce the primary releases of hfhub and tok are actually on CRAN.
hfhub is an R interface to Hugging Face Hub, permitting customers to obtain and cache recordsdata
from Hugging Face Hub whereas tok implements R bindings for the Hugging Face tokenizers
library.

Hugging Face quickly grew to become the platform to construct, share and collaborate on
deep studying purposes and we hope these integrations will assist R customers to
get began utilizing Hugging Face instruments in addition to constructing novel purposes.

We even have beforehand introduced the safetensors
bundle permitting to learn and write recordsdata within the safetensors format.

hfhub

hfhub is an R interface to the Hugging Face Hub. hfhub at the moment implements a single
performance: downloading recordsdata from Hub repositories. Mannequin Hub repositories are
primarily used to retailer pre-trained mannequin weights along with some other metadata
essential to load the mannequin, such because the hyperparameters configurations and the
tokenizer vocabulary.

Downloaded recordsdata are ached utilizing the identical structure because the Python library, thus cached
recordsdata may be shared between the R and Python implementation, for simpler and faster
switching between languages.

We already use hfhub within the minhub bundle and
within the ‘GPT-2 from scratch with torch’ weblog submit to
obtain pre-trained weights from Hugging Face Hub.

You should utilize hub_download() to obtain any file from a Hugging Face Hub repository
by specifying the repository id and the trail to file that you simply need to obtain.
If the file is already within the cache, then the operate returns the file path imediately,
in any other case the file is downloaded, cached after which the entry path is returned.

weblog submit ‘What are Massive Language Fashions? What are they not?’.

When utilizing a pre-trained mannequin (each for inference or for tremendous tuning) it’s very
necessary that you simply use the very same tokenization course of that has been used throughout
coaching, and the Hugging Face group has accomplished an incredible job ensuring that its algorithms
match the tokenization methods used most LLM’s.

tok supplies R bindings to the 🤗 tokenizers library. The tokenizers library is itself
carried out in Rust for efficiency and our bindings use the extendr mission
to assist interfacing with R. Utilizing tok we will tokenize textual content the very same manner most
NLP fashions do, making it simpler to load pre-trained fashions in R in addition to sharing
our fashions with the broader NLP group.

tok may be put in from CRAN, and at the moment it’s utilization is restricted to loading
tokenizers vocabularies from recordsdata. For instance, you may load the tokenizer for the GPT2
mannequin with:

Keep in mind which you can already host
Shiny (for R and Python) on Hugging Face Areas. For instance, we’ve constructed a Shiny
app that makes use of:

  • torch to implement GPT-NeoX (the neural community structure of StableLM – the mannequin used for chatting)
  • hfhub to obtain and cache pre-trained weights from the StableLM repository
  • tok to tokenize and pre-process textual content as enter for the torch mannequin. tok additionally makes use of hfhub to obtain the tokenizer’s vocabulary.

The app is hosted at on this House.
It at the moment runs on CPU, however you may simply change the the Docker picture if you need
to run it on a GPU for quicker inference.

The app supply code can be open-source and may be discovered within the Areas file tab.

Wanting ahead

It’s the very early days of hfhub and tok and there’s nonetheless lots of work to do
and performance to implement. We hope to get group assist to prioritize work,
thus, if there’s a characteristic that you’re lacking, please open a problem within the
GitHub repositories.

Reuse

Textual content and figures are licensed underneath Artistic Commons Attribution CC BY 4.0. The figures which were reused from different sources do not fall underneath this license and may be acknowledged by a word of their caption: “Determine from …”.

Quotation

For attribution, please cite this work as

Falbel (2023, July 12). Posit AI Weblog: Hugging Face Integrations. Retrieved from https://blogs.rstudio.com/tensorflow/posts/2023-07-12-hugging-face-integrations/

BibTeX quotation

@misc{hugging-face-integrations,
  creator = {Falbel, Daniel},
  title = {Posit AI Weblog: Hugging Face Integrations},
  url = {https://blogs.rstudio.com/tensorflow/posts/2023-07-12-hugging-face-integrations/},
  yr = {2023}
}

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles