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

embeddings:AttributeError: 'tuple' object has no attribute 'embed_documents' #27499

Open
5 tasks done
Hikizzz opened this issue Oct 21, 2024 · 1 comment
Open
5 tasks done

Comments

@Hikizzz
Copy link

Hikizzz commented Oct 21, 2024

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

embeddings=HuggingFaceBgeEmbeddings(model_name="BAAI/bge-m3"),
vector_a,vector_b = embeddings.embed_documents([text1, text2])

Error Message and Stack Trace (if applicable)

Traceback (most recent call last):
File "/home/HwHiAiUser/aircasLLM/src/langchain/toolkit.py", line 126, in
print(textSimChain.invoke({
File "/usr/local/miniconda3/envs/dg/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 4713, in invoke
return self._call_with_config(
File "/usr/local/miniconda3/envs/dg/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 1927, in call_with_config
context.run(
File "/usr/local/miniconda3/envs/dg/lib/python3.10/site-packages/langchain_core/runnables/config.py", line 396, in call_func_with_variable

return func(input, **kwargs) # type: ignore[call-arg]
File "/usr/local/miniconda3/envs/dg/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 4567, in invoke
output = call_func_with_variable_args(
File "/usr/local/miniconda3/envs/dg/lib/python3.10/site-packages/langchain_core/runnables/config.py", line 396, in call_func_with_variable

return func(input, **kwargs) # type: ignore[call-arg]
File "/home/HwHiAiUser/aircasLLM/src/langchain/toolkit.py", line 73, in textSimChain
vector_a,vector_b = embeddings.embed_documents([text1, text2])
AttributeError: 'tuple' object has no attribute 'embed_documents'

Description

  • I'm trying to encoding two strings to vector using embeddings.embed_documents().but not works
  • I have done itcorrectly on ubuntu18,x86 pc with nvidia gpu and intel cpu,using ollamaEmbedding().
  • but when transferring it to .ky10.aarch64,it doesn‘t work.
  • i have tested lastest version and my old version,including langchain(v0.2.1,0.3.4),langchain_core(v0.2.26,v0.3.3),langchain_community(v0.2.10,v0.3.3)
  • i have test HuggingFaceBgeEmbeddings,HuggingFaceEmbeddings,AscendEmbeddings(using npu on this server),the erro information is same.
  • i have test online models(autoDownload by HuggingFaceEmbeddings) and local model,include BAAI/bge-m3 and aspire/acge_text_embedding.
  • other langchain library or functions work including langchain_core.runnables,langchain_openai,....
  • i have checked https://github.com/langchain-ai/langchain/issues/26759 and https://github.com/langchain-ai/langchain/issues/23215.but it seems helpless
  • it seems the error **only occurs in funtcntions decorated by "@chain" !**I make a custiomEmbedding class inherited from embeddings and baseModel from langchain_core and test it isolated i,it works.but putting it in a chainFuction,it works bad.

System Info

System Information

OS: Linux
OS Version: #1 SMP Sun Jun 28 14:27:40 CST 2020
Python Version: 3.10.15 (main, Oct 3 2024, 07:21:53) [GCC 11.2.0]

Package Information

langchain_core: 0.3.12
langchain: 0.3.4
langchain_community: 0.3.3
langsmith: 0.1.136
langchain_chroma: 0.1.2
langchain_huggingface: 0.0.3
langchain_ollama: 0.1.1
langchain_openai: 0.1.19
langchain_text_splitters: 0.3.0
langserve: 0.2.2

Optional packages not installed

langgraph

Other Dependencies

aiohttp: 3.10.10
async-timeout: 4.0.3
chromadb: 0.5.15
dataclasses-json: 0.6.7
fastapi: 0.115.2
httpx: 0.27.2
huggingface-hub: 0.26.0
jsonpatch: 1.33
numpy: 1.26.4
ollama: 0.3.3
openai: 1.52.0
orjson: 3.10.9
packaging: 24.1
pydantic: 2.7.4
pydantic-settings: 2.6.0
pyproject-toml: 0.0.10
PyYAML: 6.0.2
requests: 2.32.3
requests-toolbelt: 1.0.0
sentence-transformers: 2.7.0
SQLAlchemy: 2.0.36
sse-starlette: 1.8.2
tenacity: 8.5.0
tiktoken: 0.8.0
tokenizers: 0.20.1
transformers: 4.45.2
typing-extensions: 4.12.2

@isLenk
Copy link

isLenk commented Oct 22, 2024

Hello, it appears you have a comma on the first line: embeddings=HuggingFaceBgeEmbeddings(model_name="BAAI/bge-m3"),

class A:
    def embed_documents(self, texts):
        return texts

V=A(),
a,b = V.embed_documents([1,2])

AttributeError: 'tuple' object has no attribute 'embed_documents'

Does the issue persist without it?

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