DEV Community

Vladyslav Donchenko
Vladyslav Donchenko

Posted on • Originally published at vsebude.it

RAG Retrieves. Fine-Tuning Forgets. HyperNetworks Inject - and Now We Have the Scaling Laws.

There are two mainstream answers to "how do I get my LLM to reliably use proprietary data?" RAG retrieves relevant chunks at inference time. Fine-tuning bakes new knowledge into the weights. Both are widely deployed. Both have well-documented failure modes.

A new paper from Nace AI and Purdue University proposes a third path backed by the first systematic scaling laws: HyperNetwork-based knowledge injection. Instead of modifying the LLM, you train a second network that generates LoRA adapters from a batch of facts. The base model never changes.

Why Fine-Tuning Is a Harder Problem Than It Looks

  • Catastrophic forgetting. Updating weights on new facts degrades existing capabilities.
  • OOD generalization failure. Fine-tuned models struggle with new entity combinations not seen during training.
  • Instability at scale. Knowledge editing methods break unpredictably past ~1,000 injected facts.
  • Hallucination amplification. New facts that contradict pretraining increase hallucination rates.

LoRA reduces cost but shares the same structural problems. You still forget.

The HyperNetwork Alternative

A HyperNetwork is a secondary model conditioned on input facts. It generates LoRA adapters (ΔW) inserted into the target model at inference time. The base model is frozen. Always.

Architecture: Fact batch enters a Transformer encoder (no causal mask, Post-LayerNorm, RoPE) -> Mean pooling -> Linear -> ΔW (LoRA rank 4, α=8) -> adapters into upper half of target model layers. Only the HyperNetwork trains.

The Scaling Laws

The team built MegaWikiQA -- 10M+ multi-hop QA pairs from Wikidata5M (4.6M entities, 822 relations, 39 domains, 1-4 hops, explicit OOD splits).

Hypernetworks from 167M to 2.8B parameters. Four findings:

  1. Power-law scaling everywhere. Loss, accuracy, and OOD generalization follow smooth power laws.
  2. Scaling the target model beats scaling the hypernetwork. Upgrade the LLM, not the injector.
  3. Depth ≈ Width for hypernetwork scaling. Comparable improvements per parameter budget.
  4. Better OOD generalization than LoRA fine-tuning at scale. Steeper OOD scaling -- gap widens at larger target model scale.

What This Means for Enterprise AI

Most enterprise teams face this: proprietary knowledge that can't go into pretraining, too dynamic for static fine-tuning, too specific for general RAG.

The hypernetwork approach: no base model modification, predictable scaling, OOD generalization to new entities and regulations, independently upgradable layers.

The Bigger Picture

RAG retrieves. Fine-tuning forgets. HyperNetworks inject -- learning to generate weight adaptations from facts, not memorizing facts themselves. The scaling laws make this a design principle: steeper OOD scaling exponents, gap widening at scale, smooth power laws you can engineer around.

Paper: https://arxiv.org/abs/2607.19604 | Code and data: https://huggingface.co/collections/nace-ai/hypernetwork-datasets


Originally published at vsebude.it

Top comments (0)