News › #llm

Hy-Memory-30B-A3B: Tencent trains a small model whose only job is writing agent memory

5 min readVerified

Tencent's Hy-Memory-30B-A3B replaces the general-purpose LLM that memory frameworks such as Mem0 and MemOS use to decide what to store. It is trained with on-policy distillation and chunk-level reinforcement learning that rewards later answerability and penalizes bank growth.

In short

Tencent's Hunyuan team released Hy-Memory-30B-A3B, a small mixture-of-experts model (30B total, about 3B active parameters) whose only job is to write long-term memory for AI agents. Today most agent memory frameworks (for example Mem0 or MemOS) ask a large general-purpose model, through framework-specific prompts, to decide what to store. The paper argues that a dedicated, trained writer can be cheaper to run and better at this task, and that one writer can serve several frameworks. On the authors' own benchmark it scores slightly higher than Claude Opus 5 used as the writer, although most of the margins are very small.

How it works

An agent with external memory works in two steps. The write step reads a new piece of conversation and decides what to add, change or delete in a memory store (the bank). The read step later searches the bank to answer a question. If the writer stores the wrong things, or stores too much, the reader cannot recover.

Hy-Memory-30B-A3B only replaces the writer. The memory framework (its storage, its schema, its retrieval) stays as it is. The model receives a chunk of about ten conversation turns plus selected parts of the current bank, and outputs structured operations in that framework's format. The framework executes them and produces the next bank.

Training rewards the writer for one thing in the end: can a later reader answer questions from the bank? It also penalizes storing content that should not be stored and letting the bank grow too fast.

Under the hood

Formulation. For chunk t, harness configuration h, bank M_t and model output a_t, the next bank is M_{t+1} = T_h(M_t, a_t). Training uses windows of up to 5 consecutive chunks. Banks written by the policy are carried from window to window, so training sees the same kind of accumulated state as deployment.

Stage 1 – Memory on-policy distillation. The student (an instruction-tuned Hy3-30B-A3B) writes memory itself; a frozen, larger Hy3 teacher scores the student's tokens. The loss is a top-50 approximation of reverse KL:

ℓ = Σ_{v ∈ top-50} π_θ(v|·) · [log π_θ(v|·) − log π_T(v|·)]

Because the student is trained on states it produced, it learns to recover from its own earlier writes.

Stage 2 – Memory RL. Three signals per chunk:

  • Dense probes prm[t]: questions that test whether facts introduced in chunk t are stored precisely. The probe set includes 8,599 trap probes for content that must not be stored, such as generic encouraging phrases from the assistant.
  • Attributed cross-chunk reward orm[t]: for questions that need several chunks, gold facts are mapped back to their source chunks, so each chunk gets credit only for the evidence it contributed. The paper averages per chunk so a chunk does not gain weight just because many questions cite it.
  • Bank-growth penalty: with g_t = bank tokens added ÷ chunk tokens and per-framework thresholds ℓ_h, u_h:
x_t   = clip((g_t − ℓ_h) / (u_h − ℓ_h), 0, 1)
pen_t = (e^{3 x_t} − 1) / (e^3 − 1)
s[t]  = 1·prm[t] + 2·orm[t] − 0.3·pen[t]

The penalty counts tokens, not entries, so writing longer records is also penalized. Advantages are computed per chunk position across 8 rollouts of the same window (a chunk-level version of GRPO): A = (s − mean) / (std + ε). After each window the best of the 8 final banks is carried forward. RL ran on 128 H20 GPUs with batches of 64 windows × 8 rollouts.

Results (paper, Table 6; fixed 20% subsamples, macro average of six metrics).

Writer model Mem0 Hy-Memory MemOS EverMemOS (held out) Average
Hy-Memory-30B-A3B 54.02 60.55 50.51 56.89 55.49
Claude Opus 5 53.43 60.53 50.50 54.04 54.62
DeepSeek V4.1 Flash 49.73 60.20 49.17 55.47 53.64
Hy3-A3B base (before training) 40.20 50.39 49.05 50.98 47.66

The clearest result is the gain over its own starting checkpoint (+7.8 points on average) and the result on EverMemOS, a framework not used in training. Against Opus 5, the margins on MemOS (0.01) and Hy-Memory (0.02) are, by the authors' own statement, not statistically resolved.

Limits stated by the authors. Credit assignment is evidence-based, not causal. Rewards rely on rubric judges whose sensitivity was not fully tested. Only one held-out framework was evaluated. Ablations (for example with and without trap probes or the growth penalty) were not run, and there are no repeated training seeds. The paper does not measure serving cost, even though lower cost is part of its motivation.

Unknowns. The license of the weights could not be confirmed from the sources we read; check the model card before use. Some secondary reports mention a "39.3% token reduction"; we did not find this figure in the paper and do not rely on it.

Try it yourself

1. Compute the reward and advantages for one chunk (CPU, Python 3.13, NumPy 2.5). The thresholds low=0.1 and high=0.6 are our own example values; the paper does not publish them.

import numpy as np

def growth_penalty(added_tokens, chunk_tokens, low, high):
    x = np.clip((added_tokens / chunk_tokens - low) / (high - low), 0.0, 1.0)
    return (np.exp(3 * x) - 1) / (np.exp(3) - 1)

prm = np.array([0.9, 0.8, 0.9, 0.6, 0.7, 0.9, 0.5, 0.8])   # 8 rollouts, probe recall
orm = np.array([0.7, 0.6, 0.8, 0.4, 0.6, 0.7, 0.3, 0.5])   # cross-chunk credit
growth = np.array([300, 120, 900, 80, 200, 450, 60, 150])   # tokens added to the bank
pen = growth_penalty(growth, 1000, low=0.1, high=0.6)

s = 1.0 * prm + 2.0 * orm - 0.3 * pen
adv = (s - s.mean()) / (s.std() + 1e-6)
np.set_printoptions(precision=2, suppress=True)
print("penalty  :", pen)
print("score    :", s)
print("advantage:", adv)

Expected output:

penalty  : [0.12 0.01 1.   0.   0.04 0.38 0.   0.02]
score    : [2.26 2.   2.2  1.4  1.89 2.19 1.1  1.79]
advantage: [ 1.06  0.37  0.89 -1.17  0.09  0.86 -1.95 -0.15]

Rollout 3 had the best recall and cross-chunk credit but added 900 tokens for a 1,000-token chunk, so the full penalty pulled it below rollout 1. Change w_pen or the thresholds to see how quickly "store everything" stops paying.

2. Swap the writer in your own memory stack (needs a GPU server). Serve tencent/Hy-Memory-30B-A3B behind an OpenAI-compatible endpoint (for example with vLLM), then point the LLM setting of a Mem0 or MemOS installation at that endpoint, leaving the embedding and retrieval settings unchanged. Compare answer accuracy and bank size against your current writer on a fixed set of conversations. The official framework code and evaluation tools are in the Tencent-Hunyuan/Hy-Memory repository. We have not run this setup ourselves, so check the repository for exact versions and the expected prompt format.

Play with it

Sources

  1. Hy-Memory-30B-A3B: Attributed Reinforcement Learning for Long-Term Memory Writing (arXiv:2610.22196)
  2. Hy-Memory-30B-A3B model card (Hugging Face)
  3. Hy-Memory framework and evaluation code (GitHub)
  4. Tech Jacks Solutions: Tencent Hy Memory 2.0 (secondary report)