Skip to content

Commit 0ae06b2

Browse files
authored
Docs: Add Huggingface readme (langgenius#88)
1 parent 8c77e0f commit 0ae06b2

File tree

10 files changed

+73
-0
lines changed

10 files changed

+73
-0
lines changed

models/huggingface_hub/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
## Overview
2+
3+
Hugging Face is a leading open-source platform and community dedicated to advancing artificial intelligence (AI) and machine learning (ML), particularly in the field of natural language processing (NLP). Founded in 2016, the company initially aimed to create an interactive chatbot but quickly pivoted to focus on providing powerful tools and resources for AI development. Today, it is widely recognized as a central hub for researchers, developers, and enthusiasts to collaborate on machine learning projects.
4+
5+
## Configuration
6+
7+
Dify supports Text-Generation and Embeddings for Hugging Face. Below are the corresponding Hugging Face model types:
8+
9+
* Text-Generation:[text-generation](https://huggingface.co/models?pipeline_tag=text-generation&sort=trending)[text2text-generation](https://huggingface.co/models?pipeline_tag=text2text-generation&sort=trending)
10+
* Embeddings:[feature-extraction](https://huggingface.co/models?pipeline_tag=feature-extraction&sort=trending)
11+
12+
The specific steps are as follows:
13+
14+
1. You need a Hugging Face account ([registered address](https://huggingface.co/join)).
15+
2. Set the API key of Hugging Face ([obtain address](https://huggingface.co/settings/tokens)).
16+
3. Select a model to enter the [Hugging Face model list page](https://huggingface.co/models?pipeline_tag=text-generation&sort=trending).
17+
18+
![](./_assets/huggingface_hub-01.png)
19+
20+
Dify supports accessing models on Hugging Face in two ways:
21+
22+
1. Hosted Inference API. This method uses the model officially deployed by Hugging Face. No fee is required. But the downside is that only a small number of models support this approach.
23+
2. Inference Endpoint. This method uses resources such as AWS accessed by the Hugging Face to deploy the model and requires payment.
24+
25+
## Models that access the Hosted Inference API
26+
27+
### 1. Select a model
28+
29+
Hosted inference API is supported only when there is an area containing Hosted inference API on the right side of the model details page. As shown in the figure below:
30+
31+
![](./_assets/huggingface_hub-02.png)
32+
33+
On the model details page, you can get the name of the model.
34+
35+
![](./_assets/huggingface_hub-03.png)
36+
37+
### 2. Using access models in Dify
38+
39+
Select Hosted Inference API for Endpoint Type in `Settings > Model Provider > Hugging Face > Model Type`. As shown below:
40+
41+
![](./_assets/huggingface_hub-04.png)
42+
43+
API Token is the API Key set at the beginning of the article. The model name is the model name obtained in the previous step.
44+
45+
## Method 2: Inference Endpoint
46+
47+
### 1. Select the model to deploy
48+
49+
Inference Endpoint is only supported for models with the Inference Endpoints option under the Deploy button on the right side of the model details page. As shown below:
50+
51+
![](./_assets/huggingface_hub-05.png)
52+
53+
### 2. Deployment model
54+
55+
Click the Deploy button for the model and select the Inference Endpoint option. If you have not bound a bank card before, you will need to bind the card. Just follow the process. After binding the card, the following interface will appear: modify the configuration according to the requirements, and click Create Endpoint in the lower left corner to create an Inference Endpoint.
56+
57+
![](./_assets/huggingface_hub-06.png)
58+
59+
After the model is deployed, you can see the Endpoint URL.
60+
61+
![](./_assets/huggingface_hub-07.png)
62+
63+
### 3. Using access models in Dify
64+
65+
Select Inference Endpoints for Endpoint Type in `Settings > Model Provider > Hugging face > Model Type`. As shown below:
66+
67+
![](./_assets/huggingface_hub-08.png)
68+
69+
The API Token is the API Key set at the beginning of the article. The name of the Text-Generation model can be arbitrary, but the name of the Embeddings model needs to be consistent with Hugging Face. The Endpoint URL is the Endpoint URL obtained after the successful deployment of the model in the previous step.
70+
71+
![](./_assets/huggingface_hub-09.png)
72+
73+
> Note: The "User name / Organization Name" for Embeddings needs to be filled in according to your deployment method on Hugging Face's [Inference Endpoints](https://huggingface.co/docs/inference-endpoints/guides/access), with either the ''[User name](https://huggingface.co/settings/account)'' or the "[Organization Name](https://ui.endpoints.huggingface.co/)".
342 KB
Loading
126 KB
Loading
393 KB
Loading
288 KB
Loading
168 KB
Loading
324 KB
Loading
129 KB
Loading
247 KB
Loading
149 KB
Loading

0 commit comments

Comments
 (0)