letta-ai / letta

Letta (formerly MemGPT) is a framework for creating LLM services with memory.
https://letta.com
Apache License 2.0
12.6k stars 1.37k forks source link

TypeError: BertModel.__init__() got an unexpected keyword argument 'safe_serialization' #1195

Closed philiprhoades closed 7 months ago

philiprhoades commented 7 months ago

Describe the bug: Error for memgpt talking to local LLM.

Please describe your setup: What is the output of memgpt version? (eg "0.2.4") 0.3.7

How did you install memgpt? pip install pymemgpt and: pip install 'pymemgpt[local]'

Describe your setup: What's your OS: Fedora Linux v38 (for Python3.11)

How are you running memgpt? tmux Terminal

I have successfully installed oobabooga in Fedora Linux, downloaded and loaded "ehartford_dolphin-2.2.1-mistral-7b" and can chat happily from the oobabooga console but when I try and connect with memgpt using either the airoboros-l2-70b-2.1 or the dolphin-2.1-mistral-7b wrapper I get an error:

# memgpt run                                                                                                                                                     

__ Creating new agent...                                                                                                                                                      
->  __ Using persona profile: 'sam_pov'                                                                                                                                       
->  __ Using human profile: 'basic'                                                                                                                                           
Traceback (most recent call last):                                                                                                                                            
  File "/usr/local/bin/memgpt", line 8, in <module>                                                                                                                           
    sys.exit(app())                                                                                                                                                           
             ^^^^^                                                                                                                                                            
  File "/usr/local/lib/python3.11/site-packages/typer/main.py", line 328, in __call__                                                                                         
    raise e                                                                                                                                                                   
  File "/usr/local/lib/python3.11/site-packages/typer/main.py", line 311, in __call__                                                                                         
    return get_command(self)(*args, **kwargs)                                                                                                                                 
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                 
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__                                                                                        
    return self.main(*args, **kwargs)                                                                                                                                         
           ^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                         
  File "/usr/local/lib/python3.11/site-packages/typer/core.py", line 783, in main                                                                                             
    return _main(                                                                                                                                                             
           ^^^^^^                                                                                                                                                             
  File "/usr/local/lib/python3.11/site-packages/typer/core.py", line 225, in _main                                                                                            
    rv = self.invoke(ctx)                                                                                                                                                     
         ^^^^^^^^^^^^^^^^                                                                                                                                                     
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke                                                                                          
    return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                                                   
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                    
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke                                                                                          
    return ctx.invoke(self.callback, **ctx.params)                                                                                                                            
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                            
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke                                                                                           
    return __callback(*args, **kwargs)                                                                                                                                        
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                        
  File "/usr/local/lib/python3.11/site-packages/typer/main.py", line 683, in wrapper                                                                                          
    return callback(**use_params)  # type: ignore                                                                                                                             
           ^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                             
  File "/usr/local/lib/python3.11/site-packages/memgpt/cli/cli.py", line 683, in run
    memgpt_agent = Agent(
                   ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/memgpt/agent.py", line 264, in __init__ 
    self.persistence_manager = LocalStateManager(agent_state=self.agent_state)
File "/usr/local/lib/python3.11/site-packages/memgpt/memory.py", line 369, in __init__
    self.embed_model = embedding_model(agent_state.embedding_config)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/memgpt/embeddings.py", line 201, in embedding_model
    return default_embedding_model()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/memgpt/embeddings.py", line 141, in default_embedding_model
    return HuggingFaceEmbedding(model_name=model)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/llama_index/embeddings/huggingface/base.py", line 83, in __init__
    model = AutoModel.from_pretrained(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/transformers/models/auto/auto_factory.py", line 563, in from_pretrained
    return model_class.from_pretrained(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/transformers/modeling_utils.py", line 3404, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BertModel.__init__() got an unexpected keyword argument 'safe_serialization'
matthieupoirot1 commented 7 months ago

I've got the same problem trying to contact ollama on windows. I tried with memgpt version 0.3.7, 0.3.6 and 0.3.5 each time reinstalling 'pymemgpt[local]' through pip install

KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK commented 7 months ago

I have the same problem on Google Colab (llama.cpp).

I also tried memgpt 0.3.7 -> 0.3.6 and got the same error with both versions.

I suspected that Google Colab's default python and pip environment was having an effect, so I tried Python in the order of 3.10 -> 3.11, but the same error occurred with every version.

The error seems to be related to the transformer, so the situation may change if you clone memgpt from git, change the transformer version, and then install it.

(Sorry, I don't have time to try this right now)

I look forward to this issue being resolved soon.

philiprhoades commented 7 months ago

The error seems to be related to the transformer, so the situation may change if you clone memgpt from git, change the transformer version, and then install it.

I don't quite understand why you think building from git will make a difference - can you expand on that idea?

farbel commented 7 months ago

If you make use of llama_index, this may help: https://github.com/run-llama/llama_index/pull/11939#issuecomment-2020853800 (bug in llama-index-embeddings-huggingface 0.1.5, solved in 0.2.0)

YanSte commented 7 months ago

Solved my issue: Thanks @farbel

llama-index-embeddings-huggingface 0.1.5, solved in 0.2.0

philiprhoades commented 7 months ago

Not mine:

pip install llama-index-embeddings-huggingface upgrade Requirement already satisfied: llama-index-embeddings-huggingface in /usr/local/lib/python3.11/site-packages (0.1.5) ERROR: Could not find a version that satisfies the requirement upgrade (from versions: none) ERROR: No matching distribution found for upgrade

I am using an old Fedora (38) so I can use Python3.11 - which I needed to do to fix an earlier problem . .

philiprhoades commented 7 months ago

@YanSte ,

Did you read my response? - I tried to update llama-index-embeddings-huggingface to 0.2.0 but CAN'T . .

KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK commented 7 months ago

The error seems to be related to the transformer, so the situation may change if you clone memgpt from git, change the transformer version, and then install it.

I don't quite understand why you think building from git will make a difference - can you expand on that idea?

Sorry for the late reply.

As for my ideas, I'm sorry that they weren't helpful.

The issue was resolved in my environment by upgrading "llama-index-embeddings-huggingface" as already discussed in this issue.

Specifically, it was resolved by the following steps:

pip install 'pymemgpt[local]'==0.3.6

pip install --upgrade llama-index-embeddings-huggingface

In my environment, I checked with pymemgpt version 0.3.6.

Also, in pymemgpt version 0.3.6, "llama-index-embeddings-huggingface" is installed with version 0.1.5, and can be changed by the command "pip install --upgrade llama-index-embeddings-huggingface". , has been upgraded to version 0.2.0.

sarahwooders commented 7 months ago

I wasn't able to reproduce this error, but am upgrading the llama-index-embeddings-huggingface package and fixed an different bug with the embedding_model not being properly set for the "local" embedding model option.

In general, I'd also recommend using the endpoint provided by memgpt quickstart instead of computing embeddings locally, since the model we're using for local computations has very poor performance.