Skip to content

🐛 Bug Report: init_empty_weights is not defined during model loading #374

Open
@mmlufer

Description

@mmlufer

Error when executing a request in Agent Zero

Problem Description

When making a request in Agent Zero, an error occurs related to the initialization of VectorDB. The error indicates that the function init_empty_weights is not defined, causing the execution to fail.

Error Details

  • VectorDB Initialization Path: /mmlufer
  • Error Message: NameError: name 'init_empty_weights' is not defined

Error Traceback

plaintext
Traceback (most recent call last):
  File "/a0/agent.py", line 272, in monologue
    # prepare LLM chain (model, system, history)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/a0/agent.py", line 353, in prepare_prompt
    # and allow extensions to edit them
  File "/a0/agent.py", line 696, in call_extensions
    for cls in classes:
        ^^^^^^^^^^^^^^^^
  File "/a0/python/extensions/message_loop_prompts/_91_recall_wait.py", line 13, in execute
    await task
  File "/a0/python/extensions/message_loop_prompts/_50_recall_memories.py", line 67, in search_memories
    db = await Memory.get(self.agent)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/a0/python/helpers/memory.py", line 60, in get
    models.get_model(
  File "/a0/models.py", line 74, in get_model
    model = globals()[fnc_name](name, **kwargs)  # call function by name
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

>>>  7 stack lines skipped <<<

  File "/opt/venv/lib/python3.11/site-packages/sentence_transformers/models/Transformer.py", line 54, in __init__
    self._load_model(model_name_or_path, config, cache_dir, **model_args)
  File "/opt/venv/lib/python3.11/site-packages/sentence_transformers/models/Transformer.py", line 85, in _load_model
    self.auto_model = AutoModel.from_pretrained(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/transformers/models/auto/auto_factory.py", line 571, in from_pretrained
    return model_class.from_pretrained(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/transformers/modeling_utils.py", line 279, in _wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/transformers/modeling_utils.py", line 4333, in from_pretrained
    model_init_context = cls.get_init_context(is_quantized, _is_ds_init_called)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/transformers/modeling_utils.py", line 3736, in get_init_context
    init_contexts = [no_init_weights(), init_empty_weights()]
                                        ^^^^^^^^^^^^^^^^^^
NameError: name 'init_empty_weights' is not defined

Steps to Reproduce

Execute a request in Agent Zero that initializes VectorDB at the path /mmlufer.
Observe the error in the console.
Expected Behavior
The request should execute successfully without errors, and VectorDB should initialize properly.

Actual Behavior

The process fails with a NameError because init_empty_weights is not defined.

Additional Information

Python Version: 3.11
Affected Package: transformers (possibly related to the installed version or missing dependencies).
Virtual Environment: /opt/venv
Possible Cause
The error seems to be related to a missing or improperly defined function in the transformers library. It is possible that the installed version is incompatible with the current code or that an update is required.

Request

Please investigate the issue and provide a solution or guidance to resolve it. If necessary, indicate whether a library update or a change in the codebase is required. ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions