arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.19598cs.CL
收藏

上下文专家混合增强大语言模型的长上下文感知能力

Mixture of In-Context Experts Enhance LLMs' Long Context Awareness

Gaoling School of Artificial Intelligence, Renmin University of China(中国人民大学高瓴人工智能学院);XiaoMi AI Lab(小米AI实验室);Career Science Lab, BOSS Zhipin(BOSS直聘职业科学实验室);NLP Center, BOSS Zhipin(BOSS直聘自然语言处理中心)

Hongzhan Lin, Ang Lv, Yuhan Chen, Chen Zhu, Yang Song, Hengshu Zhu, Rui Yan

AI总结:

本文提出 MoICE 方法,将 RoPE 角度视为上下文内专家,通过仅训练路由器动态选择多个角度,在保持推理效率的同时增强大语言模型的长上下文感知能力。

摘要:

许多研究表明,大语言模型(LLMs)对不同上下文位置的感知并不均衡。有限的上下文感知能力可能导致关键信息被忽略,进而引发任务失败。尽管已有多种方法被提出以增强大语言模型的上下文感知能力,但同时实现有效性和高效性仍然具有挑战性。本文针对使用 RoPE 作为位置嵌入的大语言模型,提出了一种名为“上下文专家混合”(Mixture of In-Context Experts,MoICE)的新方法来解决这一挑战。MoICE 包含两个关键组成部分:一个集成到大语言模型每个注意力头中的路由器,以及一种轻量级的仅训练路由器的优化策略:(1)MoICE 将每个 RoPE 角度视为一个“上下文内”专家,并证明其能够引导注意力头关注特定的上下文位置。因此,每个注意力头通过路由器动态选择多个 RoPE 角度来灵活处理 token,从而关注所需的位置。该方法降低了忽略关键上下文信息的风险。(2)仅训练路由器的策略冻结大语言模型参数,仅对路由器进行少量步骤的更新。在应用于包括 Llama 和 Mistral 在内的开源大语言模型时,MoICE 在长上下文理解和生成的多个任务上超越了先前的方法,同时保持了良好的推理效率。

英文摘要:

Many studies have revealed that large language models (LLMs) exhibit uneven awareness of different contextual positions. Their limited context awareness can lead to overlooking critical information and subsequent task failures. While several approaches have been proposed to enhance LLMs' context awareness, achieving both effectiveness and efficiency remains challenging. In this paper, for LLMs utilizing RoPE as position embeddings, we introduce a novel method called "Mixture of In-Context Experts" (MoICE) to address this challenge. MoICE comprises two key components: a router integrated into each attention head within LLMs and a lightweight router-only training optimization strategy: (1) MoICE views each RoPE angle as an `in-context' expert, demonstrated to be capable of directing the attention of a head to specific contextual positions. Consequently, each attention head flexibly processes tokens using multiple RoPE angles dynamically selected by the router to attend to the needed positions. This approach mitigates the risk of overlooking essential contextual information. (2) The router-only training strategy entails freezing LLM parameters and exclusively updating routers for only a few steps. When applied to open-source LLMs including Llama and Mistral, MoICE surpasses prior methods across multiple tasks on long context understanding and generation, all while maintaining commendable inference efficiency.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑