Closed phamkhactu closed 1 year ago
Answer generated by a 🤖
Hello,
Thank you for reaching out and providing detailed information about your issue. Based on the error message you're encountering, it seems like the LlamaCppEmbeddings is trying to tokenize a text that exceeds its maximum token limit. The maximum token limit for the LlamaCppEmbeddings in LangChain is defined by the n_ctx
parameter, which is set to 512 by default.
Here are a few suggestions that might help you resolve this issue:
Check the length of your documents: Ensure that none of your documents exceed the maximum token limit of the LlamaCppEmbeddings. You can do this by tokenizing your documents and checking their length before passing them to the embed_documents
method.
Use a different embedding model: As suggested in a similar issue #8420, you could try using the GPT4AllEmbeddings instead of the LlamaCppEmbeddings. Here's how you can modify your code to do this:
from langchain.embeddings import GPT4AllEmbeddings
# Replace LlamaCppEmbeddings with GPT4AllEmbeddings
embeddings = GPT4AllEmbeddings()
# Rest of your code remains the same
Please note that you'll need to install the gpt4all
package before you can use GPT4AllEmbeddings
. You can do this by running pip install gpt4all
.
llama-cpp-python
package might resolve the issue. You can do this by running pip install --upgrade llama-cpp-python
.Please try these suggestions and let me know if they help resolve your issue. If not, please provide more information about your documents (e.g., their average length, the maximum length, etc.) and I'll be happy to assist you further.
Best, Dosu
This response is meant to be useful, save you time, and share context. 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.
System Info
Name: langchain Version: 0.0.251
Name: faiss-cpu Version: 1.7.1
Name: llama-cpp-python Version: 0.1.77
Who can help?
No response
Information
Related Components
Reproduction
I get error:
Expected behavior
CppEmbedding can work well with faiss