AI Wiki中文/EN

Instruction tuning: learning which task the words ask for

指令微调

Separate task conditioning, template reuse and unseen-task evaluation with two authored bit tasks.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

The input alone does not identify the job

Give a model the two bits 0,1. “Report the first bit” requires zero; “report the second bit” requires one. Both answers can be correct because the instruction changes the task. Training on input–answer pairs while discarding the instruction creates a contradiction that a larger optimizer cannot remove.

Instruction tuning adapts a pretrained model using examples whose requested task is expressed in language. It usually uses supervised learning; the distinguishing feature is how tasks and demonstrations are organized, not a new universal loss function. FLAN converts datasets into instructional templates and evaluates held-out task clusters. T0 likewise unifies tasks through input and target templates while separating training and evaluation task types.

The small experiment below learns the two bit tasks. It succeeds on new wording containing the same known keywords, but that success does not establish understanding of new tasks or unfamiliar synonyms.

Known keywords make new templates easy; task and synonym holdouts reveal a different boundary.
Known keywords make new templates easy; task and synonym holdouts reveal a different boundary.

Condition on the instruction, then choose what to hold out

Let ii be an instruction, xx the task input and yy the desired response. A generative model represents:

pθ(y∣i,x)=∏j=1∣y∣pθ(yj∣i,x,y<j).p_\theta(y\mid i,x)=\prod_{j=1}^{|y|}p_\theta(y_j\mid i,x,y_{<j}).

The instruction is part of the conditioning context. It can specify an operation, output format or label convention. Training can update the whole model or a parameter-efficient subset; neither choice changes the need to preserve the task information.

For tasks t=1,…,Kt=1,\ldots,K, let DtD_t be their demonstration distributions and πt\pi_t their sampling probabilities. One training objective is:

L(θ)=∑t=1Kπt E(i,x,y)∼Dt[−log⁡pθ(y∣i,x)],∑tπt=1.\mathcal L(\theta)=\sum_{t=1}^{K}\pi_t\,\mathbb E_{(i,x,y)\sim D_t}[-\log p_\theta(y\mid i,x)],\qquad \sum_t\pi_t=1.

A mixture defines what the optimizer sees frequently. It is not automatically the same as a deployment distribution or a macro-averaged evaluation score. Also specify whether each response loss sums or averages its token losses; long answers otherwise change the effective weighting.

FLAN v1, section 2.4, limits available training examples per dataset and caps the example-proportional sampling contribution at 3,000. Its stated mixing rule has the form:

πt=min⁡(nt,c)∑smin⁡(ns,c),c=3000.\pi_t=\frac{\min(n_t,c)}{\sum_s\min(n_s,c)},\qquad c=3000.

For two datasets with 100 and 10,000 eligible examples, this gives weights 1/311/31 and 30/3130/31, rather than 1/1011/101 and 100/101100/101. This describes a published recipe, not a recommended constant for every collection. FLAN’s separate 30,000-example dataset cap and the 3,000 mixing cap play different roles.

Evaluation needs an equally explicit unit. Holding out records tests new examples; holding out wording tests new templates; holding out task families asks a broader transfer question. FLAN groups its 62 datasets into 12 clusters and excludes the relevant cluster when evaluating an unseen task. T0’s task taxonomy is also an organizing choice, not proof that two groups share no skills. Pretraining contamination remains a separate question.

Our transparent classifier uses a deliberately limited feature map:

ϕ(i,x)=(1,1first∈i,1second∈i)⊗(1,x1,x2).\phi(i,x)=(1,\mathbf1_{\text{first}\in i},\mathbf1_{\text{second}\in i})\otimes(1,x_1,x_2).

Here ⊗\otimes lists all products of entries. Exact lowercased whitespace words activate the indicators; no learned language encoder recognizes synonyms. The interaction terms allow the same bits to be treated differently for the two instructions. A binary logistic head then uses:

pw(y=1∣i,x)=σ(w⊤ϕ(i,x)),σ(z)=11+e−z.p_w(y=1\mid i,x)=\sigma(w^\top\phi(i,x)),\qquad \sigma(z)=\frac1{1+e^{-z}}.

For NN training records, the mean cross-entropy gradient is:

∇wL=1N∑n=1N(pn−yn)ϕ(in,xn).\nabla_w\mathcal L=\frac1N\sum_{n=1}^{N}(p_n-y_n)\phi(i_n,x_n).

All four bit pairs appear under both task instructions. Without the instruction, the two off-diagonal pairs have contradictory labels. Any deterministic input-only rule must make at least two errors among eight records, so its best accuracy is 0.75.

For evaluation over a declared set of task families H\mathcal H, one possible macro score is:

MacroAcc⁡=1∣H∣∑t∈H1Nt∑n=1Nt1{y^tn=ytn}.\operatorname{MacroAcc}=\frac1{|\mathcal H|}\sum_{t\in\mathcal H}\frac1{N_t}\sum_{n=1}^{N_t}\mathbf1\{\hat y_{tn}=y_{tn}\}.

This gives each task equal weight, regardless of its dataset size. It does not remove ambiguity about which tasks were actually unseen.

Learn a rule and expose the shortcut

This complete NumPy program trains nine coefficients by gradient descent on eight authored examples. The control omits instruction features and trains three coefficients. There is no pretrained language model in this experiment.

"""Authored bit tasks; lexical features are explicit, not a pretrained LM."""
import itertools,json
import numpy as np

BITS=list(itertools.product([0.,1.],repeat=2))
def features(text,bits,conditioned=True):
    x=np.asarray(bits,float)
    if x.shape!=(2,) or not np.isfinite(x).all():raise ValueError('Two finite input features required')
    words=text.lower().split()
    task=np.array([1.,float('first' in words),float('second' in words)]) if conditioned else np.ones(1)
    return np.kron(task,np.r_[1.,x])
def dataset(templates=('report first bit','report second bit'),conditioned=True):
    if len(templates)!=2:raise ValueError('Two ordered task templates required')
    rows=[(features(t,x,conditioned),x[k]) for k,t in enumerate(templates) for x in BITS]
    return np.array([x for x,y in rows]),np.array([y for x,y in rows])
def objective(w,x,y):
    z=x@w;p=np.exp(-np.logaddexp(0,-z))
    return float(np.mean(np.logaddexp(0,z)-y*z)),x.T@(p-y)/len(y)
def fit(conditioned=True,steps=1200):
    if not isinstance(steps,int) or isinstance(steps,bool) or not 0<=steps<=10000:raise ValueError('Bounded integer steps required')
    x,y=dataset(conditioned=conditioned);w=np.zeros(x.shape[1]);history=[]
    for i in range(steps+1):
        loss,g=objective(w,x,y)
        if i%200==0 or i==steps:history.append(dict(step=i,loss=loss))
        if i<steps:w-=.5*g
    return w,history
def accuracy(w,x,y):return float(np.mean((x@w>=0)==y))
def demo():
    w,history=fit();plain,_=fit(False)
    x,y=dataset();new_x,new_y=dataset(('please return first bit','please return second bit'))
    unknown=np.array([features('report xor',x) for x in BITS]);xor=np.array([int(a!=b) for a,b in BITS])
    synonym,sy=dataset(('report left bit','report right bit'))
    a,b=dataset(conditioned=False)
    return dict(train_accuracy=accuracy(w,x,y),new_template_accuracy=accuracy(w,new_x,new_y),unseen_task_accuracy=accuracy(w,unknown,xor),unknown_word_accuracy=accuracy(w,synonym,sy),no_instruction_accuracy=accuracy(plain,a,b),weights=w.tolist(),trace=history,training_rows=len(y),scope='All bit inputs enumerated; new templates retain known keywords, not unseen-task or natural-language mastery')
if __name__=='__main__':print(json.dumps(demo(),allow_nan=False))

After 1,200 updates, the conditioned classifier reaches accuracy 1 and mean training loss approximately 0.0103254. Its new templates, “please return first bit” and “please return second bit,” also score 1 because the extracted features are exactly unchanged. The input-only control reaches its 0.75 ceiling.

Replacing the task words with unseen “left” and “right” yields 0.75. Asking for XOR, a task not trained here, also yields 0.75 on four inputs. These are distinct tests: an unfamiliar synonym and a new operation. Neither is rescued merely by a low training loss. Four evaluation cases do not establish a population-level quality claim.

Tests enumerate all input-only predictions to verify the ceiling, compare the template feature matrices exactly, and check every coefficient’s analytic gradient against central finite differences. One full-batch update takes O(Nd)O(Nd) work for dd features; the design matrix uses O(Nd)O(Nd) storage. This feature construction scales poorly if every task needs an explicit indicator.

A formatted dataset can still teach the wrong behavior

Instruction tuning inherits the demonstrations’ errors, omissions and output conventions. Multiple valid answers can be reduced to one reference even when alternatives are reasonable. A model can learn a template marker or dataset artifact instead of the requested skill; our lexical feature equality makes such a shortcut visible rather than hiding it.

Separate near-duplicate examples before splitting, and inspect overlap at the task-family and source-document level. Selecting the best prompt on the test set leaks evaluation information. Reusing a familiar task with different wording should not be reported as unseen-task transfer.

Instruction tuning does not by itself provide preference learning, reliable truthfulness or a guarantee of following every instruction. See supervised fine-tuning for the token-level training mechanics. Soft prompt tuning, despite the similar name, changes a small trainable input representation and is a different adaptation choice.

Name the unit of generalization

  1. Why can 0,1 legitimately have two different target answers? Answer: The instruction selects the first or second coordinate. Removing it merges two different conditional tasks into an inconsistent input-only mapping.
  2. Under a 3,000 sampling cap, what are the weights for task sizes 100 and 10,000? Answer: Normalize 100 and 3,000, obtaining 1/311/31 and 30/3130/31. The cap changes sampling frequency, not the labels.
  3. Why does perfect accuracy on the new templates fail to establish broad language understanding? Answer: Their known task keywords produce identical features. The test changes surrounding words without asking the classifier to infer new keyword meanings or operations.
  4. A benchmark claims unseen-task transfer but holds out only random rows from every task. What is missing? Answer: A declared task-level or task-family split. Random-row holdout measures new examples of trained tasks; it cannot support the broader claim by itself.

Templates are part of the experimental design

FLAN’s cluster holdout and T0’s unified templates offer two concrete ways to organize instruction data and evaluation. Their conclusions depend on their model, training mixture and definition of unseen tasks. This chapter uses their methodological distinctions; it does not reproduce their model scores.

A useful next experiment varies task coverage and template coverage separately, retaining a fixed untouched evaluation set. Report both what was held out and what could still have been encountered during pretraining. “Zero-shot” is an evaluation condition that needs a specified boundary.

Make a prediction, then check

Does success on a new wording that retains a known task keyword establish unseen-task generalization?

Choose one answer

Learning objectives

  • Explain how instructions disambiguate input-output mappings.
  • Distinguish held-out examples, templates and task families.
  • Audit mixing weights and claims about zero-shot transfer.

Prerequisites & connections

Explore related knowledge →

References

  1. Finetuned Language Models Are Zero-Shot Learners — v1
    Jason Wei; Maarten Bosma; Vincent Y. Zhao; Kelvin Guu; Adams Wei Yu; Brian Lester; Nan Du; Andrew M. Dai; Quoc V. Le · 2021
  2. Multitask Prompted Training Enables Zero-Shot Task Generalization — v1
    Victor Sanh; Albert Webson; Colin Raffel; Stephen H. Bach and coauthors · 2021

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-20 · Single AI author read FLAN v1 PDF3/4 and section2 opening; T0 v1 PDF4/5 task taxonomy/templates. Seven paired equations and four explained exercises. Original lexical bit-task classifier, exact input-only ceiling, template feature equality, unknown words/XOR, all coefficient finite differences. Explicit hand-designed features, not a pretrained model or universal unseen-task result.

  • Single AI author read FLAN v1 PDF3/4 and section2 opening; T0 v1 PDF4/5 task taxonomy/templates. Seven paired equations and four explained exercises. Original lexical bit-task classifier, exact input-only ceiling, template feature equality, unknown words/XOR, all coefficient finite differences. Explicit hand-designed features, not a pretrained model or universal unseen-task result.
  • Four computed SVG variants per topic;11 numeric/geometry tests and36 responsive cases passed. Twelve selected captures checked:seven final directly viewed,five byte-identical to previously viewed images. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.