Trainable Sparse Vector Memory for Frozen Language Models: A Controlled Synthetic Binding Study with Qwen2.5-0.5B
2026
Large language models store factual knowledge inside dense model parameters, making targeted factual updates difficult, expensive, and hard to isolate. This paper studies a narrower prototype: a frozen pretrained causal language model augmented with a trainable sparse vector memory module. The base model is Qwen2.5-0.5B, and all of its weights remain frozen. Only the added memory system is trained. The memory module contains a router MLP, trainable keys, a trainable sparse value table, a value projection layer, and a sigmoid gate. Retrieved value vectors are injected into the hidden state after transformer layer 8 as a residual update. We evaluate the system on deterministic synthetic entity-code bindings, such as ENTITY-000042 -> FROST-32, where the base model has no prior access to the mapping. An initial 10,000-fact full-code experiment failed exact binding retrieval: the model learned answer format but not entity-specific bindings. After moving to a controlled 100-fact overfitting task, enforcing repeated exposure to every fact, and reducing answer entropy before returning to the harder full-code case, the system succeeded. Across four successful follow-up runs, seen exact-match accuracy reached 1.00, while unseen exact-match accuracy remained 0.00. Memory ablation sharply increased seen-fact cross-entropy loss, supporting the conclusion that the learned bindings were carried by the inserted memory pathway rather than by the frozen base model. The result does not establish scalability to large memory tables, real-world facts, paraphrased queries, editability, or disk-backed inference. It does show that the core mechanism works under controlled conditions: a frozen small language model can use a trainable sparse vector memory layer to store and retrieve arbitrary synthetic bindings.
Introduction
Large language models store much of their factual knowledge inside dense parameters. That creates a practical problem: once a fact is embedded in the weights, changing it cleanly is difficult. Retraining and fine-tuning can be costly and may alter unrelated behavior. Prompting and retrieval can help, but they operate outside the model's learned hidden-state computation.
Retrieval-Augmented Generation, or RAG, combines parametric knowledge in a pretrained generator with non-parametric memory retrieved from an external corpus. The original RAG formulation conditions generation on retrieved Wikipedia passages and improves knowledge-intensive generation tasks [1]. The present study asks a different question: can a frozen language model use a trainable vector memory module inserted inside the transformer stream, without updating the base model and without appending retrieved text to the prompt?
The architecture is intentionally simple: a frozen Qwen2.5-0.5B base model augmented with a trainable router, trainable memory keys, a trainable sparse value table, a value projection layer, and a trainable gate [5]. The memory output is injected into the residual stream after transformer layer 8.
The core research question is: **Can a frozen small language model learn to use an added trainable sparse memory layer to store and retrieve arbitrary synthetic entity-code bindings?** This is not a claim about solving long-term memory for language models in general. It is a controlled proof-of-life experiment.
To test the mechanism, we generate synthetic facts such as: `Question: What is the access code for ENTITY-000042?` `Answer: FROST-32` The mapping from entity ID to code is deterministic but arbitrary. The base model cannot know the correct answer unless the added memory pathway learns the binding.
The paper reports two central outcomes. First, a naive 10,000-fact full-code experiment failed exact binding retrieval even though training loss decreased. Second, after reducing the task to 100 facts, increasing exposure, and using deterministic cycling through all facts, the system achieved perfect seen exact-match accuracy and zero unseen exact-match accuracy across multiple successful runs. The repository contains the cleaned codebase, experiment configurations, scripts, outputs, and figures used for this study [10].
System overview. A frozen Qwen2.5-0.5B model processes the input token sequence. After transformer layer 8, a trainable memory module receives the hidden state, routes it to memory slots, retrieves value vectors, gates the result, and injects the memory update back into the residual stream. Only the memory module weights are trained.
Related Work
Retrieval-Augmented Generation
RAG is the closest broad family of work. It combines a pretrained generator with a retriever over an external text corpus, using retrieved documents as additional conditioning information for generation [1]. The current study differs in two key ways: the retrieved object is not text but a trainable vector, and the retrieved information is injected into a hidden state rather than appended to the prompt.
kNN-LM
kNN-LM extends a pretrained language model by interpolating its output distribution with a nearest-neighbor model over a datastore of hidden states and target tokens. Khandelwal et al. show gains in perplexity and report that the method is especially useful for rare patterns and factual knowledge [2]. Our method is memory-like in spirit, but the value table is trainable through gradient descent rather than a fixed datastore of observed examples.
RETRO
RETRO conditions an autoregressive language model on retrieved chunks from a massive text database. Borgeaud et al. report retrieval over a two-trillion-token database and competitive performance relative to much larger language models [3]. RETRO demonstrates the value of retrieval at scale, whereas this work isolates a smaller mechanistic question: whether a frozen transformer can obey a trained vector-memory injection path.
Product-Key Memory
Product-Key Memory is particularly relevant for future scaling. Lample et al. introduce a structured memory layer that can support very large memory capacity with efficient lookup through product keys [4]. The present implementation instead uses flat dense key search, which is useful for a controlled prototype but not appropriate for millions or billions of slots.
Trainable Embedding Tables and Sparse Optimization
The value table in this project is implemented with `torch.nn.Embedding`, a learnable lookup table whose rows are selected by integer indices [6]. When sparse gradients are enabled, only selected embedding rows need sparse-gradient updates. The training setup therefore uses `SparseAdam` for the value table; PyTorch describes it as an Adam-style optimizer that updates entries corresponding to non-zero sparse gradients [7].
Base Model
The base model is Qwen2.5-0.5B. The Qwen2.5 model card describes a family of base and instruction-tuned models spanning 0.5B to 72B parameters [5]. In this study, the selected base model is fully frozen, and only the inserted memory module is optimized.
Architecture
The system has two parts: a frozen causal language model and a trainable memory module. The memory module is inserted after transformer layer 8. A hidden state from the frozen transformer is routed through the memory system, transformed into a memory update, and added back into the residual stream before the remaining frozen layers and language-model head complete the forward pass.
The memory module contains five trainable components: 1. Router MLP 2. Key table 3. Value table 4. Value projection 5. Gate
The hidden state at the injection point has shape `B x T x 896`, where `B` is batch size and `T` is sequence length. The router maps this representation into a query tensor of shape `B x T x 128`. In the successful 100-fact experiments, the key table has shape `1000 x 128`. Queries and keys are normalized, and scores are computed using a dot product, which acts as cosine similarity after normalization.
The resulting score tensor has shape `B x T x 1000`. The model selects the top-k memory IDs, using `k = 8` in successful runs. PyTorch's `torch.topk` returns the largest values and their indices along a chosen dimension, which matches the slot-selection requirement here [8].
The value table has shape `1000 x 896`. With `k = 8`, the retrieved value tensor has shape `B x T x 8 x 896`. A softmax over the top-k scores yields mixing weights, producing a weighted sum of selected values. This weighted memory vector is projected back into the model hidden space, and a learned sigmoid gate controls how strongly the memory update enters the residual stream.
h_{\mathrm{new}} = h + g(h) \cdot W_v\left(\sum_{i \in \mathrm{TopK}(qK^\top)} \alpha_i V_i\right)
In plain terms: the router selects memory slots, the value table stores trainable vectors, the projection shapes the retrieved mixture for the frozen transformer, and the gate determines injection strength. The gate matters because always injecting a full-strength memory delta could destabilize a frozen model. In the successful runs, the final gate mean remains active, settling around 0.67 to 0.75 depending on the run.
Memory forward pass. The hidden state from layer 8 is routed into a memory query. The query is compared with the key table, top-k slots are selected, value vectors are retrieved and mixed, and a gated update is added back to the hidden state.
Synthetic Dataset
The dataset is synthetic by design. The objective is not to evaluate world knowledge, but to test whether the memory module can learn arbitrary bindings that the frozen base model does not already know. Each fact maps an entity ID to a code.
Example binding: `ENTITY-000042 -> FROST-32` Prompt template: `Question: What is the access code for ENTITY-000042?` `Answer:` Target answer: `FROST-32`
The dataset generator supports three difficulty modes: | Mode | Example target | |---|---| | `word` | `FROST` | | `short_code` | `FROST-32` | | `full_code` | `FROST-3932` |
The code vocabulary uses ten fixed words: `MANGO`, `VIOLET`, `EMBER`, `FROST`, `ONYX`, `LIME`, `RAVEN`, `SOLAR`, `COPPER`, and `PEARL`. The `short_code` mode combines one word with two digits, while `full_code` uses one word plus four digits, increasing answer entropy.
Fact generation is deterministic. Given the same entity index, seed, and mode, the code remains fixed. The repository documents examples such as `ENTITY-000042 -> FROST-32` for `short_code` and `ENTITY-000042 -> FROST-3932` for `full_code` [10].
The split protocol is also deterministic: | Split | Entity IDs | |---|---| | Seen | `0` to `train_facts - 1` | | Unseen | `20000` onward |
For the main successful experiments, `train_facts = 100`. Therefore, seen examples are IDs 0 through 99, while unseen evaluation begins at ID 20000. This wide separation prevents accidental overlap and supports a clear test of binding memorization rather than extrapolation [10].
Synthetic fact generation and seen/unseen split. Seen facts use IDs 0 to 99. Unseen facts use IDs 20000 and above. Since mappings are arbitrary and deterministic, unseen accuracy should remain zero unless the model accidentally generalizes or evaluation is contaminated.
Training loss is computed only on answer tokens. Prompt tokens are masked with `-100`, so the model is not rewarded for reconstructing the question template. It is rewarded for predicting the access code itself. The evaluation script then extracts generated codes using regex rules matched to the data mode.
Training Setup
The base language model is frozen. Only the memory module is trained. The optimization setup separates dense memory parameters from the sparse value table: | Parameter group | Components | Optimizer | |---|---|---| | Dense memory parameters | router, keys, gate, value projection | AdamW | | Sparse memory parameters | selected value-table rows | SparseAdam |
The successful default overfit configuration is: | Setting | Value | |---|---| | Base model | `Qwen/Qwen2.5-0.5B` | | Insertion layer | 8 | | Memory slots | 1,000 | | Key dimension | 128 | | Value dimension | 896 | | Top-k | 8 | | Training facts | 100 | | Batch size | 16 | | Steps for `short_code` | 3,000 | | Steps for `full_code` | 5,000 | | Dense learning rate | `3e-4` | | Sparse learning rate | `1e-2` | | Max sequence length | 96 | | Dense optimizer | AdamW | | Sparse optimizer | SparseAdam | | Gradient clipping | Dense parameters clipped at norm 1.0 |
The training code logs step, loss, unique memory slots, gate mean, gradient norm, step time, and GPU memory. It saves metrics, summaries, charts, trained memory weights, and exported `fp16` value-table binaries for each run.
The crucial training change was deterministic cycling. The first failed experiment sampled from a large pool of facts, leaving many individual facts undertrained. The successful version repeatedly cycles through all examples, shuffling the order only after every fact has been visited. For 100 facts, 3,000 steps, and batch size 16, training consumes `3,000 x 16 = 48,000` examples, or roughly 480 exposures per fact.
That is not a small implementation detail. It is the difference between 'the model saw some facts a few times' and 'the model has no excuse not to overfit.'
Training loop. The successful experiments use deterministic cycling through all 100 facts so each fact receives repeated exposure. The base model is frozen. Loss is computed only on answer tokens. AdamW updates dense memory parameters, while SparseAdam updates selected value-table rows.
Evaluation
Evaluation uses greedy generation and exact-match scoring. The wrapper calls the model's generation path with `do_sample = False` and `use_cache = False`. Transformers documents greedy decoding as the case where `num_beams = 1` and `do_sample = False` [9]. This matters because the evaluation is deterministic rather than relying on lucky sampling.
The evaluator extracts the newly generated text after the prompt and applies a mode-specific regex: | Mode | Regex target | |---|---| | `word` | uppercase word | | `short_code` | uppercase word plus two digits | | `full_code` | uppercase word plus four digits |
A prediction receives credit only when the extracted code exactly matches the expected code. There is no partial credit.
The two headline metrics are: | Metric | Meaning | |---|---| | Seen exact-match accuracy | Accuracy on trained entity IDs | | Unseen exact-match accuracy | Accuracy on never-trained entity IDs |
For this synthetic task, the desired pattern is high seen accuracy and low unseen accuracy. That may sound backwards if one expects a conventional generalization benchmark, but the mappings are arbitrary. There is no rule that maps `ENTITY-20042` to a correct code unless the model has seen that binding. High unseen performance would instead raise suspicion of leakage, formula learning, or an evaluation bug.
The additional ablation metric is cross-entropy loss with memory enabled and disabled. The memory-off setting zeroes the memory update and leaves the frozen base model unchanged. If seen loss rises sharply when memory is disabled, that supports the claim that the learned bindings are stored in the inserted memory pathway.
Experiments and Results
Experiment 1: Failed 10,000-Fact Full-Code Run
The first experiment was deliberately ambitious: | Setting | Value | |---|---| | Facts | 10,000 | | Mode | `full_code` | | Steps | 800 | | Batch size | 8 | | Memory slots | 20,000 | | Top-k | 4 |
The run looked promising during optimization. Loss dropped from approximately 3.82 to approximately 1.35, the gate opened to roughly 0.80 mean activation, and the router used a non-trivial number of slots. Yet exact-match retrieval failed: | Split | Exact-match | |---|---| | Seen | `0/50 = 0.00` | | Unseen | `0/50 = 0.00` |
The model produced plausible code-shaped outputs such as `MANGO-8000`, but those strings did not match the correct entity-specific answers. The key lesson is that lower loss did not prove correct retrieval.
Training loss going down does not prove memory retrieval.
The failure is easy to diagnose. The run processed `800 x 8 = 6,400` training examples while attempting to fit 10,000 facts. With random sampling and a high-entropy `full_code` target, many facts were not trained enough to support exact binding retrieval.
Failure versus success. The first 10,000-fact full-code run failed despite decreasing loss and active memory usage. The revised 100-fact setting succeeded after reducing fact count, increasing exposure, and lowering difficulty before returning to full-code.
Controlled 100-Fact Overfit Experiments
After the failed pilot, the design was changed as follows: | Change | Reason | |---|---| | Facts reduced from 10,000 to 100 | Make overfitting possible and interpretable | | Steps increased from 800 to 3,000 for `short_code` | Give each fact enough repeated updates | | Batch size increased from 8 to 16 | Increase examples per parameter update | | Top-k increased from 4 to 8 | Give the router more retrieval flexibility | | Memory slots reduced from 20,000 to 1,000 | Better match the small task scale | | Random sampling replaced with deterministic cycling | Prevent undertraining of individual facts | | `full_code` replaced by `short_code` first | Lower answer entropy for debugging |
This controlled version succeeded. The first successful run reached `50/50 = 1.00` seen exact-match accuracy and `0/50 = 0.00` unseen exact-match accuracy.
The cleaned experiment registry contains four successful follow-up runs: | Run | Facts | Mode | Seed | Steps | Seen exact-match | Unseen exact-match | Interpretation | |---|---:|---|---:|---:|---:|---:|---| | 10k-fact full-code | 10,000 | `full_code` | 1234 | 800 | 0.00 | 0.00 | Learned format, not binding | | 100-fact short-code | 100 | `short_code` | 1234 | 3,000 | 1.00 | 0.00 | Successful binding overfit | | 100-fact short-code | 100 | `short_code` | 2025 | 3,000 | 1.00 | 0.00 | Successful binding overfit | | 100-fact short-code | 100 | `short_code` | 777 | 3,000 | 1.00 | 0.00 | Successful binding overfit | | 100-fact full-code | 100 | `full_code` | 1234 | 5,000 | 1.00 | 0.00 | Successful harder binding overfit |
The important finding is not merely that seen accuracy reached 1.00. The equally important result is that unseen accuracy remained 0.00. Because the mappings are arbitrary, this split is consistent with learned training bindings rather than discovery of a hidden deterministic rule.
Seen versus unseen exact-match accuracy. All four successful 100-fact runs achieved 1.00 seen accuracy and 0.00 unseen accuracy. The failed 10,000-fact run achieved 0.00 on both splits. The seen/unseen gap is the main evidence of entity-specific binding.
Memory Ablation
The memory ablation asks a direct question: **Does the model still know the answers when the memory pathway is disabled?** If the answer were yes, the memory module would not be necessary. Because the base model is frozen, it should not acquire synthetic entity-code bindings through ordinary parameter updates.
Average cross-entropy loss was measured on seen and unseen facts with memory enabled and disabled. The generated paper report records 128 seen and 128 unseen facts for the ablation study.
Memory ablation results: | Run | Seen loss ON | Seen loss OFF | Seen increase | Unseen loss ON | Unseen loss OFF | Unseen change | |---|---:|---:|---:|---:|---:|---:| | 100-fact `full_code`, seed 1234 | 1.0823 | 3.7628 | +2.6805 | 4.5133 | 3.8511 | -0.6622 | | 100-fact `short_code`, seed 2025 | 0.8013 | 4.2119 | +3.4106 | 3.3155 | 4.4824 | +1.1669 | | 100-fact `short_code`, seed 777 | 0.8111 | 4.2527 | +3.4416 | 3.5120 | 4.3813 | +0.8693 |
The seen-fact ablation is the strongest evidence that the memory pathway matters. With memory enabled, seen loss is low. With memory disabled, seen loss rises sharply into the range of approximately 3.76 to 4.25. This supports the claim that the frozen Qwen model alone does not recover the trained synthetic codes.
The unseen behavior is mixed. In the `full_code` run, memory hurts unseen loss, suggesting specialization to trained entities. When the router encounters an unknown entity, it can still retrieve trained slots and inject unhelpful information. A practical memory system would require confidence estimation, rejection, or a fallback mechanism.
Memory ablation loss. On seen facts, disabling memory causes a large cross-entropy loss increase, indicating that the memory path carries the learned binding information. On unseen facts, behavior is mixed; in full-code mode, memory worsens unseen loss, suggesting specialization to trained entities.
Training Dynamics
The successful runs and the failed pilot have qualitatively different training trajectories. The failed 10,000-fact run lowers loss but plateaus around 1.35. This is enough to learn answer shape but not enough to reach exact binding retrieval.
By contrast, the successful 100-fact runs collapse to near-zero loss, reaching roughly `1e-5` to `2e-5` in the best cases. This difference matters because it aligns with exact-match success, not merely smoother-looking training curves.
Training loss curves for all runs. The successful 100-fact runs collapse to near-zero training loss. The failed 10,000-fact run plateaus, showing that loss reduction alone was not enough for exact binding retrieval.
Gate and slot diagnostics are useful but insufficient. The memory gate opens early and remains active. Successful runs tend to use hundreds of unique memory slots per logged step, while the failed 10,000-fact run uses fewer slots and never achieves exact-match success. However, active gates and slot usage do not prove correct binding on their own.
Gate mean and unique memory slots used during training. Successful runs keep the memory gate active and use a broad range of slots. The failed run shows that active gate behavior and non-trivial slot usage are not sufficient by themselves; exact-match evaluation remains necessary.
Loss, gate activity, and slot counts are diagnostics. Exact-match seen/unseen evaluation is the actual test.
Discussion
What Worked
The central result is that a frozen small language model can use a trained vector-memory pathway for arbitrary synthetic fact bindings under controlled conditions. The evidence chain is straightforward: the base model is frozen, the mappings are arbitrary, seen exact-match reaches 1.00, unseen exact-match remains 0.00, and disabling memory sharply increases seen-fact loss.
What Failed
The 10,000-fact full-code pilot failed, and that failure is scientifically useful. The model generated outputs with the correct surface structure but wrong entity-specific values. It learned answer syntax, not fact binding. The fix was not to blindly train longer, but to design a controlled experiment with fewer facts, lower initial answer entropy, repeated exposure, direct exact-match metrics, and a memory-off ablation.
Why the Binding Works
The likely mechanism is that the router learns to map hidden states associated with a given prompt into stable regions of key space. The top-k lookup selects a small set of value rows, and the trainable value vectors learn to push downstream frozen layers toward the correct answer tokens. The gate learns to inject that memory delta strongly enough to affect generation.
The lookup operation itself is not the learning bottleneck. The selected `nn.Embedding` rows remain trainable, and sparse gradients allow selected rows to receive updates [6]. The harder question is whether the router learns stable and useful slot selection, which the successful controlled runs suggest it can.
Why the Full-Code Result Matters
The `full_code` run is more demanding than `short_code` because the answer requires a word plus four digits. The successful `full_code`, seed 1234 run still reaches 1.00 seen exact-match and 0.00 unseen exact-match. This suggests that the memory path can support higher-entropy code strings, at least for 100 facts. However, only one full-code seed was tested, so stronger stability claims would require additional seeds.
Main Scientific Lesson
The main lesson is simple and unforgiving: **loss reduction is not enough. Exact binding evaluation is required.** For memory research of this kind, the minimum evaluation package should include seen exact-match, unseen exact-match, memory-on loss, memory-off loss, and multiple seeds where feasible.
Limitations
This work has serious limitations, and they define the boundary of the claim.
First, only 100-fact success is demonstrated. The first attempt at 10,000 facts failed.
Second, the current retrieval over memory keys is dense and flat. It scores against every key and therefore does not scale naturally to very large tables. Product-key memory or approximate nearest-neighbor retrieval would be needed for larger regimes [4].
Third, the dataset is synthetic. There are no real-world facts, natural entity names, paraphrased queries, multi-hop questions, or conflicting updates.
Fourth, only one injection point is tested: after transformer layer 8. Other insertion layers, multiple insertion points, or replacement of internal blocks remain unexplored.
Fifth, the study does not include strong baselines such as prompt stuffing, RAG over text records, LoRA adaptation, prefix tuning, or kNN-style datastore retrieval.
Sixth, no editability experiment is performed. The paper does not yet show that one binding can be changed without damaging others.
Seventh, disk-backed inference is not evaluated. The repository includes `DiskValueTable` infrastructure and exports raw memory values, but it does not report latency, throughput, cold-cache performance, or warm-cache performance [10].
Eighth, the harder `full_code` case is tested on only one seed.
Ninth, prompt robustness remains untested. The current experiment uses a fixed prompt template, so paraphrase generalization is unknown.
Future Work
Scaling to More Facts
The next step is a controlled scaling ladder: 1. 100 facts, `full_code`, more seeds 2. 1,000 facts, `short_code` 3. 1,000 facts, `full_code` 4. 10,000 facts, `short_code` 5. 10,000 facts, `full_code` The goal is not to assume smooth scaling, but to locate where the current mechanism breaks.
Paraphrase Robustness
Future tests should include semantically equivalent prompt forms, such as: `What code belongs to ENTITY-000042?` `Tell me the access code for ENTITY-000042.` `ENTITY-000042 has which access code?` `Retrieve the code for ENTITY-000042.`
Editability
A practical memory module should support targeted updates. A direct next experiment is to train 100 facts, revise 10 of them, and measure whether edited facts change correctly while unedited facts remain stable.
Confidence and Rejection
The mixed unseen ablation results indicate a need for confidence-aware memory use. Candidate approaches include a top-k score margin threshold, entropy over retrieval weights, a learned confidence head, gate regularization, or a fallback to the base model when retrieval is uncertain.
Product-Key or Approximate Search
Dense key search will not support very large memory tables efficiently. Product-key memory is a natural next step, and approximate nearest-neighbor systems may also be suitable when retrieval speed matters more than exact dense search [4].
Disk-Backed Inference
The longer-term objective is to keep a large value table outside VRAM and fetch only selected rows during inference. A serious disk-backed evaluation should separate VRAM-table inference, CPU-RAM-table inference, memory-mapped warm-cache inference, memory-mapped cold-cache inference, random-access latency, and batched lookup latency.
Reproducibility
The public repository contains experiment configs, source code, scripts, outputs, tests, and generated paper figures [10]. The repository layout is: | Path | Purpose | |---|---| | `configs/` | One YAML file per experiment | | `src/memory_lm/` | Library code for memory, model wrapper, data, training, evaluation, analysis, and utilities | | `scripts/` | CLI wrappers for training, evaluation, summarization, and plotting | | `experiments/` | Raw run outputs | | `results/` | Clean tables and paper-ready figures | | `tests/` | Unit tests for data determinism, extraction, memory shapes, and masking |
The repository documents the following reproduction commands [10]: `bash pip install torch --index-url https://download.pytorch.org/whl/cu128 pip install -r requirements.txt pip install -e . python scripts/train.py --config configs/overfit_100_short_code_seed1234.yaml python scripts/evaluate.py --run experiments/overfit_100_short_code_seed1234 python scripts/summarize_runs.py python scripts/plot_runs.py pytest tests/ `
The generated paper report states that the codebase uses Python 3.12, PyTorch, Transformers, and a single CUDA GPU, with peak VRAM around 3.43 GiB and 22 tests passing.
Conclusion
This paper tested whether a frozen small language model can use an inserted trainable sparse vector memory module to store arbitrary synthetic factual bindings. The base Qwen2.5-0.5B model remained completely frozen. Only the added memory pathway was trained.
The first large experiment failed. With 10,000 full-code facts and 800 steps, the model learned the shape of the target answers but not the correct entity-specific bindings. That failure matters because it shows that lower loss, active gates, and slot usage do not prove exact retrieval.
After revising the experiment to a controlled 100-fact overfit setting, enforcing repeated exposure, and using seen/unseen exact-match evaluation, the system succeeded. Across four successful runs, seen exact-match accuracy reached 1.00 while unseen exact-match accuracy remained 0.00. Memory ablation sharply increased seen-fact loss, indicating that the learned bindings are carried by the inserted memory pathway.
The defensible claim is narrow but real: **a frozen Qwen2.5-0.5B model can use a trainable sparse vector memory module injected into an intermediate hidden state to overfit arbitrary synthetic entity-code bindings without updating the base model weights.** The work does not show million-scale memory, factual editing, real-world knowledge integration, paraphrase robustness, or production readiness. Those remain future experiments.
Tags: frozen language models, trainable memory modules, sparse vector memory, synthetic binding tasks, hidden-state memory injection, memory ablation, retrieval-augmented architectures, Ranit Bhowmick, Sayanti Chatterjee
Canonical URL: https://ranitbhowmick.com/research/trainable-sparse-vector-memory-for-frozen-language-models-qwen25-05b