Skip to content

enhancement: include LLM-extracted tags and keywords in the embedded document #25

@RutgerBos

Description

@RutgerBos

Problem

On every add_memory, the LLM extracts keywords and tags that enrich each memory. These are stored in ChromaDB metadata but are never included in the text that gets embedded. Only the raw content string is passed to the vector index:

# retrievers.py add_document()
self.collection.add(
    documents=[document],   # ← raw content only
    metadatas=[processed_metadata],
    ids=[doc_id]
)

This means a query like "ollama GPU setup" won't match a memory whose content is "NVIDIA driver 590.48.01 is compatible with kernel 6.17" even though it has tags ["ollama", "gpu", "nvidia"]. The LLM's extraction work is wasted at search time.

Proposed fix

Concatenate content with its tags and keywords before embedding:

searchable_text = content
if tags:
    searchable_text += " " + " ".join(tags)
if keywords:
    searchable_text += " " + " ".join(keywords)

Pass searchable_text as the document to ChromaDB while keeping content as the stored field in metadata. This ensures the embedding captures the enriched signal without changing what gets returned to callers.

Alternative

A proper hybrid search (BM25 over keywords + dense vector over content, with score fusion) would be more principled, but the simple concatenation approach above is low-effort and likely captures most of the gain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions