Skip to main content
Hugging Face Inference Providers give you one API for models hosted by many inference partners. The API is compatible with the OpenAI API, so you can use it with the openai backend in Curator. This guide generates vegan recipes.

Setup

  1. Create a Hugging Face account if you do not have one.
  2. Create an access token. You use it to authenticate your requests.
  3. Turn on at least one provider on the Inference Providers settings page.
Install the packages.
1

Create an LLM subclass

2

Create the input dataset

3

Point the OpenAI backend at Hugging Face

Set these three values.
  • base_url is the Hugging Face router, https://router.huggingface.co/v1.
  • api_key is your Hugging Face token.
  • model_name is the model ID on the Hub. Add :<provider> to the end to choose a provider, e.g., :together. Without it, Hugging Face picks a provider for you.
The model page on the Hub shows which providers serve a model.
4

Share the results

To look through the results in the Curator Viewer, upload them with push_to_viewer.
The results are a Hugging Face Dataset, so you can also push them to the Hub.
This dataset on the Hub was made in the same way.

Switch models

You can change the model or the provider by changing model_name. To find the models that one provider serves, filter the Hub by that provider, e.g., the models served by Together.