docs: add guidance for hugging face components (#6872)
* huggingface-api-model-component * hf-local-embeddings * hf-embeddings-inference * Apply suggestions from code review Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com> --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>
This commit is contained in:
parent
a5a8227833
commit
a22d73c4d3
2 changed files with 55 additions and 20 deletions
|
|
@ -179,7 +179,7 @@ This component connects to Google's generative AI embedding service using the Go
|
|||
|
||||
:::note
|
||||
This component is deprecated as of Langflow version 1.0.18.
|
||||
Instead, use the [Hugging Face API Embeddings component](#hugging-face-embeddings-inference-api).
|
||||
Instead, use the [Hugging Face Embeddings Inference component](#hugging-face-embeddings-inference).
|
||||
:::
|
||||
|
||||
This component loads embedding models from HuggingFace.
|
||||
|
|
@ -202,29 +202,42 @@ Use this component to generate embeddings using locally downloaded Hugging Face
|
|||
|------|--------------|------|
|
||||
| embeddings | Embeddings | The generated embeddings |
|
||||
|
||||
## Hugging Face embeddings Inference API
|
||||
## Hugging Face embeddings inference
|
||||
|
||||
This component generates embeddings using [Hugging Face Inference API models](https://huggingface.co/).
|
||||
This component generates embeddings using [Hugging Face Inference API models](https://huggingface.co/) and requires a [Hugging Face API token](https://huggingface.co/docs/hub/security-tokens) to authenticate. Local inference models do not require an API key.
|
||||
|
||||
Use this component to create embeddings with Hugging Face's hosted models.
|
||||
Use this component to create embeddings with Hugging Face's hosted models, or to connect to your own locally hosted models.
|
||||
|
||||
### Inputs
|
||||
|
||||
| Name | Display Name | Info |
|
||||
|------|--------------|------|
|
||||
| API Key | API Key | API key for accessing the Hugging Face Inference API |
|
||||
| API URL | API URL | URL of the Hugging Face Inference API |
|
||||
| Model Name | Model Name | Name of the model to use for embeddings |
|
||||
| Cache Folder | Cache Folder | Folder path to cache Hugging Face models |
|
||||
| Encode Kwargs | Encoding Arguments | Additional arguments for the encoding process |
|
||||
| Model Kwargs | Model Arguments | Additional arguments for the model |
|
||||
| Multi Process | Multi-Process | Whether to use multiple processes |
|
||||
| API Key | API Key | The API key for accessing the Hugging Face Inference API. |
|
||||
| API URL | API URL | The URL of the Hugging Face Inference API. |
|
||||
| Model Name | Model Name | The name of the model to use for embeddings. |
|
||||
| Cache Folder | Cache Folder | The folder path to cache Hugging Face models. |
|
||||
| Encode Kwargs | Encoding Arguments | Additional arguments for the encoding process. |
|
||||
| Model Kwargs | Model Arguments | Additional arguments for the model. |
|
||||
| Multi Process | Multi-Process | Whether to use multiple processes. |
|
||||
|
||||
### Outputs
|
||||
|
||||
| Name | Display Name | Info |
|
||||
|------|--------------|------|
|
||||
| embeddings | Embeddings | The generated embeddings |
|
||||
| embeddings | Embeddings | The generated embeddings. |
|
||||
|
||||
### Connect the Hugging Face component to a local embeddings model
|
||||
|
||||
To run an embeddings inference locally, see the [HuggingFace documentation](https://huggingface.co/docs/text-embeddings-inference/local_cpu).
|
||||
|
||||
To connect the local Hugging Face model to the **Hugging Face embeddings inference** component and use it in a flow, follow these steps:
|
||||
|
||||
1. Create a [Vector store RAG flow](/starter-projects-vector-store-rag).
|
||||
There are two embeddings models in this flow that you can replace with **Hugging Face** embeddings inference components.
|
||||
2. Replace both **OpenAI** embeddings model components with **Hugging Face** model components.
|
||||
3. Connect both **Hugging Face** components to the **Embeddings** ports of the **Astra DB vector store** components.
|
||||
4. In the **Hugging Face** components, set the **Inference Endpoint** field to the URL of your local inference model. **The **API Key** field is not required for local inference.**
|
||||
5. Run the flow. The local inference models generate embeddings for the input text.
|
||||
|
||||
## LM Studio Embeddings
|
||||
|
||||
|
|
|
|||
|
|
@ -211,19 +211,41 @@ For more information, see the [Groq documentation](https://groq.com/).
|
|||
|
||||
## Hugging Face API
|
||||
|
||||
This component generates text using Hugging Face's language models.
|
||||
This component sends requests to the Hugging Face API to generate text using the model specified in the **Model ID** field.
|
||||
|
||||
The Hugging Face API is a hosted inference API for models hosted on Hugging Face, and requires a [Hugging Face API token](https://huggingface.co/docs/hub/security-tokens) to authenticate.
|
||||
|
||||
In this example based on the [Basic prompting flow](/starter-projects-basic-prompting), the **Hugging Face API** model component replaces the **Open AI** model. By selecting different hosted models, you can see how different models return different results.
|
||||
|
||||
1. Create a [Basic prompting flow](/starter-projects-basic-prompting).
|
||||
|
||||
2. Replace the **OpenAI** model component with a **Hugging Face API** model component.
|
||||
|
||||
3. In the **Hugging Face API** component, add your Hugging Face API token to the **API Token** field.
|
||||
|
||||
4. Open the **Playground** and ask a question to the model, and see how it responds.
|
||||
|
||||
5. Try different models, and see how they perform differently.
|
||||
|
||||
For more information, see the [Hugging Face documentation](https://huggingface.co/).
|
||||
|
||||
### Inputs
|
||||
|
||||
| Name | Display Name | Info |
|
||||
|---------------------|-------------------|-------------------------------------------|
|
||||
| Endpoint URL | Endpoint URL | The URL of the Hugging Face Inference API endpoint. |
|
||||
| Task | Task | Specifies the task for text generation. |
|
||||
| API Token | API Token | The API token required for authentication.|
|
||||
| Model Kwargs | Model Kwargs | Additional keyword arguments for the model.|
|
||||
| Input Value | Input Value | The input text for text generation. |
|
||||
| Name | Type | Description |
|
||||
|----------------|---------------|-----------------------------------------------------------------|
|
||||
| model_id | String | The model ID from Hugging Face Hub. For example, "gpt2", "facebook/bart-large". |
|
||||
| huggingfacehub_api_token | SecretString | Your Hugging Face API token for authentication. |
|
||||
| temperature | Float | Controls randomness in the output. Range: [0.0, 1.0]. Default: 0.7. |
|
||||
| max_new_tokens | Integer | Maximum number of tokens to generate. Default: 512. |
|
||||
| top_p | Float | Nucleus sampling parameter. Range: [0.0, 1.0]. Default: 0.95. |
|
||||
| top_k | Integer | Top-k sampling parameter. Default: 50. |
|
||||
| model_kwargs | Dictionary | Additional keyword arguments to pass to the model. |
|
||||
|
||||
### Outputs
|
||||
|
||||
| Name | Type | Description |
|
||||
|-------|---------------|------------------------------------------------------------------|
|
||||
| model | LanguageModel | An instance of HuggingFaceHub configured with the specified parameters. |
|
||||
|
||||
## LMStudio
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue