From d0971dd50e0013a8d80b9c0db096e7545c0ea8e4 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 30 Jul 2024 13:45:38 -0700 Subject: [PATCH] docs(supported_embedding.md): add specifying input_type for huggingface embedding calls --- .../docs/embedding/supported_embedding.md | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/my-website/docs/embedding/supported_embedding.md b/docs/my-website/docs/embedding/supported_embedding.md index 73ac4775548..aa3c2c4c59d 100644 --- a/docs/my-website/docs/embedding/supported_embedding.md +++ b/docs/my-website/docs/embedding/supported_embedding.md @@ -270,7 +270,7 @@ response = embedding( | embed-multilingual-v2.0 | `embedding(model="embed-multilingual-v2.0", input=["good morning from litellm", "this is another item"])` | ## HuggingFace Embedding Models -LiteLLM supports all Feature-Extraction Embedding models: https://huggingface.co/models?pipeline_tag=feature-extraction +LiteLLM supports all Feature-Extraction + Sentence Similarity Embedding models: https://huggingface.co/models?pipeline_tag=feature-extraction ### Usage ```python @@ -282,6 +282,25 @@ response = embedding( input=["good morning from litellm"] ) ``` + +### Usage - Set input_type + +LiteLLM infers input type (feature-extraction or sentence-similarity) by making a GET request to the api base. + +Override this, by setting the `input_type` yourself. + +```python +from litellm import embedding +import os +os.environ['HUGGINGFACE_API_KEY'] = "" +response = embedding( + model='huggingface/microsoft/codebert-base', + input=["good morning from litellm", "you are a good bot"], + api_base = "https://p69xlsj6rpno5drq.us-east-1.aws.endpoints.huggingface.cloud", + input_type="sentence-similarity" +) +``` + ### Usage - Custom API Base ```python from litellm import embedding