In-context Vectors: Making In Context Learning More Effective and Controllable Through Latent Space Steering

Large language models (LLMs) demonstrate emergent in-context learning capabilities, where they adapt to new tasks based on example demonstrations. However, in-context learning has seen limited effectiveness in many settings, is difficult to quantitatively control and takes up context window space. To overcome these limitations, we propose an alternative approach that recasts in-context learning as in-context vectors (ICV). Using ICV has two steps. We first use a forward pass on demonstration examples to create the in-context vector from the latent embedding of the LLM. This vector captures essential information about the intended task. On a new query, instead of adding demonstrations to the prompt, we shift the latent states of the LLM using the ICV. The ICV approach has several benefits: 1) it enables the LLM to more effectively follow the demonstration examples; 2) it's easy to control by adjusting the magnitude of the ICV; 3) it reduces the length of the prompt by removing the in-context demonstrations; 4) ICV is computationally much more efficient than fine-tuning. We demonstrate that ICV achieves better performance compared to standard in-context learning and fine-tuning on diverse tasks including safety, style transfer, role-playing and formatting. Moreover, we show that we can flexibly teach LLM to simultaneously follow different types of instructions by simple vector arithmetics on the corresponding ICVs.

Why Can GPT LearnIn-Context? Language…Why Can GPT Learn In-Context? Language Models Secretly Perform Gradient Descent as Meta-OptimizersLoRA: Low-RankAdaptation of Large…LoRA: Low-Rank Adaptation of Large Language ModelsIn-Context LearningCreates Task VectorsIn-Context Learning Creates Task VectorsInference-TimeIntervention: Eliciting…Inference-Time Intervention: Eliciting Truthful Answers from a Language ModelJudging LLM-as-a-Judgewith MT-Bench and…Judging LLM-as-a-Judge with MT-Bench and Chatbot ArenaRepresentationEngineering: A Top-Down…Representation Engineering: A Top-Down Approach to AI TransparencyLLaMA: Open andEfficient Foundation…LLaMA: Open and Efficient Foundation Language ModelsActivation Addition:Steering Language Model…Activation Addition: Steering Language Models Without OptimizationSelf-DetoxifyingLanguage Models via…Self-Detoxifying Language Models via Toxification ReversalLarger language modelsdo in-context learning…Larger language models do in-context learning differentlyDiscovering LatentKnowledge in Language…Discovering Latent Knowledge in Language Models Without SupervisionSafety-Tuned LLaMAs:Lessons From Improving…Safety-Tuned LLaMAs: Lessons From Improving the Safety of Large Language Models that Follow InstructionsFunction Vectors inLarge Language ModelsFunction Vectors in Large Language ModelsPersonalized Steering ofLarge Language Models…Personalized Steering of Large Language Models: Versatile Steering Vectors Through Bi-directional Preference OptimizationImprovingInstruction-Following i…Improving Instruction-Following in Language Models through Activation SteeringAnalyzing theGeneralization and…Analyzing the Generalization and Reliability of Steering VectorsAligning Large LanguageModels with…Aligning Large Language Models with Representation Editing: A Control PerspectiveFinding Visual TaskVectorsFinding Visual Task VectorsControllable TextGeneration for Large…Controllable Text Generation for Large Language Models: A SurveyReFT: RepresentationFinetuning for Language…ReFT: Representation Finetuning for Language ModelsRepresentationEngineering for…Representation Engineering for Large-Language Models: Survey and Research ChallengesSemantics-AdaptiveActivation Intervention…Semantics-Adaptive Activation Intervention for LLMs via Dynamic Steering VectorsM2IV: Towards Efficientand Fine-grained…M2IV: Towards Efficient and Fine-grained Multimodal In-Context Learning in Large Vision-Language ModelsA Unified Understandingand Evaluation of…A Unified Understanding and Evaluation of Steering MethodsIn-context Vectors:Making In Context…In-context Vectors: Making In Context Learning More Effective and Controllable Through Latent Space SteeringEarlier referencesFocus paperCiting papersOlderNewer

Click a node to pin it, click the empty canvas to go back to this paper, or hover to preview. Open a node’s page from its title.