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: 'GPT4All' object has no attribute 'model_type' #622

Closed
45Matches opened this issue Jun 5, 2023 · 3 comments
Closed

AttributeError: 'GPT4All' object has no attribute 'model_type' #622

45Matches opened this issue Jun 5, 2023 · 3 comments
Labels
bug Something isn't working primordial Related to the primordial version of PrivateGPT, which is now frozen in favour of the new PrivateGPT

Comments

@45Matches
Copy link

45Matches commented Jun 5, 2023

Describe the bug and how to reproduce it
Following the setup instructions README.md. First time running the step python privateGPT.py after a successful ingest.py, the error is as follows:

% python privateGPT.py
Found model file.
gptj_model_load: loading model from 'models/ggml-gpt4all-j-v1.3-groovy.bin' - please wait ...
gptj_model_load: n_vocab = 50400
gptj_model_load: n_ctx   = 2048
gptj_model_load: n_embd  = 4096
gptj_model_load: n_head  = 16
gptj_model_load: n_layer = 28
gptj_model_load: n_rot   = 64
gptj_model_load: f16     = 2
gptj_model_load: ggml ctx size = 5401.45 MB
gptj_model_load: kv self size  =  896.00 MB
gptj_model_load: ................................... done
gptj_model_load: model size =  3609.38 MB / num tensors = 285
Traceback (most recent call last):
  File "/Users/user/.pyenv/versions/3.11.3/envs/vikings/privateGPT/privateGPT.py", line 76, in <module>
    main()
  File "/Users/user/.pyenv/versions/3.11.3/envs/vikings/privateGPT/privateGPT.py", line 36, in main
    llm = GPT4All(model=model_path, n_ctx=model_n_ctx, backend='gptj', callbacks=callbacks, verbose=False)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic/main.py", line 1102, in pydantic.main.validate_model
  File "/Users/user/.pyenv/versions/vikings/lib/python3.11/site-packages/langchain/llms/gpt4all.py", line 156, in validate_environment
    values["backend"] = values["client"].model_type
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'GPT4All' object has no attribute 'model_type'

Expected behavior
Running python privateGPT.py for the first time after successful installation, expecting to see the text > Enter your query

Environment

  • MacOS 13.4 M1
  • Python 3.11.3
  • pyenv virtual

Additional context
.env

PERSIST_DIRECTORY=db
MODEL_TYPE=GPT4All
MODEL_PATH=models/ggml-gpt4all-j-v1.3-groovy.bin
EMBEDDINGS_MODEL_NAME=all-MiniLM-L6-v2
MODEL_N_CTX=1000
TARGET_SOURCE_CHUNKS=4

@45Matches 45Matches added the bug Something isn't working label Jun 5, 2023
@beriagraphics
Copy link

Already fixed here #5657

@45Matches
Copy link
Author

45Matches commented Jun 5, 2023

Thank you @beriagraphics. Nice one. I might be missing something, but the error is still occurring after #5657 was fixed? or is it a different model definition issue.

When I change directly model_type='gptj' in GPT4AllModel() init, the code works for me (i get the expected Enter a query: prompt, but not with the backend / client.model_type approach.

From Line 150 of gpt4all.py

        values["client"] = GPT4AllModel(
            model_name,
            model_path=model_path or None,
            model_type='gptj',
            allow_download=values["allow_download"],
        )
        # if values["n_threads"] is not None:
        #     # set n_threads
        #     values["client"].model.set_thread_count(values["n_threads"])
        # values["backend"] = values["client"].model_type
Screenshot 2023-06-05 at 11 04 34 pm

@45Matches
Copy link
Author

Langchain Issue: #5720

@imartinez imartinez added the primordial Related to the primordial version of PrivateGPT, which is now frozen in favour of the new PrivateGPT label Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working primordial Related to the primordial version of PrivateGPT, which is now frozen in favour of the new PrivateGPT
Projects
None yet
Development

No branches or pull requests

3 participants