LLM Contract Pre-Review System: Per-Rule Calls, Confidence and Test-Set Size

Quick Overview

An interview probe of a production LLM contract pre-review system with PM-configured rules, one model call per rule and confidence-based blocking. It tests per-rule versus single-prompt trade-offs, evaluation of rule changes, confidence calibration, test-set drift and size, and when to use deterministic code.

LLM Contract Pre-Review System: Per-Rule Calls, Confidence and Test-Set Size

Company: Amazon

Role: Software Engineer

Category: ML System Design

Difficulty: hard

Interview Round: Technical Screen

In a technical screen for an engineering role that builds AI solutions for business customers, the interviewers ask you to walk through a production LLM system you built and then probe its design and evaluation. Answer as the owner of this system: - Users submit contracts. Before a human reviewer sees a contract, an AI pre-review checks it against 10 to 20 rules that a product manager configures online, for example "do the contract's start and end dates match the actual records?" - The model compares the contract with database records through a read-only tool. - Each rule runs as its own LLM call and returns a result and a confidence. Submission is blocked only when a rule fails with high confidence. The user can override the AI result by entering a reason and submit anyway. - Before a rule change ships, it must pass a test set of 10 contracts: 5 that comply and 5 that do not. After launch, every override is logged and sends a notification, the team is alerted when overrides for a rule cross a threshold, and rules that are overridden often get their prompts revised. - The resume claims the system saves a certain number of person-days of work per month. ### Clarifying Questions - Are the rules the same for every contract, or do they depend on the counterparty? - What happens to a contract after the AI pre-review: does a human still review every contract? - How many contracts go through the system per day? - Which model and platform does the system run on, and can it return token log probabilities? ### Part 1: One LLM call per rule Why run each rule as its own LLM call, so 20 rules mean 20 calls, instead of putting all the rules into one system prompt and calling the model once? ```hint Compare the two on four axes Weigh token cost, latency, how a failure in one rule spreads, and how you would measure one rule's accuracy in each design. ``` #### What This Part Should Cover - The benefits of per-rule calls for isolation, monitoring and change management. - The cost and latency of per-rule calls and ways to reduce them. - When combining or grouping rules is the better choice. ### Part 2: Measuring accuracy and trusting confidence When a product manager changes a rule, how do you know whether accuracy went up or down? Do you have real-time metrics? Where does the confidence come from, and if the model reports 100% confidence, how do you check that it is right? ```hint Score the confidence Treat the model's confidence as a prediction you can check against labeled outcomes, grouped by confidence level. ``` #### What This Part Should Cover - Offline evaluation of a rule change before it ships. - Online metrics, including what overrides reveal and what they miss. - Calibrating the confidence and choosing the blocking threshold. ### Part 3: The test set: drift and size The pipeline depends on the 10 test contracts. Over time, how would you detect that the test set no longer matches real contracts, and when would you update it? Why are 10 contracts enough? A rule that scores 8 or 9 out of 10 might score much lower on 20, 30 or 50 contracts. ```hint Put an interval on it Work out how wide the plausible range of a rule's true accuracy is after it gets 9 of 10 test contracts right. ``` #### What This Part Should Cover - Signals that the test set has drifted from production. - The statistical uncertainty of small test sets and the sample size needed. - How to build and maintain the test set. ### Part 4: LLM or deterministic code In general, how do you decide whether a check should be done by the LLM or written as deterministic code? Apply your criteria to the date-matching rule. ```hint Find the fuzzy step For the date rule, separate the step that needs judgment from the step that has exactly one right answer. ``` #### What This Part Should Cover - Criteria for choosing between an LLM and code. - A design for the date rule that follows from those criteria. - How the choice affects testing and failure modes. ### What a Strong Answer Covers - Trade-offs of the per-rule design stated in cost, latency and debuggability. - Evaluation that separates wrongful blocks from missed violations and uses labels beyond overrides. - Statistical reasoning about test-set size and calibrated confidence. - A principled split between LLM judgment and code, and safe database access for the model. ### Follow-up Questions - How was the person-days saving on the resume measured, and how would you measure it properly? - The model reads the database through a tool. Is that MCP? How do you guarantee the tool can only read? - After a model upgrade, users start overriding one rule far more often. How do you investigate? - Contract volume grows tenfold. How do you cut the cost per contract?

Overview: An interview probe of a production LLM contract pre-review system with PM-configured rules, one model call per rule and confidence-based blocking. It tests per-rule versus single-prompt trade-offs, evaluation of rule changes, confidence calibration, test-set drift and size, and when to use deterministic code.

Read the full Amazon Software Engineer interview experience this question came from

Amazon logo
Amazon
Nov 27, 2026
hardSoftware EngineerTechnical ScreenML System Design
0
0

In a technical screen for an engineering role that builds AI solutions for business customers, the interviewers ask you to walk through a production LLM system you built and then probe its design and evaluation. Answer as the owner of this system:

  • Users submit contracts. Before a human reviewer sees a contract, an AI pre-review checks it against 10 to 20 rules that a product manager configures online, for example "do the contract's start and end dates match the actual records?"
  • The model compares the contract with database records through a read-only tool.
  • Each rule runs as its own LLM call and returns a result and a confidence. Submission is blocked only when a rule fails with high confidence. The user can override the AI result by entering a reason and submit anyway.
  • Before a rule change ships, it must pass a test set of 10 contracts: 5 that comply and 5 that do not. After launch, every override is logged and sends a notification, the team is alerted when overrides for a rule cross a threshold, and rules that are overridden often get their prompts revised.
  • The resume claims the system saves a certain number of person-days of work per month.

Clarifying Questions Guidance

  • Are the rules the same for every contract, or do they depend on the counterparty?
  • What happens to a contract after the AI pre-review: does a human still review every contract?
  • How many contracts go through the system per day?
  • Which model and platform does the system run on, and can it return token log probabilities?

Part 1: One LLM call per rule

Why run each rule as its own LLM call, so 20 rules mean 20 calls, instead of putting all the rules into one system prompt and calling the model once?

What This Part Should Cover Guidance

  • The benefits of per-rule calls for isolation, monitoring and change management.
  • The cost and latency of per-rule calls and ways to reduce them.
  • When combining or grouping rules is the better choice.

Part 2: Measuring accuracy and trusting confidence

When a product manager changes a rule, how do you know whether accuracy went up or down? Do you have real-time metrics? Where does the confidence come from, and if the model reports 100% confidence, how do you check that it is right?

What This Part Should Cover Guidance

  • Offline evaluation of a rule change before it ships.
  • Online metrics, including what overrides reveal and what they miss.
  • Calibrating the confidence and choosing the blocking threshold.

Part 3: The test set: drift and size

The pipeline depends on the 10 test contracts. Over time, how would you detect that the test set no longer matches real contracts, and when would you update it? Why are 10 contracts enough? A rule that scores 8 or 9 out of 10 might score much lower on 20, 30 or 50 contracts.

What This Part Should Cover Guidance

  • Signals that the test set has drifted from production.
  • The statistical uncertainty of small test sets and the sample size needed.
  • How to build and maintain the test set.

Part 4: LLM or deterministic code

In general, how do you decide whether a check should be done by the LLM or written as deterministic code? Apply your criteria to the date-matching rule.

What This Part Should Cover Guidance

  • Criteria for choosing between an LLM and code.
  • A design for the date rule that follows from those criteria.
  • How the choice affects testing and failure modes.

What a Strong Answer Covers Guidance

  • Trade-offs of the per-rule design stated in cost, latency and debuggability.
  • Evaluation that separates wrongful blocks from missed violations and uses labels beyond overrides.
  • Statistical reasoning about test-set size and calibrated confidence.
  • A principled split between LLM judgment and code, and safe database access for the model.

Follow-up Questions Guidance

  • How was the person-days saving on the resume measured, and how would you measure it properly?
  • The model reads the database through a tool. Is that MCP? How do you guarantee the tool can only read?
  • After a model upgrade, users start overriding one rule far more often. How do you investigate?
  • Contract volume grows tenfold. How do you cut the cost per contract?