Von 4K auf 400K: Erweiterung des Kontexts von LLMs mit Aktivierungsbeacons
Soaring from 4K to 400K: Extending LLM's Context with Activation Beacon
January 7, 2024
Autoren: Peitian Zhang, Zheng Liu, Shitao Xiao, Ninglu Shao, Qiwei Ye, Zhicheng Dou
cs.AI
Zusammenfassung
Die Nutzung langer Kontexte stellt eine große Herausforderung für große Sprachmodelle dar, da deren Kontextfensterlänge begrenzt ist. Obwohl das Kontextfenster durch Feinabstimmung erweitert werden kann, führt dies zu erheblichen Kosten sowohl während des Trainings als auch der Inferenz und hat einen ungünstigen Einfluss auf die ursprünglichen Fähigkeiten des LLM. In dieser Arbeit schlagen wir Activation Beacon vor, das die Rohaktivierungen des LLM in kompaktere Formen kondensiert, sodass es einen viel längeren Kontext mit einem begrenzten Kontextfenster wahrnehmen kann. Activation Beacon wird als Plug-and-Play-Modul für das LLM eingeführt. Es bewahrt die ursprünglichen Fähigkeiten des LLM bei kurzen Kontexten vollständig, während es gleichzeitig die neue Fähigkeit zur Verarbeitung längerer Kontexte erweitert. Darüber hinaus arbeitet es mit kurzen Schiebefenstern, um den langen Kontext zu verarbeiten, was eine wettbewerbsfähige Speicher- und Zeiteffizienz sowohl im Training als auch in der Inferenz erreicht. Activation Beacon wird durch die autoregressive Aufgabe gelernt, die auf einer Mischung von Beacons mit diversen Kondensierungsraten basiert. Dank dieser Behandlung kann es effizient ausschließlich mit Kurzsequenzdaten in nur 10.000 Schritten trainiert werden, was weniger als 9 Stunden auf einer einzelnen 8xA800-GPU-Maschine in Anspruch nimmt. Die experimentellen Studien zeigen, dass Activation Beacon in der Lage ist, die Kontextlänge von Llama-2-7B um das 100-fache zu erweitern (von 4K auf 400K), während es gleichzeitig ein überlegenes Ergebnis bei Aufgaben zur langen Kontextgenerierung und -verständnis erzielt. Unser Modell und Code werden im BGE-Repository verfügbar sein.
English
The utilization of long contexts poses a big challenge for large language
models due to their limited context window length. Although the context window
can be extended through fine-tuning, it will result in a considerable cost at
both training and inference time, and exert an unfavorable impact to the LLM's
original capabilities. In this work, we propose Activation Beacon, which
condenses LLM's raw activations into more compact forms such that it can
perceive a much longer context with a limited context window. Activation Beacon
is introduced as a plug-and-play module for the LLM. It fully preserves the
LLM's original capability on short contexts while extending the new capability
on processing longer contexts. Besides, it works with short sliding windows to
process the long context, which achieves a competitive memory and time
efficiency in both training and inference. Activation Beacon is learned by the
auto-regression task conditioned on a mixture of beacons with diversified
condensing ratios. Thanks to such a treatment, it can be efficiently trained
purely with short-sequence data in just 10K steps, which consumes less than 9
hours on a single 8xA800 GPU machine. The experimental studies show that
Activation Beacon is able to extend Llama-2-7B's context length by times100
times (from 4K to 400K), meanwhile achieving a superior result on both
long-context generation and understanding tasks. Our model and code will be
available at the BGE repository.