← Back to Blog

Initialize MrMemory client with API key

The Memory Problem: Why Keyword Search Fails

=====================================================

When building an AI agent that needs to retrieve information from various sources, you're faced with a daunting task. The choice between keyword search and semantic search determines the effectiveness of your agent's memory system. I'll tell you about my own struggles with this problem.

Keyword Search: A Quick Fix with Bitter Consequences

---------------------------------------------------

Keyword search is the traditional method. It matches exact words or word stems in a query against a corpus of text. Sounds straightforward, right? But it has its limitations. For instance, if your user searches for "project deadline extension," a keyword system might miss documents containing related information like "budgeting" or "scheduling."

Here's an example with the MrMemory API:


from mrmemory import MrMemory

# Initialize MrMemory client with API key
client = MrMemory(api_key="your-key")

# Store information using keyword search
client.remember("user prefers dark mode", tags=["preferences"])

# Recall information using keyword search
results = client.recall("what theme does the user like?")

Semantic Search: The Better Way

---------------------------------

Semantic search uses vector embeddings to convert text into numerical representations, allowing agents to find relevant information based on meaning rather than exact keywords. This approach bridges the gap between natural language queries and unstructured documents, making it ideal for conversational memory and diverse user populations.

Here's an example with the MrMemory API:


from mrmemory import MrMemory

# Initialize MrMemory client with API key
client = MrMemory(api_key="your-key")

# Store information using semantic search
client.remember("user prefers dark mode", tags=["preferences"])

# Recall information using semantic search
results = client.recall("what theme does the user like?")

What's the Difference?

-------------------------

PlatformKeyword SearchSemantic Search
MrMemoryFast, PredictableMeaning-Based Recall
Mem0Limited ContextAdvanced Contextualization

Conclusion

--------------

The choice between keyword search and semantic search for AI agents depends on your use case. While keyword search is fast, it can lead to irrelevant results. Semantic search offers a more robust solution by enabling meaning-based recall. Try MrMemory today and experience the power of vector databases in action.

Internal Links

Tags

ai-agent-memory, semantic-search, keyword-search, vector-databases, meaning-based-recall

Ready to give your AI agents memory?

Install in one line. Remember forever. Start with a 7-day free trial.

Start Free Trial →
ZepSelf-Hosted OnlyHybrid Search Approach
MemGPTSelf-Supervised LearningLarge-Scale Knowledge Graph