mem0ai / mem0

The Memory layer for your AI apps
https://mem0.ai
Apache License 2.0
21.63k stars 1.97k forks source link

Hugging Face Embedding Error with Bug #1752

Open qianliyx opened 2 weeks ago

qianliyx commented 2 weeks ago

🐛 Describe the bug

my code

import os
from mem0 import Memory

# os.environ["OPENAI_API_KEY"] = "none" # for embedder

config = {
    "llm": {
        "provider": "ollama",
        "config": {
            "model": "gemma2",
            "temperature": 0,
            "max_tokens": 2048,
            "ollama_base_url": "http://localhost:11434",  # Ensure this URL is correct
        },
    },
    "vector_store": {
        "provider": "chroma",
        "config": {
            "collection_name": "test",
            "path": "resource/knbase",
        }
    },
    "embedder": {
        "provider": "huggingface",
        "config": {
            "model": "multi-qa-MiniLM-L6-cos-v1"
        }
    }
}

m = Memory.from_config(config)
m.add("我喜欢在周末骑自行车", user_id="alice", metadata={"category": "hobbies"})

bug info

File [~/miniforge3/lib/python3.12/site-packages/chromadb/api/types.py:508](http://localhost:8888/lab/tree/~/miniforge3/lib/python3.12/site-packages/chromadb/api/types.py#line=507), in validate_embeddings(embeddings)
    504     raise ValueError(
    505         f"Expected embeddings to be a list with at least one item, got {len(embeddings)} embeddings"
    506     )
    507 if not all([isinstance(e, list) for e in embeddings]):
--> 508     raise ValueError(
    509         "Expected each embedding in the embeddings to be a list, got "
    510         f"{list(set([type(e).__name__ for e in embeddings]))}"
    511     )
    512 for i, embedding in enumerate(embeddings):
    513     if len(embedding) == 0:

ValueError: Expected each embedding in the embeddings to be a list, got ['float']
qianliyx commented 2 weeks ago

sorry its useless,mine is macbook