Add model card and link to paper
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,3 +1,68 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: feature-extraction
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Latent Memory 🧠
|
| 7 |
+
|
| 8 |
+
This repository contains the official implementation and artifacts for the paper [One Token per Multimodal Evidence: Latent Memory for Resource-Constrained QA](https://huggingface.co/papers/2606.10572).
|
| 9 |
+
|
| 10 |
+
Latent Memory is a latent-space memory paradigm that replaces raw text or image evidence items with a single high-dimensional latent token produced by a small compressor LLM/VLM. By retrieving and prompting these latent tokens directly to a generator model, it achieves competitive QA performance while significantly reducing token consumption and storage pressure.
|
| 11 |
+
|
| 12 |
+
- **Paper:** [One Token per Multimodal Evidence: Latent Memory for Resource-Constrained QA](https://huggingface.co/papers/2606.10572)
|
| 13 |
+
- **GitHub Repository:** [zz1358m/Latent-Memory-Master](https://github.com/zz1358m/Latent-Memory-Master)
|
| 14 |
+
|
| 15 |
+
## Installation ⚙️
|
| 16 |
+
|
| 17 |
+
```bash
|
| 18 |
+
pip install -r requirements.txt
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
## Usage 🚀
|
| 22 |
+
|
| 23 |
+
The framework provides unified entry points for different experiment families, including text-only (LLaMA/Mistral) and multimodal (LLaVA/Gemma) setups.
|
| 24 |
+
|
| 25 |
+
### Training
|
| 26 |
+
|
| 27 |
+
To train a compressor for a specific task:
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
# Text-only
|
| 31 |
+
python scripts/train_release.py --task text --config configs/config.yaml
|
| 32 |
+
|
| 33 |
+
# LLaVA multimodal
|
| 34 |
+
python scripts/train_release.py --task llava --config configs/config_llava.yaml
|
| 35 |
+
|
| 36 |
+
# Gemma multimodal
|
| 37 |
+
python scripts/train_release.py --task gemma --config configs/config_gemma3_4B_12B.yaml
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
### Evaluation
|
| 41 |
+
|
| 42 |
+
To evaluate a trained checkpoint:
|
| 43 |
+
|
| 44 |
+
```bash
|
| 45 |
+
# Evaluate text-only latent retrieval
|
| 46 |
+
python scripts/eval_release.py --task text --config configs/config.yaml --checkpoint checkpoints/text_llama/model.pt --output results/text_llama --top_k 5
|
| 47 |
+
|
| 48 |
+
# Evaluate on multiple datasets (e.g. HotpotQA, 2WikiMultiHopQA, MuSiQue)
|
| 49 |
+
python scripts/eval_release.py --task text \
|
| 50 |
+
--config configs/config_llama1b_mistral7b.yaml \
|
| 51 |
+
--checkpoint checkpoints/text_llama_mistral/model_best.pt \
|
| 52 |
+
--output results/text_llama_mistral \
|
| 53 |
+
--dataset hotpotqa \
|
| 54 |
+
--ood_datasets 2wikimultihopqa,musique \
|
| 55 |
+
--k_list 1,2,5 \
|
| 56 |
+
--skip_baselines
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Citation
|
| 60 |
+
|
| 61 |
+
```bibtex
|
| 62 |
+
@article{zheng2024one,
|
| 63 |
+
title={One Token per Multimodal Evidence: Latent Memory for Resource-Constrained QA},
|
| 64 |
+
author={Zheng, Zhi and Meng, Ziqiao and Luan, Hao and Liu, Wei and Lee, Wee Sun},
|
| 65 |
+
journal={arXiv preprint arXiv:2606.10572},
|
| 66 |
+
year={2024}
|
| 67 |
+
}
|
| 68 |
+
```
|