mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

`llama-index-memory-mem0`: embedding dimension is always 0

Open tslmy opened this issue 1 year ago • 2 comments

🐛 Describe the bug

from llama_index.core import Settings
from llama_index.memory.mem0 import Mem0Memory

from llama_index.embeddings.ollama import OllamaEmbedding
from llama_index.llms.openai_like import OpenAILike
from llama_index.agent.openai import OpenAIAgent

Settings.llm = OpenAILike(
    model="llama3.1",
    api_base="http://localhost:11434/v1",
    api_key="ollama",
    is_function_calling_model=True,
    is_chat_model=True,
)
Settings.embed_model = OllamaEmbedding(
    model_name="nomic-embed-text:latest",
)
memory_from_config = Mem0Memory.from_config(
    config={
        "vector_store": {
            "provider": "qdrant",
            "config": {
                "collection_name": "temp",
                "embedding_model_dims": 768,  # Change this according to your local model's dimensions
            },
        },
        "llm": {
            "provider": "ollama",
            "config": {
                "model": "llama3.1",
                "temperature": 0,
                "max_tokens": 8000,
                "ollama_base_url": "http://localhost:11434",
            },
        },
        "embedder": {
            "provider": "ollama",
            "config": {
                "model": "nomic-embed-text:latest",
                "ollama_base_url": "http://localhost:11434",
                "embedding_dims": 768,  # Change this according to your local model's dimensions
            },
        },
    },
    context={"user_id": "test"},
)
agent_runner = OpenAIAgent.from_tools(
    memory=memory_from_config,
)

if __name__ == "__main__":
    agent_runner.chat("Hi!")

Observed:

  File ".../.venv/lib/python3.12/site-packages/qdrant_client/local/distances.py", line 94, in cosine_similarity
    return np.dot(vectors, query)
           ^^^^^^^^^^^^^^^^^^^^^^
ValueError: shapes (0,768) and (0,) not aligned: 768 (dim 1) != 0 (dim 0)

Expected: No exceptions.

Versions:

requires-python = ">=3.12,<3.13"

name = "llama-index-memory-mem0"
version = "0.2.0"

name = "llama-index"
version = "0.12.1"

name = "mem0ai"
version = "0.1.32"

tslmy avatar Nov 24 '24 19:11 tslmy

Hi @tslmy Currently we don't support OpenAIAgent on llama-index. We will increase support to more agents. Please refer this documentation: https://docs.mem0.ai/integrations/llama-index

spike-spiegel-21 avatar Nov 25 '24 12:11 spike-spiegel-21

@spike-spiegel-21 , thanks. That's totally fine. I kinda wished it was more explicit from the docs.

tslmy avatar Dec 30 '24 19:12 tslmy