Skip to content

Commit 3a70849

Browse files
Merge pull request #4976 from BerriAI/litellm_huggingface_embedding_fixes
feat(huggingface_restapi.py): Support multiple hf embedding types + async hf embeddings
2 parents 84513c0 + 4395890 commit 3a70849

File tree

5 files changed

+356
-61
lines changed

5 files changed

+356
-61
lines changed

Diff for: docs/my-website/docs/embedding/supported_embedding.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ response = embedding(
270270
| embed-multilingual-v2.0 | `embedding(model="embed-multilingual-v2.0", input=["good morning from litellm", "this is another item"])` |
271271

272272
## HuggingFace Embedding Models
273-
LiteLLM supports all Feature-Extraction Embedding models: https://huggingface.co/models?pipeline_tag=feature-extraction
273+
LiteLLM supports all Feature-Extraction + Sentence Similarity Embedding models: https://huggingface.co/models?pipeline_tag=feature-extraction
274274

275275
### Usage
276276
```python
@@ -282,6 +282,25 @@ response = embedding(
282282
input=["good morning from litellm"]
283283
)
284284
```
285+
286+
### Usage - Set input_type
287+
288+
LiteLLM infers input type (feature-extraction or sentence-similarity) by making a GET request to the api base.
289+
290+
Override this, by setting the `input_type` yourself.
291+
292+
```python
293+
from litellm import embedding
294+
import os
295+
os.environ['HUGGINGFACE_API_KEY'] = ""
296+
response = embedding(
297+
model='huggingface/microsoft/codebert-base',
298+
input=["good morning from litellm", "you are a good bot"],
299+
api_base = "https://p69xlsj6rpno5drq.us-east-1.aws.endpoints.huggingface.cloud",
300+
input_type="sentence-similarity"
301+
)
302+
```
303+
285304
### Usage - Custom API Base
286305
```python
287306
from litellm import embedding

Diff for: litellm/llms/cohere.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#################### OLD ########################
2+
##### See `cohere_chat.py` for `/chat` calls ####
3+
#################################################
14
import json
25
import os
36
import time

0 commit comments

Comments
 (0)