逐日AI

面试题库

共 328 题,当前筛选 2 题。

5 天提示词工程零基础

D1 提示词是什么、不是什么:模型如何读指令;角色 / 任务 / 格式 / 约束四要素

  • 为什么规则要放系统提示而不是用户消息?请从遵从度、管控和成本三个角度说明,并指出系统提示做不到什么。Why do rules belong in the system prompt rather than the user message? Cover adherence, control, and cost, and name what the system prompt cannot guarantee.
    国内高频海外高频进阶#system-prompt#prompt-basics

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

    1. 题眼在「三个角度」和「做不到什么」。只答「系统提示权重高」是背概念,面试官要看的是你有没有在生产里拼过系统提示。
    2. 拆法:遵从度看多轮稀释——用户消息会被后续对话淹没,系统提示全程生效;管控看谁能改——系统提示由后端统一拼装、用户碰不到,规则放这里才能对所有用户一致;成本看缓存——提示缓存按前缀命中,系统提示是最稳定的前缀。
    3. 「做不到什么」是区分度所在:系统提示遵从度高不等于绝对,提示注入可以让模型跑偏,所以安全边界不能只靠系统提示,要在模型外用代码兜底。
    4. 结论:规则进系统提示是为了稳定、一致、省钱;但它是「强建议」不是「硬约束」,硬约束必须在代码层实现。
    5. 追问方向:系统提示可以放在对话末尾吗?可以但不推荐——多数模型对靠前指令更敏感,且会破坏缓存前缀;另一个追问是「哪些内容不该进系统提示」,答案是每次都变的任务细节,放进去会让缓存失效且难以复用。

    How to reason about it · think before answering

    1. The tell is whether you cover all three angles and name a limitation. 'System prompts carry more weight' alone reads as memorized.
    2. Adherence: user turns get diluted as the conversation grows, the system prompt stays in force. Control: the backend assembles the system prompt and users cannot touch it, so rules apply uniformly. Cost: prompt caching matches on prefixes, and the system prompt is the most stable prefix.
    3. The limitation is the differentiator: higher adherence is not a guarantee, prompt injection can still steer the model, so security boundaries need code-level enforcement outside the model.
    4. Conclusion: rules go in the system prompt for stability, consistency and cost, but it is a strong suggestion, not a hard constraint.
    5. Follow-ups: can the system prompt go last? Possible but unwise — models weight early instructions more and it breaks the cache prefix. What should stay out? Per-request task details, which would bust the cache and hurt reuse.

    答题要点

    • 遵从度:用户消息会被多轮对话稀释,系统提示全程生效
    • 管控:系统提示由后端统一拼装,用户碰不到,规则才能对所有人一致
    • 成本:提示缓存按前缀命中,系统提示是最稳定的前缀,不变的内容集中在这里最省钱
    • 做不到的:它不是安全边界,提示注入可以绕过,硬约束必须在代码层兜底

    Key points

    • Adherence: user turns get diluted over a long conversation, the system prompt stays in force
    • Control: the backend assembles it and users cannot edit it, so rules apply to everyone
    • Cost: prompt caching matches prefixes, so stable content in the system prompt maximizes cache hits
    • Limit: it is not a security boundary; prompt injection can bypass it, so enforce hard rules in code

D5 跨模型迁移:Claude / GPT / 国产模型的差异、system prompt 组织;进入 Claude 课与 Codex 课

  • 系统提示应该怎么组织才方便跨模型复用?怎么判断某一句该放哪一块?How should a system prompt be organized so it ports across models, and how do you decide which block a given sentence belongs to?
    国内高频海外高频进阶#system-prompt#model-migration

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

    1. 这题看似问结构,实际在考「有没有维护过多家模型共用的一份提示词」。答「写清楚一点就能通用」的人没维护过;维护过的人会先说分块。
    2. 拆法:三块各回答一个问题。通用规则——这一句换一家模型还成立吗,成立放这里(角色、任务、完成标准、带理由的约束、schema);厂商适配——这一句是不是只对某一家成立,是的放这里(输入包裹方式、示例风格、长度提示、拒答边界表述、结构化输出开关),每家一份整块替换;任务变量——每次调用都在变吗,是的做成参数。
    3. 两条自检是区分度:把厂商块整块删掉,剩下的还是不是一份能读懂的提示词;通用块里搜有没有任何一家的专属词(标签名、API 参数名、风格偏好)。
    4. 结论:分块的收益不只是迁移——通用块是最长最稳定的前缀,放最前面缓存命中最高;厂商块每家固定;任务变量放最后。这跟 D1 讲系统提示要放稳定内容是同一条原则的延伸。
    5. 追问:few-shot 示例算哪一块?示例的内容属于通用规则,示例的书写风格(包裹标签、代码块风格)属于厂商适配,所以示例最好也拆成「内容 + 渲染」两层,或者至少不带厂商专属标签。

    How to reason about it · think before answering

    1. It looks structural but tests whether you have maintained one prompt across vendors. 'Just write it clearly' means no; experienced people start with blocks.
    2. Three blocks, one question each. Common rules — would this sentence still hold on another vendor? Role, task, done-criteria, reasoned constraints, schema. Vendor adaptation — is this true for one vendor only? Input wrapping, example style, length hints, refusal wording, structured-output switch; one per vendor, swapped wholesale. Task variables — does this change per call? Make it a parameter.
    3. Two self-checks are the differentiator: delete the vendor block entirely and see if what remains is still a readable prompt; grep the common block for any vendor-specific token — tag names, API parameter names, style preferences.
    4. Conclusion: the payoff goes beyond migration — the common block is the longest, most stable prefix, so leading with it maximizes prompt-cache hits; vendor block fixed per vendor; variables last. It extends the D1 principle of keeping stable content in the system prompt.
    5. Follow-up: where do few-shot examples go? Their content is common, their rendering (wrapping tags, code-block style) is vendor-specific, so split examples into content plus rendering, or at least keep vendor tags out of them.

    答题要点

    • 三块:通用规则(换模型仍成立)、厂商适配(每家一份整块替换)、任务变量(每次调用的参数)
    • 判据是两个问题:换一家还成立吗;每次调用都在变吗
    • 自检:删掉厂商块剩下的仍可读;通用块里没有任何一家的专属词
    • 顺序通用、厂商、变量,最稳定的前缀在前,缓存命中最高

    Key points

    • Three blocks: common rules that hold across vendors, a per-vendor adaptation block swapped wholesale, and per-call task variables
    • Two deciding questions: does it still hold on another vendor; does it change every call
    • Self-checks: the prompt stays readable with the vendor block removed; no vendor-specific tokens in the common block
    • Order common, vendor, variables so the most stable prefix leads and cache hits are maximized