逐日AI

面试题库

共 328 题,当前筛选 2 题。

标签
还有 126 个标签
#agent-loop2#api-design2#chunking2#cost-tradeoff2#debugging2#distributed-systems2#error-handling2#hybrid-search2#llm-as-judge2#multi-agent2#multi-hop2#oauth2#operations2#pipeline-design2#prompt-caching2#recall2#retrospective2#retry2#scheduling2#sse2#tool-permissions2#trade-offs2#access-control1#agentic-rag1#agents-sdk1#analytics1#architecture-review1#behavioral1#budget-control1#caching1#cancellation1#checkpointing1#circuit-breaker1#citation-verification1#client1#client-integration1#coding-agent1#compaction1#compliance1#concurrency1#confused-deputy1#context-engineering1#contextual-retrieval1#copyright1#correctness1#cost-control1#customer-support1#data-quality1#database1#deployment1#distribution1#embedding-migration1#error-propagation1#escalation1#evidence1#faithfulness1#fallback1#feedback-loop1#fencing-token1#filter-pushdown1#filtering1#framework-design1#graph-rag1#guardrails1#handoff1#image-generation1#integration1#iterative-scan1#json-parsing1#labeling1#latency1#latency-budget1#least-privilege1#long-context1#long-session1#long-term-memory1#mcp1#message-bus1#methodology1#model-migration1#multi-tenancy1#notifications1#ocr1#offline-testing1#project-storytelling1#protocol-versions1#quality1#query-rewriting1#rate-limiting1#reconnect1#refusal1#replay1#reproducibility1#rerank1#resume1#retrieval1#risk-assessment1#rollout1#routing1#runtime1#safety1#scaling1#self-introduction1#split-brain1#state-management1#state-persistence1#statelessness1#stdio-transport1#storytelling1#subagent1#subagents1#subscriptions1#test-strategy1#thresholds1#timezone1#token-accounting1#tool-design1#tool-schema1#tools1#trust-boundary1#ux1#verification1#versioning1#workflow-design1#workflow-engine1#zero-downtime1

30 天从前端工程师到 Agent 工程师

D6 消息、上下文工程与压缩、会话存储/恢复/分叉(dg M06/M08/M09/M10)

  • 上下文工程和 RAG 检索是什么关系?只做 RAG 不做上下文管理会出什么问题?How do context engineering and RAG relate, and what breaks if you do RAG without context management?
    国内高频海外高频深入#context-engineering#rag#retrieval

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

    1. 题眼在「关系」。把两者说成并列的两种技术是最常见的失分答法——正确的框架是包含关系:上下文工程是「决定这次请求里放什么」,RAG 是它的一种供给手段,负责「从外部捞该放进去的东西」。
    2. 拆开看职责就清楚了:RAG 解决的是「信息不在模型参数里、也不在当前对话里」,靠检索把它取回来;上下文工程解决的是「取回来的东西、加上历史、加上工具定义,一共放不放得下、该按什么优先级放」。前者管来源,后者管预算。
    3. 所以只做 RAG 不做上下文管理会出三类问题,最好按这个顺序说。第一是挤占:检索回来的文档动辄几千 token,直接拼进去把对话历史挤没了,模型记得住资料却忘了用户三句话前说过什么。第二是干扰:召回条数调大看着安全,实际上不相关的片段会稀释模型注意力,准确率不升反降。第三是成本:检索结果每一轮都重发,一段两千 token 的资料聊十轮就付了十次。
    4. 给出正确的组合姿势:先给历史和检索结果各划一条预算线,检索结果只保留 top-k 且不跨轮重复注入,历史超线就压缩,两条线加起来必须留出输出空间。这套「分账」的说法比笼统的「要平衡」有说服力得多。
    5. 可以预期的追问:检索结果该放在系统提示词里还是当成一条 user 消息?答放在靠近当前问题的位置通常效果更好,而且要标注来源便于模型区分「资料」和「用户说的话」;顺带说清它是一次性上下文,不该被写进长期会话历史里反复重发。

    How to reason about it · think before answering

    1. The hinge word is 'relate'. Treating them as two parallel techniques is the standard weak answer — the right frame is containment: context engineering decides what goes into this request, and RAG is one supply mechanism that fetches what should go in.
    2. Separate the responsibilities and it becomes obvious: RAG solves 'the information is neither in the weights nor in this conversation' by retrieving it; context engineering solves 'the retrieved chunks plus the history plus the tool definitions all have to fit, in some priority order'. One owns sourcing, the other owns budget.
    3. So RAG without context management breaks in three ways, best delivered in this order. Crowding: retrieved documents run to thousands of tokens and squeeze out the conversation, so the model knows the manual but forgot what the user said three turns ago. Interference: raising top-k feels safe but irrelevant chunks dilute attention and accuracy drops instead of rising. Cost: retrieved text is resent every turn, so a 2k-token passage costs ten times over ten turns.
    4. Give the correct combination: budget history and retrieval separately, keep retrieval to top-k without re-injecting the same chunks every turn, compress history when it crosses its line, and make sure both lines together still leave room for output. This 'separate budgets' framing lands much better than a vague 'you need to balance them'.
    5. Expect the follow-up on placement: putting retrieved context near the current question usually works better, and it should be labeled with its source so the model can tell reference material from what the user actually said. Note too that it is single-turn context and should not be written into the persisted history and resent forever.

    答题要点

    • 不是并列关系而是包含关系:上下文工程决定这次请求放什么,RAG 是给它供货的一种手段,负责把不在模型和对话里的信息检索回来
    • 只做 RAG 会挤占历史:几千 token 的检索结果把对话挤没,模型记得住资料却忘了用户刚说的话
    • 召回条数越大越准是错觉:不相关片段会稀释注意力,准确率反而下降,应控制 top-k
    • 检索结果每轮重发会持续计费,属于一次性上下文,不该写进持久化历史反复重发
    • 正确姿势是给历史和检索各划一条预算线,历史超线就压缩,两条线之外还要留出输出空间

    Key points

    • They are not parallel: context engineering decides what enters the request, and RAG is one supply mechanism for information that is neither in the weights nor in the conversation
    • RAG alone crowds out history — multi-thousand-token retrievals evict the conversation, so the model knows the docs but forgot the user's last request
    • A bigger top-k is not safer: irrelevant chunks dilute attention and accuracy drops, so cap retrieval
    • Retrieved text is single-turn context; persisting it into the history means paying for it on every subsequent turn
    • Budget history and retrieval on separate lines, compress history when it crosses its line, and leave room for the output on top of both

D24 RAG 进阶:hybrid search、rerank、引用、recall 评估

  • 怎么评估一个 RAG 系统的检索效果?评估集应该怎么构造?How do you evaluate retrieval quality in a RAG system, and how should the evaluation set be built?
    国内高频海外高频深入#rag#evaluation#recall

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

    1. 这题是国内面试的极高频题,也是最容易暴露「只搭过没调过」的一题。判据很简单:你的回答里有没有出现**具体的指标名和标注粒度**,没有就是没做过。
    2. 先把评估对象分清楚——这是最容易混的一步:**检索评估问「找得到找不到」,生成评估问「答得对不对」**。两套评估集要分开维护。混成一套的后果是分数掉了你分不清是检索漏了还是模型答砸了,而这两件事的修法完全不同。
    3. 评估集的形状:20 条左右的 query,每条**人工标注 1 到 3 个必须召回的 chunkId**。注意标注粒度是**块**不是文档——检索的单位就是块,标到文档级会让指标虚高。query 要覆盖真实分布,尤其要包含那些你知道会翻车的类型(编号、同义改写、跨文档)。
    4. 三个指标各回答一个问题:recall@5 是「进上下文的那几条覆盖了多少」,也就是你真正关心的数;recall@20 是天花板,它上不去说明问题在召回侧、重排再强也没用;MRR 对排序质量敏感,recall 打平时用它分高下。
    5. 生产视角:评估集一旦定下来就要冻结,换了样本分数就没有可比性——这和产线质检必须用固定的标准样品是同一个道理。同时线上要有对照指标(引用为空率、幻觉引用率、转人工率),因为离线过了不等于线上没事。
    6. 可预期的追问:标注成本这么高,20 条够吗?答:20 条不够做统计显著性,但足够做**回归**——它的作用是「改了检索之后别悄悄变差」。要做 A/B 定论再上规模,而且优先扩充失败案例,不是随机加样本。

    How to reason about it · think before answering

    1. This is a very common question in the Chinese market and the fastest way to expose someone who has assembled RAG but never tuned it. The test: does your answer contain concrete metric names and an annotation granularity?
    2. First separate what is being evaluated — the step people most often conflate. Retrieval evaluation asks 'was it found'; generation evaluation asks 'was the answer right'. Keep two separate sets. Merge them and, when the score drops, you cannot tell whether retrieval missed or the model fumbled — and those have completely different fixes.
    3. Shape of the set: about 20 queries, each annotated with 1-3 chunk ids that must be retrieved. Annotate at chunk level, not document level — chunks are the retrieval unit, and document-level labels inflate the numbers. Cover the real query mix, especially the types you know break: codes, paraphrase, cross-document.
    4. Three metrics, three questions. recall@5 is what actually reaches the model, so it is the number you care about. recall@20 is the ceiling — if it does not move, the problem is on the recall side and no reranker will save you. MRR is sensitive to ordering and breaks ties when recall is equal.
    5. Production view: freeze the set once agreed, because changing samples destroys comparability — the same reason a factory keeps fixed reference samples. Pair it with online counterparts (empty-citation rate, hallucinated-citation rate, escalation rate), since passing offline does not mean passing in production.
    6. Expected follow-up: is 20 enough given the labelling cost? Not for statistical significance, but enough for regression — its job is to stop retrieval silently getting worse. Scale up before you settle an A/B, and grow it from failure cases rather than random additions.

    答题要点

    • 检索评估和生成评估是两套:前者问「找得到找不到」,后者问「答得对不对」,分开维护。
    • 评估集是 20 条左右的 query,每条人工标 1 到 3 个必须召回的 chunkId——标到块级,不是文档级。
    • recall@5 是真正关心的数(模型只看得到这几条),recall@20 是天花板,MRR 衡量排序质量。
    • 评估集一旦定下来就冻结,否则分数没有可比性;线上再配引用为空率、幻觉引用率做对照。
    • 20 条不够做显著性但够做回归;扩充时优先补失败案例,不是随机加样本。

    Key points

    • Retrieval and generation evaluation are two separate sets: 'was it found' versus 'was the answer right'.
    • Around 20 queries, each labelled with 1-3 chunk ids that must be retrieved — chunk level, not document level.
    • recall@5 is what the model actually sees, recall@20 is the ceiling, MRR measures ordering quality.
    • Freeze the set once agreed or scores stop being comparable; pair it with online empty-citation and hallucinated-citation rates.
    • Twenty cases is a regression guard, not a significance test; grow it from failure cases, not random samples.