Learning resourcesReviewed · Mem0

Mem0 Custom Prompts for LLM Reranking

Mem0's Custom Prompts is a documentation page for Python developers using Mem0, a memory layer for LLM applications, that explains how to write the prompt its LLM reranker uses to score stored memories against a search query. The prompt runs once per candidate memory; the page explains the scoring_prompt setting, required {query} and {document} placeholders, and numerical scores from 0.0 to 1.0.

Researched 14 Nov 2026

In short.

Mem0's Custom Prompts is a guide for developers customizing how AI assistants rank stored memories, with a separate model evaluation needed for each candidate memory. It supplies Python configuration, domain-specific templates and a prompt comparison loop. Custom templates must contain {query} and {document}, and the score extractor expects values between 0.0 and 1.0. The page recommends requesting only the numerical score. Ranking improvements, runtime compatibility, latency and operating costs are not established.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete selected Custom Prompts page at [https://docs.mem0.ai/components/rerankers/custom-prompts], including its examples, required-variable notice and common-issue guidance. Linked configuration, optimization, provider, repository and Markdown pages are excluded. No explicit reuse licence appears on the selected page. Installation, execution, ranking performance, score extraction and operating costs were not assessed.

The overview

Identity

Custom Prompts is a Mem0 documentation page within its Open Source reranker configuration material: [https://docs.mem0.ai/components/rerankers/custom-prompts]. Its subject is changing the instructions an LLM uses to score candidate memories during search. It provides a guide and examples rather than a standalone application.

Assessment

This guide is useful when memory relevance depends on application priorities such as previous support resolutions, learning objectives or personal preferences. It identifies the configuration setting and output constraints needed to express those priorities. It supplies no measured evidence that a custom template produces better rankings than the default.

Users

The examples suit Python developers building Mem0-based support assistants, educational tools or personal assistants. Beginners receive concrete scoring templates, but need enough Python knowledge to edit nested configuration dictionaries. The examples assume a usable Mem0 environment and memories to search; installation and memory ingestion are not taught here.

Capabilities

The page shows how to replace generic relevance instructions with domain-specific criteria. Its support template considers the current issue, earlier resolutions and customer preferences or constraints. Its educational template considers prerequisites, difficulty and learning objectives. Its personal-assistant template considers recent versus historical importance, personal preferences and habits, and contextual relationships. Additional examples request weighted scoring or analysis of query intent before a final score.

Using it

Requirements

The illustrated configuration imports Memory from mem0 and supplies provider, model and api_key values inside the reranker config; the page does not state which of these fields are mandatory or whether credentials can be provided another way. It names openai and gpt-5-mini as example values. Both {query} and {document} must appear in a custom template. Minimum Python and Mem0 versions, installation dependencies and current model availability are unknown from this page.

Mechanism

A reranker scores candidate search results to help determine their order. Here, each memory is evaluated individually against the query, with one prompt invocation per candidate. The template receives the query through {query} and the memory through {document}. The default rubric runs from 0.0–0.3 for not relevant or no useful information, through 0.4–0.5 slightly relevant, 0.6–0.7 moderately relevant and 0.8–0.9 highly relevant, to 1.0 for a memory that is perfectly relevant and directly answers the query.

Setup

Define a template containing both required placeholders. Set config['reranker']['provider'] to llm_reranker, then place provider, model, api_key and scoring_prompt inside config['reranker']['config']. The example also sets top_k to 5 and constructs the memory object with Memory.from_config(config). The page does not establish which installed releases support this exact configuration.

Example

For customer support, the supplied template asks the model to prioritize memories about the present issue, previous resolution patterns and customer preferences or constraints, then return a relevance score. This expresses the intended ranking policy; no resulting scores or search order are supplied.

The comparison snippet swaps scoring_prompt values, recreates Memory and calls memory.search with a user_id filter. Its named prompt variants require definitions, and the snippet includes no recorded output.

Assessment & evidence

Limitations

The page warns that vague criteria, excessive prompt length, scores outside 0.0–1.0 and extra response text can cause problems. It does not describe retries or handling of invalid model output. Only two template variables are documented, so how timestamps or additional context reach recency-based scoring is unspecified. Ranking accuracy, extraction reliability and latency remain unassessed.

Scoring approach

The weighted example requests 40% relevance, 20% recency, 25% importance and 15% actionability. These percentages are instructions to the model; the page does not demonstrate that they are applied accurately. Another template asks the model to consider query intent and memory content before returning a score. Neither approach has comparative results, and any explanatory output could interfere with the numeric extraction guidance.

Alternatives

The directly documented alternative is retaining the default relevance template, which avoids writing domain-specific criteria. The navigation also names Cohere, Sentence Transformer, Hugging Face and Zero Entropy rerankers. Their linked pages are excluded, so this page does not establish their comparative capabilities, requirements, prices or suitability.

Evidence

Mem0's own page supplies the default prompt, Python configuration, required-variable notice, domain templates, advanced examples and troubleshooting advice. These support its documented interface and intended behavior. It includes no benchmark dataset, measured comparison or saved search results. No code was executed, so successful integration and ranking quality are not established.

Access & freshness

Costs

Prices, token counts and total operating costs are unknown. The documented invocation per candidate means larger candidate sets require more model evaluations; longer templates also increase the text submitted. These are implications of the described mechanism, not measured costs. The top_k value of 5 does not establish that only five candidates are evaluated.

Rights

The page appears under Open Source documentation and links to its GitHub editing location, but supplies no explicit licence for its text or snippets. Permissions for commercial reuse, modification and redistribution are therefore unknown from this page. The navigation label alone does not establish those terms.

Freshness

The supplied page was captured on 14 November 2026. Its metadata reports a last modification of 31 July 2026. No Mem0 package version or repository commit is specified for the examples, so the date does not establish compatibility with a particular release. Later documentation changes and current provider behavior are unknown.

Next steps

Start with the default template as a baseline, then adapt one domain example while retaining both placeholders and requesting only a score. Compare returned rankings on representative queries against the same stored memories. Record invalid scores, candidate counts, latency and model usage to establish practical fit. Confirm release compatibility, provider pricing and reuse terms before adoption.

Evidence for this report

selected-page.htmlselected · checked 2026-11-14