Keeping Humans in the Loop

Updated · 8 min read
mediumPython 3.13aihuman-in-the-loopoversightresponsible-aiconfidencereview

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

LevelDescription
Human-in-the-loopIt is used when a person approves each decision before it takes effect
Human-on-the-loopThe AI acts on its own; a person monitors and can step in or stop it
Human-in-commandPeople decide when and how the AI is used at all, and can switch it off
Review by samplingIt is used to check a random sample of AI decisions regularly
EscalationUncertain, 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".

AI takes the confident cases; people take the uncertain ones
Python
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)
Output
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/50

Explanation:

Auto-answer thresholdAnswered by AIAI accuracySent to a personOverall right
0.35 (no person)3989.7%044/50
0.503196.8%847/50
0.6029100%1048/50
0.7016100%2348/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

FieldWhy a person must stay in charge
HealthcareDiagnoses and treatment affect health and life; AI can support but a clinician decides
FinanceLoans and insurance decisions affect people's lives and are regulated
Hiring and workScreening and promotion decisions are high-risk under many laws; see "Bias and Fairness"
Law and justiceDecisions about rights and freedom need human judgment and explanation
EducationGrades, admissions and discipline shape students' futures
Safety-critical systemsVehicles, factories and power systems need human supervision and safe fallbacks

Designing Good Oversight

PracticeWhy
Show the evidenceReviewers need the source, the confidence and the reason, not just the answer
Keep the review queue smallToo many reviews leads to rubber-stamping
Make overriding easyOne click to correct, with the correction saved
Learn from correctionsAdd reviewed cases to the evaluation set and training data
Give people a way to appealAnyone 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:

  1. Why did raising the threshold from 0.6 to 0.7 not improve the score?
  2. What is automation bias, and how can a design reduce it?
  3. Name two fields where a person must make the final decision.

Quick check: human-in-the-loop

4 questions
1At a threshold of 0.6, how many questions went to a person?
2What was the overall score with no person involved?
3What is automation bias?
4Why is 0.6 a better threshold than 0.7 here?

Key Takeaways

Quick reference

NeedPractice
Route by confidenceAuto above a threshold, person in the middle, decline below
Choose the thresholdCompare AI accuracy and human workload on an evaluation set
Prevent rubber-stampingShow evidence; track agreement rates
Improve over timeSave corrections into the evaluation set
Respect peopleSay who decided; offer an appeal

Was this tutorial helpful?

Lesson 171 of 186