无需训练即可实现设备端任务感知检索,提升小模型上下文学习效果。
Gradient-free Task-Conditioned Retrieval for On-Device In-Context Learning

- 用输入输出对构造条件空间,通过闭式正则回归对齐表征。
- 低秩压缩构建紧凑索引,查询时仅需输入和预计算的索引。
- 支持文本与多模态检索,已在树莓派上成功部署验证。
设备端上下文学习依赖预推理检索,从本地记忆中选取有用示例作为上下文。该检索需利用任务信息,在计算、内存和数据暴露受限条件下进行。本文提出无梯度框架CoRA,将冻结编码器转化为任务感知检索器:利用候选输入输出对构建输出驱动的条件空间,并通过闭式岭回归将候选输入表征对齐至该空间;采用低秩分解生成紧凑检索基,候选输出仅用于离线索引构建,查询时只需输入和预计算索引。证明了其秩约束基为输出条件化拟合表示的最优低秩压缩,并推导出无需存储完整拟合矩阵的两阶段流式构建方法。进一步扩展至多模态检索,将视觉表征融入条件与检索空间。在十项文本数据集和四项多模态基准上,使用Llama-3.2-1B、MobileLLM-Pro、OpenFlamingo-3B、Qwen3.5-2B等模型,以及树莓派5的端到端部署均表明,CoRA可在不进行检索器微调、反向传播或调用目标模型的情况下实现有效任务感知检索。
原文摘要 · Abstract (English)
On-device in-context learning (ICL) relies on pre-inference retrieval to select demonstrations for useful context before downstream model inference. This retrieval must exploit task-specific information while operating over local memories under limited computation, memory, and data-exposure budgets. We propose Conditional Retrieval Alignment (CoRA), a gradient-free framework that converts a frozen encoder into a task-conditioned retriever using paired candidate inputs and outputs. CoRA selects complementary encoder layers, constructs an output-derived conditioning space from candidate memory, and aligns candidate input representations to this space through closed-form ridge regression. Low-rank factorization then produces a compact retrieval basis where candidate outputs are used only during offline index construction, whereas query-time retrieval requires only the query input and precomputed index. We show that CoRA's rank-constrained basis is the optimal low-rank compression of the output-conditioned fitted representation, and derive an exact two-pass streaming construction that avoids materializing the full fitted matrix. We further extend the framework to multimodal exemplar retrieval by incorporating visual representations into the conditioning and retrieval spaces. Experiments across ten textual datasets and four multimodal benchmarks with Llama-3.2-1B, MobileLLM-Pro, OpenFlamingo-3B, and Qwen3.5-2B, as well as end-to-end Raspberry Pi~5 deployment demonstrate that CoRA supports effective task-conditioned retrieval without retriever fine-tuning, backpropagation, or target-model calls.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。