Skip to content

Commit 5465958

Browse files
authored
fix: nomic embeddings (#2030)
* fix: allow to configure trust_remote_code based on: #1893 (comment) * fix: nomic hf embeddings
1 parent 8119842 commit 5465958

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

poetry.lock

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

private_gpt/components/embedding/embedding_component.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(self, settings: Settings) -> None:
3131
self.embedding_model = HuggingFaceEmbedding(
3232
model_name=settings.huggingface.embedding_hf_model_name,
3333
cache_folder=str(models_cache_path),
34+
trust_remote_code=settings.huggingface.trust_remote_code,
3435
)
3536
case "sagemaker":
3637
try:

private_gpt/settings/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ class HuggingFaceSettings(BaseModel):
189189
None,
190190
description="Huggingface access token, required to download some models",
191191
)
192+
trust_remote_code: bool = Field(
193+
False,
194+
description="If set to True, the code from the remote model will be trusted and executed.",
195+
)
192196

193197

194198
class EmbeddingSettings(BaseModel):

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ google-generativeai = {version ="^0.5.4", optional = true}
6565
# Optional Ollama client
6666
ollama = {version ="^0.3.0", optional = true}
6767

68+
# Optional HF Transformers
69+
einops = {version = "^0.8.0", optional = true}
70+
6871
[tool.poetry.extras]
6972
ui = ["gradio", "ffmpy"]
7073
llms-llama-cpp = ["llama-index-llms-llama-cpp"]
@@ -75,7 +78,7 @@ llms-sagemaker = ["boto3"]
7578
llms-azopenai = ["llama-index-llms-azure-openai"]
7679
llms-gemini = ["llama-index-llms-gemini", "google-generativeai"]
7780
embeddings-ollama = ["llama-index-embeddings-ollama", "ollama"]
78-
embeddings-huggingface = ["llama-index-embeddings-huggingface"]
81+
embeddings-huggingface = ["llama-index-embeddings-huggingface", "einops"]
7982
embeddings-openai = ["llama-index-embeddings-openai"]
8083
embeddings-sagemaker = ["boto3"]
8184
embeddings-azopenai = ["llama-index-embeddings-azure-openai"]

settings.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ embedding:
9191
huggingface:
9292
embedding_hf_model_name: nomic-ai/nomic-embed-text-v1.5
9393
access_token: ${HF_TOKEN:}
94+
# Warning: Enabling this option will allow the model to download and execute code from the internet.
95+
# Nomic AI requires this option to be enabled to use the model, be aware if you are using a different model.
96+
trust_remote_code: true
9497

9598
vectorstore:
9699
database: qdrant

0 commit comments

Comments
 (0)