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 when using GritLM with HippoRAG #76

Open
PascualMeritaTorres opened this issue Mar 5, 2025 · 1 comment
Open

AttributeError when using GritLM with HippoRAG #76

PascualMeritaTorres opened this issue Mar 5, 2025 · 1 comment

Comments

@PascualMeritaTorres
Copy link

AttributeError when using GritLM with HippoRAG

Error Description

When running HippoRAG with the GritLM model using the following command:

python main.py --dataset sample --llm_base_url https://api.openai.com/v1 --llm_name gpt-4o-mini --embedding_name GritLM/GritLM-7B

We encounter this error:

AttributeError: 'BaseConfig' object has no attribute 'embedding_return_as_cpu'

Root Cause

The error occurs in the configuration dictionary of GritLLMEmbeddingModel:

config_dict = {
    "embedding_model_name": self.embedding_model_name,
    "return_cpu": self.global_config.embedding_return_as_cpu,         # Error here
    "return_numpy": self.global_config.embedding_return_as_numpy,     # Error here
    "norm": self.global_config.embedding_return_as_normalized,
    "model_init_params": {
        "model_name_or_path": self.embedding_model_name,
        "torch_dtype": "auto",
        "device_map": "auto",  # added this line to use multiple GPUs
        # **kwargs
    },
    "encode_params": {
        "batch_size": self.global_config.embedding_batch_size,
        # "instruction": "",
    },
    "generate_params": {
        # "max_new_tokens": 
        # "do_sample": 
    }
}

The attributes embedding_return_as_cpu and embedding_return_as_numpy are being referenced but were never defined in the BaseConfig class.

Possible Solutions

  1. Add these missing attributes to BaseConfig by doing:
embedding_return_as_cpu: bool = field(
        default=True,
        metadata={"help": "Whether to return embeddings on CPU."}
 )
  embedding_return_as_numpy: bool = field(
      default=True,
      metadata={"help": "Whether to return embeddings as numpy arrays."}
  )
  1. Remove these settings in the config dictionary
@bernaljg
Copy link
Collaborator

bernaljg commented Mar 5, 2025

Thanks for pointing this out!

We have removed the unnecessary attributes from the GritLM class config to avoid this issue. The commit is 2f05c27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants