Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NVIDIAEmbeddings' object has no attribute 'truncate' #67

Open
gnanaprakash-ravi opened this issue Jul 9, 2024 · 2 comments

Comments

@gnanaprakash-ravi
Copy link

Hi,
I am working on 5_mins_rag_no_gpu.
Facing this error: AttributeError: 'NVIDIAEmbeddings' object has no attribute 'truncate'
on this version: langchain-nvidia-ai-endpoints==0.1.2

Detailed error:

File "C:\Users\inrgna00\OneDrive - Ingram Micro\From Downloads\RAG\mistral.py", line 183, in <module>
    docs = retriever.get_relevant_documents(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\_api\deprecation.py", line 148, in warning_emitting_wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\retrievers.py", line 323, in get_relevant_documents
    raise e
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\retrievers.py", line 316, in get_relevant_documents
    result = self._get_relevant_documents(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\vectorstores.py", line 696, in _get_relevant_documents
    docs = self.vectorstore.similarity_search(query, **self.search_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 530, in similarity_search
    docs_and_scores = self.similarity_search_with_score(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 402, in similarity_search_with_score
    embedding = self._embed_query(query)
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 154, in _embed_query
    return self.embedding_function.embed_query(text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_nvidia_ai_endpoints\embeddings.py", line 156, in embed_query
    return self._embed([text], model_type=self.model_type or "query")[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_nvidia_ai_endpoints\embeddings.py", line 139, in _embed
    if self.truncate:
       ^^^^^^^^^^^^^
AttributeError: 'NVIDIAEmbeddings' object has no attribute 'truncate'

I have tried the version: langchain-nvidia-ai-endpoints==0.0.19
I had this error:

File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\retrievers.py", line 316, in get_relevant_documents
    result = self._get_relevant_documents(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\vectorstores.py", line 696, in _get_relevant_documents
    docs = self.vectorstore.similarity_search(query, **self.search_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 530, in similarity_search
    docs_and_scores = self.similarity_search_with_score(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 402, in similarity_search_with_score
    embedding = self._embed_query(query)
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 154, in _embed_query
    return self.embedding_function.embed_query(text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_nvidia_ai_endpoints\embeddings.py", line 125, in embed_query
    return self._embed([text], model_type=self.model_type or "query")[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_nvidia_ai_endpoints\embeddings.py", line 102, in _embed
    "model": self.get_binding_model() or self.model,
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\_api\deprecation.py", line 148, in warning_emitting_wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_nvidia_ai_endpoints\_common.py", line 690, in get_binding_model
    matches = [model for model in self.available_models if model.id == self.model]
                                  ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_nvidia_ai_endpoints\_common.py", line 620, in available_models
    if self.curr_mode == "nim" or not self.is_hosted:
       ^^^^^^^^^^^^^^
AttributeError: 'NVIDIAEmbeddings' object has no attribute 'curr_mode'
@gnanaprakash-ravi
Copy link
Author

I have tried with .invoke method from the retriever as well.

File "C:\Users\inrgna00\OneDrive - Ingram Micro\From Downloads\RAG\1mistral.py", line 143, in <module>
    docs = retriever.invoke(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\retrievers.py", line 194, in invoke
    return self.get_relevant_documents(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\_api\deprecation.py", line 148, in warning_emitting_wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\retrievers.py", line 323, in get_relevant_documents
    raise e
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\retrievers.py", line 316, in get_relevant_documents
    result = self._get_relevant_documents(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_core\vectorstores.py", line 696, in _get_relevant_documents
    docs = self.vectorstore.similarity_search(query, **self.search_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 530, in similarity_search
    docs_and_scores = self.similarity_search_with_score(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 402, in similarity_search_with_score
    embedding = self._embed_query(query)
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_community\vectorstores\faiss.py", line 154, in _embed_query
    return self.embedding_function.embed_query(text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_nvidia_ai_endpoints\embeddings.py", line 156, in embed_query
    return self._embed([text], model_type=self.model_type or "query")[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\inrgna00\AppData\Local\miniconda3\envs\rag\Lib\site-packages\langchain_nvidia_ai_endpoints\embeddings.py", line 139, in _embed
    if self.truncate:
       ^^^^^^^^^^^^^
AttributeError: 'NVIDIAEmbeddings' object has no attribute 'truncate'

@mattf
Copy link
Collaborator

mattf commented Aug 22, 2024

@gnanaprakash-ravi does your code work with v0.2.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants