Skip to content

mem0.add() does not store embeddings in Qdrant when using Ollama (mxbai-embed-large); returns {'results': []} #3441

Description

@ankurphani

🐛 Describe the bug

This is probably a bug. I observed that the embeddings are not stored in quadrant store using .add().

It does not return any error message either.

Here is my config.

from mem0 import Memory

config = {
    "vector_store": {
        "provider": "qdrant",
        "config": {
            "collection_name": "test",
            "host": "localhost",
            "port": 6333,
            "embedding_model_dims": 1024,
        }
    },
    "llm": {
        "provider": "ollama",
        "config": {
            "model": "llama3.1:latest",
            "temperature": 0,
            "max_tokens": 2000,
            "ollama_base_url": "http://localhost:11434",
        },
    },
    "embedder": {
        "provider": "ollama",
        "config": {
            "model": "mxbai-embed-large",
            "ollama_base_url": "http://localhost:11434",

        },
    }
}

# Initialize Memory with the configuration
try:
    m = Memory.from_config(config)
except Exception as e:
    print(f"Error initializing Memory: {e}")
    exit(1)

# Add a memory
messages = [
    {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
    {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."},
    {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."},
    {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
]
try:
    m.add(messages, user_id="john")

except Exception as e:
    print(f"Error adding memory: {e}")
    exit(1)

# Retrieve memories
try:
    related_memories = m.search(query="What do you know about me?", user_id="john")
    print(f"related_memories: {related_memories}")
except Exception as e:
    print(f"Error retrieving memories: {e}")
    exit(1)

The above code returns

{'results': []}

I manually upserted the data in qdrant store using their REST API and it worked fine.

I have verified that the embedding model dimensions are right. i.e. 1024

resp = requests.post("http://localhost:11434/api/embeddings", json={
    "model": "mxbai-embed-large",
    "prompt": "dimension check"
})
vec = resp.json()["embedding"]
print(len(vec))  # this prints 1024

Can anyone confirm having this same issue using Ollama and Qdrant or there is some configuration issue from my side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions