Fine-Tuning Without Gradients? Closed-Form, LLM-Written Classifiers on a Frozen Encoder

Md Nasir Uddin, Musa Tur Farazi, Soumik Bhattacharjee, Tishna Sabrina, Chowdhury Mohammad Rakin HaiderarXiv 2026

TL;DR

When adapting a pre-trained language model to a new task, we almost reflexively reach for gradient descent. This paper shows that you don't always have to: by wrapping inputs in clever prompts, reading hidden layers of a completely frozen model, and using classical linear algebra to fit a classifier in closed form, you can beat standard full fine-tuning and LoRA—no gradients required. Better yet, an LLM acts as the "design assistant" that writes the entire extraction and fitting program.

What Problem Does This Paper Address?

Fine-tuning pre-trained encoders (like RoBERTa) via gradient descent is the gold standard for text classification, whether updating all weights (Full Fine-Tuning, or FT), training small adapters (LoRA), or updating weights through fill-in-the-blank prompts (Prompt-based Fine-Tuning, or PFT).

However, gradient training has baggage. It requires hyperparameter sweeps, risks "collapsing" into a useless constant predictor when data is scarce, and lacks bit-for-bit reproducibility. Meanwhile, we know frozen encoders already contain rich representations. Simple "linear probes" (training a basic logistic regression on top of the final frozen layer) usually lag behind fine-tuning, leaving an open question: Is fine-tuning winning because it adapts the internal representations, or just because simple probes are doing a poor job of reading what is already there?

Methods

The authors introduce Closed-Form Weight-Space Programming (WSP). Despite the name—borrowed from recent literature where LLMs generate neural network weights directly—the LLM here writes no weights. Instead, an LLM agent (Claude Code) acts at design time to write a program specifying how to interrogate a frozen RoBERTa-large encoder.

Figure 1: Closed-form weight-space programming. At design time an LLM editor writes the program: the cloze templates a text is wrapped in, the views read from the frozen encoder, the closed-form heads (shrinkage LDA, kernel ridge, the MLM label-word prior) and the rule that selects among them. The plain input and Tv view templates are read as V = (1 + Tv) × 2 × L views (2 poolings at each of L layers); Tp ≥Tv templates give label-word scores at <mask>, so one prediction reads the encoder 1 + Tp times. In our RoBERTa-large instantiation, Tv = 8, Tp = 16, L = 12, V = 216 and H = 113. The classifier’s weights are computed from labelled data, not trained, and no encoder weight changes.

Here is how a WSP classifier works:

  1. Multi-Prompt Views: An input text $x$ is run through the frozen encoder both plain and wrapped in $T_p = 16$ different "cloze" templates (e.g., "$x$ It was <mask>."). From 8 of these templates plus the plain text, hidden states are pooled across the top 12 layers, yielding $V = 216$ distinct representation "views" per input. It also grabs the zero-shot probabilities for task-specific label words (like good/bad) at the <mask> token across all 16 templates.
  2. Closed-Form Heads: Instead of stochastic gradient descent, WSP solves exact classical estimators—shrinkage Linear Discriminant Analysis (LDA) and dual-form Kernel Ridge Regression—combined in various ways with the zero-shot label-word prior. Across hyperparameter grids, this creates a pool of $H = 113$ candidate classifiers.
  3. Cross-Fitted Selection: Using a validation set and 5-fold cross-fitting on the training set, a meta-rule automatically picks either the single best head, the top three, or an ensemble of heads within one standard error of the best ("Occam's window").

Datasets

No new benchmarks were created; the authors evaluated on 17 established English single-text classification datasets (2 to 14 classes):

  • 11 Development Datasets (used iteratively while designing the WSP recipe): SST-2, AG News, Yelp-2, Amazon-2, MR, SUBJ, CR, MPQA, TREC-6, BBC News, and IMDB.
  • 6 Held-out Datasets (tested strictly once the recipe was frozen): SST-5, CoLA, DBpedia-14, Yahoo-10, Yelp-5, and Amazon-5.

Key Insights and Ideas

  • The "Readout Gap" vs. "Representation Gap": Against standard FT and LoRA, almost the entire performance gap of a frozen encoder is merely a readout problem—extracting multiple layers across multiple prompts and combining them smartly erases FT's advantage. However, PFT still wins on unseen tasks, suggesting that backpropagating through a prompt genuinely adapts internal representations in a way frozen readouts cannot mimic.
  • Immunity to Collapse: When data is tiny (e.g., 16 examples per class), gradient-trained models frequently suffer from high variance or catastrophic collapse. Because WSP solves convex/exact equations deterministically, it never collapses.
  • Radical Scientific Transparency: In an unusually candid move, the authors log every time-stamped version of their method, openly separate "development" datasets (where test scores influenced their next ideas) from clean held-out datasets, and document 27 reasonable ideas that completely failed—including closed-form edits to the encoder's feed-forward weights and in-context demonstrations.

Key Results

Average test accuracy across development and held-out datasets.

Average test accuracy across development and held-out datasets.
  • Standard Budgets (512 to 8,192 labels): On the 11 development datasets, WSP beats FT and LoRA at every budget (by +0.34 to +0.56 points on average) and matches PFT within 0.09 points.
  • Low-Label & Few-Shot Regimes: As labels shrink, WSP shines brighter against standard fine-tuning. With 64 and 128 labels, WSP leads FT and LoRA by +1.18 to +3.48 points. In the true few-shot setting (16 labels/class), WSP trounces FT by +5.31 points and LoRA by +3.79 points on development sets (+2.37 and +2.52 on held-out sets).
  • Held-Out Reality Check: On the 6 held-out tasks, WSP stays ahead of LoRA (+1.13 at 512 labels; +0.21 at 8,192) and roughly ties FT, but PFT pulls clearly ahead (beating WSP by 1.30 points at 8,192 labels). WSP particularly struggles on CoLA (grammatical acceptability), trailing all trained baselines.

Limitations and Future Work

  • Heavy Inference & Memory Costs: WSP is not a free lunch. Because it runs the plain text plus 16 prompt templates, inference requires 17 encoder forward passes per prediction instead of one. Adaptation on SST-2 is also 2.3x to 4.8x slower than a tuned FT run, and kernel heads must store training features in memory—consuming 7.2 GB per task at 8,192 labels (compared to ~3 MB for a LoRA adapter).
  • Scope Constraints: The recipe was tailored for RoBERTa-large (transferring it directly to BERT-large lagged FT/LoRA by up to 1.72 points) and only handles single-token label words. Furthermore, the authors did not test LLM-written templates against human-written ones, leaving open how much the LLM editor itself contributed vs. the statistical machinery. Future directions are not explicitly discussed in the paper.

Summary updated

BibTeX
@misc{uddin2026fine,
  author = {Md Nasir Uddin and Musa Tur Farazi and Soumik Bhattacharjee and Tishna Sabrina and Chowdhury Mohammad Rakin Haider},
  title = {{Fine-Tuning Without Gradients? Closed-Form, LLM-Written Classifiers on a Frozen Encoder}},
  year = {2026},
  eprint = {2611.33972},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.33972},
}
Figure