CCA-F 练习题库· Prompt Engineering & Structured Output
An invoice extraction pipeline uses tool use with a strict JSON schema. After validation, 8% of extracted invoices fail a business rule check: the sum of line item amounts does not equal the total_amount field. These are semantic errors, not schema syntax errors. The invoices are well-formed documents with no missing data. How should you implement the retry loop?
- ARetry up to 3 times with the same prompt; schema-compliant extraction will converge on a valid answer with additional attempts.
- B在 schema 里加一个 calculated_total 字段,在后处理阶段用抽取到的 line item 金额求和填入,然后把它当作权威总额并丢弃抽取出的 total_amount,这样业务规则校验永远能通过。
- CFlag all invoices with this error as missing data and route them directly to human review without retry.
- DOn failure, append the original document, the failed extraction, and the specific validation error ("line items sum to X but total_amount is Y") to the follow-up prompt for model self-correction.
正确答案:D
解析
- Dis correct. The failures are semantic (a sum-vs-total mismatch), not schema-syntax errors, and the documents are complete, so the fix is a feedback-driven retry: append the original document, the failed extraction, and the specific validation error ("line items sum to X but total_amount is Y") so the model can re-examine the source and self-correct the arithmetic.
- Afails because retrying the identical prompt gives the model no new information and tends to reproduce the same error (schema-compliance was never the failing constraint).
- Cmislabels present data as "missing" and escalates to humans before attempting a cheap automated fix.
- Bsilently overwrites total_amount with the line-item sum, which wrongly assumes the line items are always the correct side of the discrepancy and would propagate mis-extracted line items into the canonical total while masking the real defect.
延伸阅读
本题为本站自有原创练习题,非任何官方考试内容;解析对照 Anthropic 公开文档撰写, 如与最新文档不符请以官方为准。想在限时环境下检验水平,可参加 模拟考(题目与本页题库不重叠)。