Closed austinmw closed 6 months ago
🤖
Hey @austinmw, great to see you diving into the depths of LlamaIndex again! How's everything going on your end?
The error message you're encountering, "AttributeError: 'LangchainEmbedding' object has no attribute '_langchain_embedding'", suggests that the '_langchain_embedding' attribute is not found in the 'LangchainEmbedding' object.
In the LlamaIndex codebase, the '_langchain_embedding' attribute is clearly defined in the 'LangchainEmbedding' class and is assigned a value in the 'init' method. This attribute is used to store the instance of the Langchain embeddings class, which is used to generate embeddings for queries and documents.
This error could occur if you are trying to access the '_langchain_embedding' attribute before it is initialized. Make sure you are not trying to access this attribute before the 'LangchainEmbedding' object is fully initialized.
If you are still encountering this error, it could be due to a version mismatch. The provided context is for version 0.9.44 of the llama-index library. If you are using a different version of the library, the '_langchain_embedding' attribute may not exist or may have a different name.
Please ensure that you are using the correct version of the library and that the 'LangchainEmbedding' object is fully initialized before trying to access the '_langchain_embedding' attribute.
If you've checked all of these and the issue persists, it would be helpful to see the full code of your script, especially the initialization of the LangchainEmbedding
object and the part where you call the _build_index
function. This will help to better understand the context in which the error is occurring.
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
I've initialized the embedding model on this line:
embed_model = LangchainEmbedding(bedrock_embedding)
@austinmw ah, this is related to using multiprocessing :( I had added some (slightly hacky) code to handle pickling needed for multiprocessing, seems like its destroying the private variable here
will see if I can fix that
@logan-markewich Thanks!
@austinmw I tried playing around with this a bit.
The main logic happening is in the getstate and setstate here https://github.com/run-llama/llama_index/blob/c70abf65102de37d5fd78c2efbf0378de91d3e4e/llama_index/schema.py#L65
I'm not able to get something working without breaking other things. I think the solution here is to try and multiprocess one level higher, or instead of multiprocessing, use async operations (although langchain LLMs do not support async at the moment)
At the end of the day, not everything is pickleable 😢
One other thing to try is also using our bedrock abstractions instead of langchain (ours will support async, and might even work with multiprocessing here)
https://docs.llamaindex.ai/en/stable/examples/llm/bedrock.html#bedrock https://docs.llamaindex.ai/en/stable/examples/embeddings/bedrock.html#bedrock-embeddings
Hey @logan-markewich , thanks for looking into it. I actually switched to the LangChain wrappers as a recommendation from another issue thread which said the Bedrock abstractions were not currently well maintained in LlamaIndex (I can't remember exactly what error I was facing at the moment).
Edit: This was the issue that caused me to switch to LangChain wrappers: https://github.com/run-llama/llama_index/issues/9812
@austinmw I just merged/released some refactors the other day -- supposedly they work (I don't have access to test bedrock)
Hi, @austinmw,
I'm helping the LlamaIndex team manage their backlog and am marking this issue as stale. The issue involves a bug causing an AttributeError when running the code and building the index. There have been discussions in the comments about potential solutions, including handling pickling for multiprocessing and considering the use of bedrock abstractions instead of langchain. It was mentioned that some refactors were merged and released, but it's unclear if they address the specific issue.
Could you please let us know if this issue is still relevant to the latest version of the LlamaIndex repository? If it is, please comment on the issue to let the LlamaIndex team know. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.
Thank you for your understanding and cooperation. If you have any further questions or updates, feel free to reach out.
Bug Description
"AttributeError: 'LangchainEmbedding' object has no attribute '_langchain_embedding'
Version
0.9.44
Steps to Reproduce
requirements.txt
:entry_point.py
:Relevant Logs/Tracbacks