mem0ai / mem0

The Memory layer for your AI apps
https://mem0.ai
Apache License 2.0
21.85k stars 2k forks source link

DOC: Following Quick Start with Hugging Face and no answer #1277

Closed PhilFlash closed 7 months ago

PhilFlash commented 7 months ago

🐛 Describe the bug

Try documentation for Hugging Face and Mistral (with Windows 10, Python 3.11.8, embedchain 0.1.81 and an User Access Tokens for Huggin Face in READ mode)

First call with: python quickstart.py

Traceback (most recent call last):
  File "E:\pythonProjects\embedchain_ex1\.venv\Lib\site-packages\langchain_community\embeddings\huggingface.py", line 59, in __init__
    import sentence_transformers
ModuleNotFoundError: No module named 'sentence_transformers'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "E:\pythonProjects\embedchain_ex1\quickstart.py", line 9, in <module>
    app = App.from_config("mistral.yaml")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\pythonProjects\embedchain_ex1\.venv\Lib\site-packages\embedchain\app.py", line 417, in from_config
    embedding_model = EmbedderFactory.create(
                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\pythonProjects\embedchain_ex1\.venv\Lib\site-packages\embedchain\factory.py", line 74, in create
    return embedder_class(config=embedder_config_class(**config_data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\pythonProjects\embedchain_ex1\.venv\Lib\site-packages\embedchain\embedder\huggingface.py", line 14, in __init__
    embeddings = HuggingFaceEmbeddings(model_name=self.config.model)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\pythonProjects\embedchain_ex1\.venv\Lib\site-packages\langchain_community\embeddings\huggingface.py", line 62, in __init__
    raise ImportError(
ImportError: Could not import sentence_transformers python package. Please install it with `pip install sentence-transformers`.

I run : pip install sentence-transformers

Second call:

Inserting batches in chromadb: 100%|█████████████████████████████████████████████████████| 1/1 [00:01<00:00,  1.99s/it]
Successfully saved https://www.forbes.com/profile/elon-musk (DataType.WEB_PAGE). New chunks count: 4
Inserting batches in chromadb: 100%|█████████████████████████████████████████████████████| 1/1 [00:27<00:00, 27.62s/it]
Successfully saved https://en.wikipedia.org/wiki/Elon_Musk (DataType.WEB_PAGE). New chunks count: 100
E:\pythonProjects\embedchain_ex1\.venv\Lib\site-packages\langchain_core\_api\deprecation.py:117: LangChainDeprecationWarning: The class `langchain_community.llms.huggingface_hub.HuggingFaceHub` was deprecated in langchain-community 0.0.21 and will be removed in 0.2.0. Use HuggingFaceEndpoint instead.
  warn_deprecated(
E:\pythonProjects\embedchain_ex1\.venv\Lib\site-packages\langchain_core\_api\deprecation.py:117: LangChainDeprecationWarning: The function `__call__` was deprecated in LangChain 0.1.7 and will be removed in 0.2.0. Use invoke instead.
  warn_deprecated(

File mistal.yaml is is the same as the documentation:

llm:
  provider: huggingface
  config:
    model: 'mistralai/Mistral-7B-Instruct-v0.2'
    top_p: 0.5
embedder:
  provider: huggingface
  config:
    model: 'sentence-transformers/all-mpnet-base-v2'

I have no answer. What's wrong ?

PhilFlash commented 7 months ago

Code must be:

from embedchain import App
app = App.from_config("mistral.yaml")
app.add("https://www.forbes.com/profile/elon-musk")
app.add("https://en.wikipedia.org/wiki/Elon_Musk")
answer = app.query("What is the net worth of Elon Musk?")
print(answer)

sorry for the inconvenience