private-gpt icon indicating copy to clipboard operation
private-gpt copied to clipboard

ISSUE: Model path related error.

Open d2rgaming-9000 opened this issue 1 year ago • 2 comments

File "/home/USER/.local/lib/python3.10/site-packages/langchain/embeddings/llamacpp.py", line 64, in validate_environment
   model_path = values["model_path"]
KeyError: 'model_path' 

Presumably, it does not implement the proper path for the 'model', and I assume that it does not even implement any 'model', until I somehow tell it to use one (But I don't think that's how it is suppoesed to work).

I receive this error when I type in 'python ingest.py'

Full error below:

Python-dotenv could not parse statement starting at line 1
Python-dotenv could not parse statement starting at line 2
Python-dotenv could not parse statement starting at line 3
Python-dotenv could not parse statement starting at line 4
Python-dotenv could not parse statement starting at line 5
Traceback (most recent call last):
  File "/home/USER/Downloads/git/GPT_project/ingest.py", line 36, in <module>
    main()
  File "/home/USER/Downloads/git/GPT_project/ingest.py", line 29, in main
    llama = LlamaCppEmbeddings(model_path=llama_embeddings_model, n_ctx=model_n_ctx)
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic/main.py", line 1102, in pydantic.main.validate_model
  File "/home/jotarokujo/.local/lib/python3.10/site-packages/langchain/embeddings/llamacpp.py", line 64, in validate_environment
    model_path = values["model_path"]
KeyError: 'model_path'

STEPS TO REPRODUCE:

1- pip install -r requirements.txt

2- Rename example.env to .env and edit the variables appropriately.

MODEL_TYPE: GPT4All
PERSIST_DIRECTORY: is the folder you want your vectorstore in

LLAMA_EMBEDDINGS_MODEL: ~/Downloads/git/GPT_project/EMBEDDING_bin //<- this contains ggml-model-q4_0.bin

MODEL_PATH: ~/Downloads/git/GPT_project/GPT4ALL_bin //<- this  contains ggml-gpt4all-j-v1.3-groovy.bin).
MODEL_N_CTX: 1024

3- pip install pdfminer.six

4- run python ingest.py

d2rgaming-9000 avatar May 12 '23 02:05 d2rgaming-9000

This is a problem that goes back to the way langchain loads the embeddings model. For some reason they need a full path. For a quick fix you can simply modify your .env by setting your full (exhaustive) path to the LLAMMA embeddings model. Something like:

# LLAMA_EMBEDDINGS_MODEL=~/Downloads/git/GPT_project/GPT4ALL_bin
> LLAMA_EMBEDDINGS_MODEL=/Users/d2rgaming-9000/Downloads/git/GPT_project/GPT4ALL_bin

andreakiro avatar May 12 '23 08:05 andreakiro

I did that. And I still get the same error.

I provided the full path /home/user/Downloads/....., for every variable. And it still brings the same error.

d2rgaming-9000 avatar May 14 '23 13:05 d2rgaming-9000

I don't know why it seems to be setting the '=' operator as ':' by default for me. (See my .env above as an example).

I have changed it however to match yours.

~~But it still not working.~~

~~It did seem to have changed something.~~

~~For example I stead of error lines 1, 2, 3, .. and 5. Now I'm getting 1 and 8 lines of error references.~~

~~Line 29 and 36 in ingest.py Lines 339 in pydantic.main.BaseModel.... Line 1102 in pydantic.main.validate...~~ ~~Are all the lines that are being referenced regarding this error.~~

~~Finally I get this ``KeyError: 'model_path'`~~

~~Which is the same error that I have been receiving as can also be seen above in the initial post, which makes me assume that it is still not able to determine path.~~

I assumed it was normal to leave the ':' as is. Because the readme specifies only to change the variables.

Now that I have changed all the ':' to '=' operator, it is working fine. Just a little something to keep in mind for anyone who may be facing the same confusing problem in the future.

d2rgaming-9000 avatar May 14 '23 20:05 d2rgaming-9000