逐日AI

面试题库

共 328 题,当前筛选 1 题。

5 天提示词工程零基础

D2 few-shot、思维链、分步与自检;什么时候这些都不管用

  • few-shot 为什么有效?示例给多了会出什么问题?你怎么决定给几个?Why does few-shot prompting work, what goes wrong when you give too many examples, and how do you decide how many to include?
    国内高频海外高频基础#few-shot#prompt-techniques

    分析过程 · 先想清楚再作答

    1. 这题在筛「有没有把示例当成格式与边界的信号,而不是当成让模型变聪明的魔法」。答成「示例越多模型越懂」会暴露没在生产里调过提示词。
    2. 拆法:先答原理——模型在补全,示例直接展示了「下文该长什么样」,比文字描述格式和边界规则更不容易被误读;示例是最强的格式信号。
    3. 再答代价:每个示例都占上下文与费用;示例过多会让模型过拟合示例的表面特征(长度、措辞、顺序),还会把示例里无意带进去的偏见放大,比如四个示例里三个是 bug,它就更倾向判 bug。
    4. 结论:数量由「要覆盖几种类型」决定而不是越多越好,通常两到五个,每个覆盖一种不同的情况,并且至少一个是边界样本。
    5. 可预期的追问:示例的顺序有影响吗?有,多数模型对最后一个示例更敏感,所以把最像目标输入的放最后;另一个追问是示例和说明冲突时模型听谁的,答案是多半听示例,所以示例必须与格式栏逐字一致。

    How to reason about it · think before answering

    1. The screen is whether you treat examples as signals for format and boundaries rather than as magic that makes the model smarter. 'More examples, better model' reads as untested.
    2. Mechanism first: the model completes text, and examples show the continuation directly, which is harder to misread than prose describing a format or an edge rule. Examples are the strongest format signal.
    3. Then the cost: each example consumes context and money; too many cause overfitting to surface features such as length, wording and order, and amplify accidental bias — three bug examples out of four nudges everything toward bug.
    4. Conclusion: the count follows the number of distinct cases you need to cover, typically two to five, each a different case, with at least one boundary sample.
    5. Follow-ups: does order matter? Yes, models weight the last example more, so place the one closest to the target input last. And if examples contradict the instructions, the model usually follows the examples, so they must match the format spec exactly.

    答题要点

    • 示例直接展示下文该长什么样,比文字描述格式和边界规则更不容易被误读
    • 示例过多的代价:占上下文与费用、过拟合表面特征、放大示例里的类别偏见
    • 数量按「要覆盖几种不同情况」定,通常两到五个,至少一个边界样本
    • 顺序有影响,最像目标输入的放最后;示例与说明冲突时模型多半听示例

    Key points

    • Examples show the continuation directly, which beats prose for conveying format and edge rules
    • Too many examples cost context and money, overfit surface features, and amplify class bias
    • Pick the count by how many distinct cases need coverage, typically two to five with one boundary case
    • Order matters — put the closest match last; when examples and instructions conflict the model follows the examples