Official repository for the Findings of ACL 2026 paper "CLAG: Adaptive Memory Organization via Agent-Driven Clustering for Small Language Model Agents."
CLAG is an agent memory system designed for small language model (SLM) agents. It organizes long-term memory through agent-driven semantic clustering, tailoring memory organization and retrieval to SLMs' sensitivity to irrelevant context.
CLAG employs an SLM-driven router to assign incoming memories to semantically coherent clusters and autonomously generates cluster-specific profiles—including topic summaries and descriptive tags—to establish each cluster as a self-contained functional unit.
Keywords: Agent memory · LLM memory · Small language models (SLMs) · Long-term memory · Memory-augmented agents · Semantic clustering
SLM agents need memory systems optimized for their capabilities. A single global retrieval pool can mix unrelated topics and expose an agent to distracting context. Small language models are especially sensitive to this irrelevant evidence, making focused memory retrieval essential. CLAG keeps memory updates local to coherent clusters and retrieves evidence in two stages to reduce cross-topic interference and keep retrieved context relevant.
CLAG addresses this problem with three key components:
- Agentic Routing: routes each new memory into the most appropriate semantic cluster
- Localized Evolution: refines and consolidates memories only within the routed cluster
- Cluster-Aware Two-Stage Retrieval: first selects relevant clusters, then retrieves fine-grained evidence only inside them
.
├── CLAG_memory.py # CLAG memory implementation
├── test_CLAG.py # Main evaluation / experiment entry point
├── prepare_bioasq.py # BioASQ preprocessing
├── prepare_bioasq_gold_context.py # BioASQ preprocessing utilities
├── run_prepare_bioasq_all.sh # BioASQ preprocessing pipeline
├── data/ # Datasets and processed files
├── logs_CLAG/ # Experiment logs
├── results_CLAG/ # Output results
└── figure/ # README figures
- Python 3.9+ recommended
git clone https://github.com/dmis-lab/CLAG.git
cd CLAG
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtNote
Some NLTK resources may be downloaded at runtime if they are not already installed.
The following datasets are already included under data/:
- HotpotQA
- LoCoMo
BioASQ is not distributed with this repository. Please download the required files from the official BioASQ participant area:
- training10b
- test dataset
After downloading, place the files under data/ and run:
bash run_prepare_bioasq_all.shThis script generates processed files under data/processed/, including chunked versions used in the experiments.
Run CLAG evaluation with:
python3 test_CLAG.py \
--dataset data/locomo10.json \
--backend sglang \
--model gpt-4o-mini--dataset: path to the evaluation dataset JSON--backend: backend to use (openai,ollama, orsglang)--model: model name for the selected backend--output: path to save output JSON--ratio: evaluate only a subset of the dataset (0.0to1.0)--retrieve_k: retrieval top-k (default:10)
export OPENAI_API_KEY="YOUR_KEY"By default, CLAG expects an SGLang server at:
http://localhost:30000
You can override this with:
--sglang_host--sglang_port
Make sure your Ollama server is running locally and the specified model is available.
To reproduce the main experiments, use test_CLAG.py with the target dataset and backend configuration.
If you find this repository useful, please cite the Findings of ACL 2026 paper:
@inproceedings{roh-etal-2026-clag,
title = "{CLAG}: Adaptive Memory Organization via Agent-Driven Clustering for Small Language Model Agents",
author = "Roh, Taeyun and
Jang, WonJune and
Jung, Junha and
Kang, Jaewoo",
editor = "Liakata, Maria and
Moreira, Viviane P. and
Zhang, Jiajun and
Jurgens, David",
booktitle = "Findings of the {A}ssociation for {C}omputational {L}inguistics: {ACL} 2026",
month = jul,
year = "2026",
address = "San Diego, California, United States",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2026.findings-acl.824/",
doi = "10.18653/v1/2026.findings-acl.824",
pages = "16707--16726",
ISBN = "979-8-89176-395-1"
}
