While Memobase is designed to provide a comprehensive, global context for each user with very low latency, there are times when you need to search for specific information within a user’s profile.

Memobase provides a powerful, context-aware search method to filter out irrelevant memories and retrieve only what’s needed for the current turn of the conversation.

How Profile Search Works

Unlike simple keyword or semantic matching, Memobase’s profile search uses the LLM to perform a feature-based analysis. It reasons about what aspects of a user’s profile are relevant to their latest query.

For example, if a user asks, “Can you recommend a good restaurant?”, Memobase doesn’t just search for the term “restaurant.” Instead, it identifies key features that would help answer the question, such as:

  • basic_info::location: To determine the city for the restaurant search.
  • interests::food: To understand the user’s cuisine preferences.
  • health::allergies: To know what ingredients to avoid.

This intelligent, feature-based approach results in a much more relevant and helpful set of memories than traditional search methods.

# Assume 'user' is an initialized MemoBaseUser object
contextual_profile = user.profile(
    chats=[{"role": "user", "content": "Find some restaurants for me"}],
    need_json=True
)

print(contextual_profile)

See the API Reference for more details.

Important Considerations

  • Latency: Profile search is a powerful but computationally intensive operation. It can add 2-5 seconds to your response time, depending on the size of the user’s profile. Use it judiciously.
  • Cost: Each profile search consumes Memobase tokens (roughly 100-1000 tokens per call), which will affect your usage costs.