# HuggingFaceEmbeddings not working?

**URL:** <https://discuss.huggingface.co/t/huggingfaceembeddings-not-working/145806>\
**Category:** Beginners\
**Created:** [March 14, 2025, 5:33pm UTC](https://discuss.huggingface.co/t/huggingfaceembeddings-not-working/145806 "2025-03-14T17:33:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fdavidg](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@fdavidg](https://discuss.huggingface.co/u/fdavidg)\
**Post date:** [March 14, 2025, 5:33pm UTC](https://discuss.huggingface.co/t/huggingfaceembeddings-not-working/145806/1 "2025-03-14T17:33:14Z")

</div>

Here is the code snippet:  
“”"  
from langchain.embeddings import HuggingFaceEmbeddings  
embeddings\_model\_name = os.environ.get(‘EMBEDDINGS\_MODEL\_NAME’, ‘all-MiniLM-L6-v2’) I have attached the pertinent section of code below: I def main():  
# Create embeddings  
embeddings = HuggingFaceEmbeddings(model\_name=embeddings\_model\_name)

```
if does_vectorstore_exist(persist_directory):
    # Update and store locally vectorstore
    print(f"Appending to existing vectorstore at {persist_directory}")
    db = Chroma(persist_directory=persist_directory, embedding_function=embeddings, client_settings=CHROMA_SETTING>
    # db = Chroma(persist_directory=persist_directory, embeddings, client_settings=CHROMA_SETTINGS)
    collection = db.get()
    texts = process_documents([metadata['source'] for metadata in collection['metadatas']])
    print(f"Creating embeddings. May take some minutes...")
    db.add_documents(texts)
else:
    # Create and store locally vectorstore
    print("Creating new vectorstore")
    texts = process_documents()
    print(f"Creating embeddings. May take some minutes...")
    # Modify statement below from embeddings to embedding_function=embeddings
    # db = Chroma.from_documents(texts, embeddings, persist_directory=persist_directory)
    db = Chroma.from_documents(texts, embedding_function=embeddings, persist_directory=persist_directory)
    # db = Chroma.from_documents(texts, embedding_function=embeddings.embed_documents, persist_directory=persist_d>

db.persist() db = None

print(f"Ingestion complete! You can now run privateGPT.py to query your documents")

```

“”"

Here is the error message I get after running:  
“”"  
I Loading new documents: 100%|██████████████| 18823/18823 [20:54\<00:00, 15.01it/s]  
Loaded 56261545 new documents from /mnt/source\_documents  
Split into 80123280 chunks of text (max. 500 tokens each)  
Creating embeddings. May take some minutes…  
Traceback (most recent call last):  
File “/home/fdavidg/ollama/ollama-0.5.4/examples/langchain-python-rag-privategpt/ingest.py”, line 179, in   
main()  
File “/home/fdavidg/ollama/ollama-0.5.4/examples/langchain-python-rag-privategpt/ingest.py”, line 169, in main  
db = Chroma.from\_documents(texts, embedding\_function=embeddings, persist\_directory=persist\_directory)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
File “/home/fdavidg/ollama/ollama-0.5.4/examples/langchain-python-rag-privategpt/GPTAllDocs/lib/python3.12/site-packages/langchain/vectorstores/chroma.py”, line 612, in from\_documents  
return cls.from\_texts(  
^^^^^^^^^^^^^^^  
File “/home/fdavidg/ollama/ollama-0.5.4/examples/langchain-python-rag-privategpt/GPTAllDocs/lib/python3.12/site-packages/langchain/vectorstores/chroma.py”, line 567, in from\_texts  
chroma\_collection = cls(  
^^^^  
TypeError: langchain.vectorstores.chroma.Chroma() got multiple values for keyword argument ‘embedding\_function’ I  
“”"

I have checked versions and chromadb is up to date.

I am new to most of this AI programming, but have experience with Python. I am at a loss to determine what I am doing wrong. Any help, please!

Thank you.

Sincerely,

Frank D Gunseor

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [March 14, 2025, 11:48pm UTC](https://discuss.huggingface.co/t/huggingfaceembeddings-not-working/145806/2 "2025-03-14T23:48:44Z")

</div>

I think there is probably a runtime error. Not just with that model, but the API for all Sentence Transformer models is strange.

It may have been fixed already, but I think the cause is probably the same or similar.

> [@Unable to access public model - status 401](https://discuss.huggingface.co/t/unable-to-access-public-model-status-401/144806):
>
> i build .net code to access sentence-transformers/all-MiniLM-L6-v2. while running, i get the following error: {StatusCode: 401, Unauthorized] although token is right , it has read permission using (var client = new HttpClient()) { client.DefaultRequestHeaders.Add(“Authorization”, “hf\_DimrceBJNUZfMjpICMAQfXzNkrioZErQVI”); var requestContent = new { inputs = new string[] { text1, text2 } }; var response = await client.PostAsync("https://api-inference.huggingface.co/models/sentence-tran…

---

<div class="post-metadata">

**Author:** ![fdavidg](https://avatars.discourse-cdn.com/v4/letter/f/9fc29f/32.png) [@fdavidg](https://discuss.huggingface.co/u/fdavidg)\
**Post date:** [March 15, 2025, 5:00pm UTC](https://discuss.huggingface.co/t/huggingfaceembeddings-not-working/145806/3 "2025-03-15T17:00:31Z")

</div>

So how do I fix the errors?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [March 16, 2025, 3:36am UTC](https://discuss.huggingface.co/t/huggingfaceembeddings-not-working/145806/4 "2025-03-16T03:36:27Z")

</div>

Since it’s an error on the part of Hugging Face, all we users can do is report the error and wait.  
[website@huggingface.co](mailto:website@huggingface.co)
