Home/Documentation

Guide: Advanced RAG with Tripartite Search

Learn how to combine user, organization, and domain knowledge for superior retrieval.

The Problem with Standard RAG

Standard RAG flattens all knowledge into a single vector space. This makes it hard to distinguish between:

  • Personal context: "I prefer Python"
  • Organizational knowledge: "Our company uses Go for backend"
  • Domain facts: "Python is a dynamic language"

The Solution: Tripartite Search

MemoAir allows you to query all three layers simultaneously but distinctly.

results = client.search.tripartite(
    query="What language should I use for the new service?",
    user_id="user:john",           # Checks John's preferences
    org_id="org:acme",             # Checks company standards
    search_ontology=True           # Checks general tech facts
)

Interpreting Results

The results are tagged by their source graph, allowing your LLM to weigh them appropriately.

# Example Output Logic
for result in results:
    if result.source == "user":
        print(f"User Preference: {result.content}")
    elif result.source == "org":
        print(f"Company Policy: {result.content}")
    elif result.source == "ontology":
        print(f"General Fact: {result.content}")

This enables your agent to say: "While you generally prefer Python (User), the company standard for new backend services is Go (Org). Go is a statically typed language known for performance (Ontology)."

Next Steps