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
pydantic.error_wrappers.ValidationError: 1 validation error for GPT4All #7778
Comments
I am having a similar issue. This is a minimum code example to reproduce the error: from langchain.llms.gpt4all import GPT4All
llm = GPT4All(model="./models/gpt4all-lora-quantized-ggml.bin") I get the following error:
I tried giving the directory without the Versions:
|
Answer generated by a 🤖 AnswerFrom your description, it appears that you're encountering a In your code, you're initializing the llm = GPT4All(
model = model_path,
callbacks = callbacks,
verbose = False
) The error might be stemming from the Additionally, it's important to verify that your model file is compatible with the To run locally, download a compatible ggml-formatted model. If the model file isn't in the correct format, this could also be causing the error. If the problem persists, it could be due to a compatibility issue between the versions of the libraries you're using. You might need to use specific versions of the libraries that are compatible with each other. In the context shared, it's shown that the llm = GPT4All(model=model_path, max_tokens=2048, callbacks=callbacks, verbose=False) Please ensure that the number of tokens specified in the This is one potential solution to your problem. If you believe this answer is correct and it's a bug that impacts other users, you're encouraged to make a pull request. If this answer contradicts your experience, you might want to consider upgrading to the latest version of the relevant libraries. Sources
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. |
I have tried these approaches but unable to figure out. The only thing I have not tried yet is upgrading my Python version. I know few other folks for whom the same piece of code works on python version > 3.9 |
I was able to fix this issue by downgrading to the below package versions. |
How would downgrading to a previous langchain version solve the issue?? |
I am not certain on how it works but it appeared to me the higher versions of pydantic did not combine well with the combination of higher versions of langchain and gpt4all. After running some tests for few days, I realized that running the latest versions of langchain and gpt4all works perfectly fine on python > 3.10 without hitting the validationErrors on pydantic |
System Info
Python 3.8.10
gpt4all==1.0.5
langchain==0.0.234
pydantic==1.10.11
pydantic-core==2.3.0
Who can help?
No response
Information
Related Components
Reproduction
Code snippet:
from langchain import PromptTemplate, LLMChain
from langchain.vectorstores import Chroma
from langchain.chains import ConversationalRetrievalChain
from langchain.memory import ConversationBufferMemory
from langchain.embeddings import HuggingFaceInstructEmbeddings
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.llms import GPT4All
embedding_model_name = "hkunlp/instructor-large"
persist_directory = 'db'
callbacks = [StreamingStdOutCallbackHandler()]
model_path = "/home/imrohankar/gpttest/DocGPT/models/ggml-gpt4all-j-v1.3-groovy.bin"
llm = GPT4All(
model = model_path,
callbacks = callbacks,
verbose = False
)
Error:
Traceback (most recent call last):
File "/home/imrohankar/gpttest/DocGPT/conversation.py", line 15, in
llm = GPT4All(
File "/home/imrohankar/gpttest/DocGPT/venv/lib/python3.8/site-packages/langchain/load/serializable.py", line 74, in init
super().init(**kwargs)
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 1 validation error for GPT4All
root
'type' object is not subscriptable (type=type_error)
Note: Tried downgrading pydantic, langchain versions but still the error. I am unable to understand why it gives type error while initializing GPT4All
Expected behavior
I would expect it to find the model file at the model path
The text was updated successfully, but these errors were encountered: