Keeping Humans in the Loop
Human-in-the-loop means designing an AI system so that people review, approve or correct its outputs at the points where mistakes would matter. The AI handles the easy, confident cases quickly; a person handles the uncertain or high-stakes ones. Done well, it combines the speed of AI with human judgment, and it keeps a person accountable for decisions that affect people's lives.
Levels of Human Involvement
| Level | Description |
|---|---|
| Human-in-the-loop | It is used when a person approves each decision before it takes effect |
| Human-on-the-loop | The AI acts on its own; a person monitors and can step in or stop it |
| Human-in-command | People decide when and how the AI is used at all, and can switch it off |
| Review by sampling | It is used to check a random sample of AI decisions regularly |
| Escalation | Uncertain, unusual or sensitive cases go to a person automatically |
Example: Routing Uncertain Answers to a Person
Campus Helper's similarity score (from "Semantic Search") says how close the best FAQ entry is to the question. This program uses it to route each of the 50 evaluation questions: answer automatically above a threshold, send to a person in the uncertain middle, and decline below 0.35. It assumes the person answers correctly, as the office staff would.
This program needs pip install sentence-transformers, faq.json from "Semantic Search" and eval_set.json from "Building an Evaluation Set".
import json
from sentence_transformers import SentenceTransformer
texts = [item["text"] for item in json.load(open("faq.json"))]
cases = json.load(open("eval_set.json"))
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
vectors = model.encode(texts, normalize_embeddings=True)
results = []
for case in cases:
scores = vectors @ model.encode(case["question"], normalize_embeddings=True)
best = int(scores.argmax())
expected = case["must_contain"]
right_answer = expected is not None and expected in texts[best]
results.append((float(scores[best]), right_answer, expected is None))
def route(auto_above, decline_below):
auto = [r for r in results if r[0] >= auto_above]
human = [r for r in results if decline_below <= r[0] < auto_above]
declined = [r for r in results if r[0] < decline_below]
auto_ok = sum(r[1] for r in auto)
# A person answers the middle band correctly, and the declined ones are counted right if they were off-topic
correct = auto_ok + len(human) + sum(r[2] for r in declined)
print(f"auto >= {auto_above:.2f}: {len(auto):2} answered automatically, {auto_ok:2} right ({auto_ok / max(len(auto), 1):5.1%})"
f" | {len(human):2} to a person | {len(declined):2} declined | overall right {correct}/50")
print("No person involved (answer if score >= 0.35):")
route(0.35, 0.35)
print("\nWith a person reviewing the uncertain middle:")
for auto_above in [0.5, 0.6, 0.7]:
route(auto_above, 0.35)No person involved (answer if score >= 0.35):
auto >= 0.35: 39 answered automatically, 35 right (89.7%) | 0 to a person | 11 declined | overall right 44/50
With a person reviewing the uncertain middle:
auto >= 0.50: 31 answered automatically, 30 right (96.8%) | 8 to a person | 11 declined | overall right 47/50
auto >= 0.60: 29 answered automatically, 29 right (100.0%) | 10 to a person | 11 declined | overall right 48/50
auto >= 0.70: 16 answered automatically, 16 right (100.0%) | 23 to a person | 11 declined | overall right 48/50Explanation:
| Auto-answer threshold | Answered by AI | AI accuracy | Sent to a person | Overall right |
|---|---|---|---|---|
| 0.35 (no person) | 39 | 89.7% | 0 | 44/50 |
| 0.50 | 31 | 96.8% | 8 | 47/50 |
| 0.60 | 29 | 100% | 10 | 48/50 |
| 0.70 | 16 | 100% | 23 | 48/50 |
- Without a person, 4 of the 39 automatic answers are wrong, and the score is the familiar 44/50.
- At 0.6, every automatic answer is right, and only 10 questions (20%) need a person. The overall score rises to 48/50.
- At 0.7, there is no further gain: 23 questions go to people for the same 48/50. The extra human work buys nothing, so 0.6 is the sweet spot here.
- The 2 remaining errors are questions that scored below 0.35 and were declined although the FAQ could answer them. A person reviewing a sample of declines would catch those.
Where Human Oversight Is Essential
| Field | Why a person must stay in charge |
|---|---|
| Healthcare | Diagnoses and treatment affect health and life; AI can support but a clinician decides |
| Finance | Loans and insurance decisions affect people's lives and are regulated |
| Hiring and work | Screening and promotion decisions are high-risk under many laws; see "Bias and Fairness" |
| Law and justice | Decisions about rights and freedom need human judgment and explanation |
| Education | Grades, admissions and discipline shape students' futures |
| Safety-critical systems | Vehicles, factories and power systems need human supervision and safe fallbacks |
Designing Good Oversight
| Practice | Why |
|---|---|
| Show the evidence | Reviewers need the source, the confidence and the reason, not just the answer |
| Keep the review queue small | Too many reviews leads to rubber-stamping |
| Make overriding easy | One click to correct, with the correction saved |
| Learn from corrections | Add reviewed cases to the evaluation set and training data |
| Give people a way to appeal | Anyone affected by a decision should be able to ask a person |
Common Mistakes
A human in name only. If reviewers approve everything in seconds, there is no real oversight.
Reviewing everything. It wastes people's time and leads to fatigue; route by confidence and risk.
No feedback loop. Corrections that aren't saved don't improve the system.
Hiding who decided. People affected should know whether a person or an AI made the decision.
Interview Corner
What is human-in-the-loop, and when is it needed?
A design where people review, approve or correct AI outputs at the points that matter, usually for uncertain cases and high-stakes decisions. It is needed wherever mistakes harm people, such as health, money, jobs, law and safety, and is often required by regulation.
How would you decide which cases go to a human?
Route by confidence and by stakes: send low-confidence and high-impact cases to people, and measure the trade-off between automatic accuracy and human workload on an evaluation set to choose the threshold.
Practice
Exercise: a review sample. Change the program so that, in addition to the middle band, a person also reviews every declined question. How many more reviews does that take, and does the overall score reach 50/50?
Check your understanding:
- Why did raising the threshold from 0.6 to 0.7 not improve the score?
- What is automation bias, and how can a design reduce it?
- Name two fields where a person must make the final decision.
Key Takeaways
Quick reference
| Need | Practice |
|---|---|
| Route by confidence | Auto above a threshold, person in the middle, decline below |
| Choose the threshold | Compare AI accuracy and human workload on an evaluation set |
| Prevent rubber-stamping | Show evidence; track agreement rates |
| Improve over time | Save corrections into the evaluation set |
| Respect people | Say who decided; offer an appeal |
Was this tutorial helpful?