· Xiaojing Yang · NLP and LLMs · 3 min read

EN

Prompting and Instruction Following

Prompting 既是任务说明,也是接口设计和评估风险。

核心观点

Prompt 不只是输入文本,而是语言模型的临时任务接口。

1. Prompting 做了什么

Prompting 在不改变模型权重的情况下说明任务、上下文、约束、风格和输出格式。Instruction following 取决于预训练、instruction tuning、alignment 和 decoding。

Prompt 路径
Instruction
要做什么
Context
证据或示例
Constraints
格式和规则
Decoding
生成输出
Evaluation
检查有用性和失败

2. Prompt 类型

类型用途
zero-shot直接指令
few-shot在上下文中给例子
chain-of-thought style在合适时引出推理痕迹
structured outputJSON、表格、标签
retrieval-augmented prompt用外部证据 grounded answer

3. Hugging Face 实践

from transformers import pipeline

generator = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct")
out = generator("Explain cross-validation in one paragraph.", max_new_tokens=80)

4. 我的研究连接

Prompting 对 LLM evaluation 很重要,因为很小的措辞变化都可能改变表现。对多语任务来说,英文 prompt 不一定公平迁移到其他语言或领域。

有用习惯

把 prompts 当成实验变量。

评估风险

不要在最终测试集上调 prompt。

总结

Prompting 强大,因为它轻量;也正因为轻量,它很容易悄悄过拟合。

面试回答模板

如果面试问到这个概念,我通常会这样回答:

  1. 用一句话定义;
  2. 解释数据如何流动;
  3. 指出主要失败模式;
  4. 连接到 evaluation、multilinguality 或 fine-tuning。

参考资料

Share:
Back to Blog

Related Posts

View All Posts »
FoundationsNLP and LLMsEN

Attention Mechanism

Attention as a learned way to decide what context matters for each token.

FoundationsNLP and LLMsEN

Fine-Tuning Transformers

How pretrained language models are adapted to a task or domain with supervised data.

FoundationsNLP and LLMsEN

LLM Evaluation and Failure Modes

A practical map of LLM evaluation risks: hallucination, prompt sensitivity, bias, contamination, and brittle benchmarks.

FoundationsNLP and LLMsEN

NLP Evaluation

Why NLP evaluation needs metrics, uncertainty, human judgment, and task-specific error analysis.