SHINE: A Scalable In-Context Hypernetwork for Mapping Context to LoRA in a Single Pass

Yewei Liu, Xiyuan Wang, Yansheng Mao, Yoav Gelberg, Haggai Maron, Muhan Zhang

Introduction

Adapting Large Language Models (LLMs) to specific, domain-heavy contexts typically forces a choice between two imperfect paradigms: In-Context Learning (ICL) and Supervised Fine-Tuning (SFT). ICL, or prompting, is fast to deploy but consumes the model's limited context window and increases inference latency. SFT provides permanent adaptation but is computationally expensive, slow, and requires storing entirely different model weights for different tasks.

Enter SHINE (Scalable Hyper In-context NEtwork), a novel hypernetwork architecture that bridges this gap. SHINE transforms natural language context into high-quality LoRA (Low-Rank Adaptation) adapters in a single forward pass. By effectively "baking" in-context knowledge directly into model parameters, SHINE achieves the performance of fine-tuning with the speed of prompting, all while eliminating the need for massive context windows during inference.

The Challenge with Prior Hypernetworks

Hypernetworks—neural networks designed to generate weights for other networks—offer a theoretical "third way" between ICL and SFT. Ideally, a hypernetwork could process a document and instantly output an adapter that makes the LLM "know" that document.

However, prior hypernetworks for LLMs have struggled with the massive dimensionality of weight spaces. They often rely on restrictive bottlenecks or simple Multi-Layer Perceptrons (MLPs) that fail to capture the complex, global dependencies between different layers of the target network.

The SHINE Architecture

To overcome these limitations, the authors introduce a bottleneck-free, highly scalable architecture that operates in two primary steps:

1. Memory Extraction

The system utilizes the frozen LLM backbone itself, augmented with a "Meta LoRA" module and learnable memory embeddings. It processes the input context and compresses it into a sequence of rich "memory states" distributed across all layers.

2. LoRA Generation via M2P Transformer

These memory states are then fed into a lightweight Memory-to-Parameter (M2P) Transformer. Crucially, this component employs a sparse attention strategy that alternates between "column attention" (mixing information across layers) and "row attention" (mixing information across memory tokens).

This bidirectional flow is a key innovation. Unlike previous "layer-wise" generators that only look forward, SHINE allows information to flow from deep layers back to shallow ones. This mimics the mathematical dependencies found in backpropagation, ensuring the generated weights are globally coherent across the entire parameter space.

Training Pipeline and Datasets

SHINE's training pipeline is rigorous, beginning with a 6-billion-token pretraining phase (using the TransMLA dataset) focused on context reconstruction and completion. This is followed by Instruction Fine-Tuning (IFT) to align the generated adapters with specific question-answering tasks.

For evaluation, the researchers utilized standard benchmarks (SQuAD, HotpotQA, MuSiQue, 2WikiMultihopQA, LongBench) and introduced a new dataset: MS MARCO MQA. This dataset features contexts from MS MARCO paired with LLM-generated, multi-turn question-answer pairs designed to test conversational capabilities.

Key Insights and Results

SHINE demonstrates remarkable efficiency and strong performance, highlighting several key insights:

  • Speed and Efficiency: SHINE generates LoRA adapters in just 0.3 seconds (amortizable time), compared to a sluggish 29.3 seconds for standard SFT.
  • In-Parameter vs. In-Context: By transforming temporary "in-context knowledge" into semi-permanent "in-parameter knowledge," the original context can be discarded after the LoRA is generated. This saves massive amounts of KV cache memory during inference.
  • Strong Performance: On the MS MARCO MQA benchmark, SHINE achieved an F1 score of 55.6, vastly outperforming SFT (33.0) and a Naive baseline (23.2), while closing the gap with the "golden baseline" of full In-Context Learning (69.4).
  • Scalability and Long Context: The architecture demonstrates clear scaling laws, improving as the backbone LLM scales from 0.6B to 8B parameters. Furthermore, a recurrent version, SHINE-R, successfully handles contexts up to 18,000 tokens, significantly reducing VRAM costs compared to standard ICL.
  • The Bitter Lesson: Ablation studies revealed that while human-designed "coupled cross-attention" (forcing the A and B matrices in LoRA to interact more) helped early in training, the general, unconstrained Transformer eventually outperformed it. This reinforces the "Bitter Lesson" of AI research: general methods leveraging computation and data eventually beat hand-crafted priors.

Limitations and Future Directions

While SHINE represents a significant leap forward, the authors note a few areas for future improvement. First, the model experiences multi-turn decay; while it excels at single-turn QA, performance degrades in longer conversations, likely due to a lack of long-context post-training. Second, SHINE currently struggles with complex reasoning tasks like GSM8K math problems. The authors suggest that "meta-training" on Chain-of-Thought (CoT) data is a necessary next step. Finally, while highly efficient, SHINE has not yet perfectly matched the accuracy of full In-Context Learning across all benchmarks, leaving room for further architectural refinement.

Summary updated

BibTeX
@inproceedings{liu2026shine,
  author = {Yewei Liu and Xiyuan Wang and Yansheng Mao and Yoav Gelberg and Haggai Maron and Muhan Zhang},
  title = {{SHINE: A Scalable In-Context Hypernetwork for Mapping Context to LoRA in a Single Pass}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=ZMexYcAibv},
}
Figure