How to use this doc
▶- Read each section’s 30-second answer out loud once.
- Skim In this project — know file names and one demo curl.
- Practice If they push follow-ups.
- Use the cheat sheet at the end the morning of the interview.
Study guide tied to this project (Player Service + Python ML + Ollama). Every concept below maps to code you can point at or live-implement.
Source: AI_TOPICS_INTERVIEW_PREP.md · upstream repo
### 30-second answer
Retrieve → Augment prompt → Generate → Evaluate
| Step | This project |
|---|---|
| Retrieve | PlayerRepository.findByLastName..., findAllById(member_ids) |
| Augment | FACTS: block in TeamChatService summary prompt |
| Generate | ChatClientService.chat(prompt, 0.1f) via Ollama |
| Evaluate | FaithfulnessEvaluator.evaluate(summary, teamNames) |
ROLE: You are a baseball scout.
FACTS: Seed player: Jim Abbott
Team members: Jim Abbott, Pat Combs, ...
TASK: Describe this team in 2-3 sentences. Mention every name.
CONSTRAINT: If a detail is not in FACTS, do not mention it.
Separating facts from instructions reduces the model treating its own knowledge as input data.
| Question | Answer |
|---|---|
| RAG vs fine-tuning? | RAG for fresh/structured DB data that changes; fine-tuning for style/domain when data is static and large |
| What if retrieval is wrong? | Wrong player seeded → wrong team → faithfulness can still be high but answer is wrong; fix retrieval (disambiguate Abbott) |
| Chunking / embeddings? | Not needed here — structured rows, not documents. For PDFs/wiki you'd embed + vector search |
| When is RAG not enough? | Multi-hop reasoning across many docs, or when facts aren't in retrievable form |
### 30-second answer
| Plain chat | Agent |
|---|---|
| Input → LLM → text | Input → plan/route → tool(s) → compose response |
| No side effects | Changes state (feedback exclusions, sessions) |
| Stateless | Often stateful (session, memory) |
| User message | "Tool" invoked | Side effect |
|---|---|---|
| "Build a team like Abbott" | PlayerRepository + ML /team/generate + LLM summarize | New ChatSession |
| "Remove Combs" | ML /team/feedback + /team/generate + LLM summarize | exclude_db updated in Python |
| "Rebuild the team" | ML /team/generate + LLM summarize | Session updated |
| "Why is the sky blue?" | LLM only | None |
Key line: The LLM does not pick the team (ML does). The agent orchestrates specialists.
TeamChatService.handle)TeamFeedbackRequest)ChatSessionStore holds predictionId, roster (so user doesn't resend ids)| Question | Answer |
|---|---|
| LLM-as-router vs rules? | Rules for demo reliability (tinyllama); LLM JSON intent + rules fallback in production |
| How do you prevent runaway agents? | Max retries (1), bounded tools, no arbitrary code execution |
| Agent metrics? | Router accuracy, tool success rate, latency per tool, session completion rate |
| Multi-agent? | Overkill here; one orchestrator + three backends is enough |
### 30-second answer
| Task | Use AI? | Use instead |
|---|---|---|
| Which players are similar? | No | Python k-NN /team/generate |
| Look up player birth year? | No | PlayerRepository |
| Summarize a roster in prose? | Yes | LLM + RAG |
| Parse "remove Combs" intent? | Maybe | Rules now; LLM router later |
| Invent team if ML is down? | Never | 503 + clear error |
Java orchestrates, Python recommends, H2 stores truth, Ollama narrates.
predictionId links inference to feedback; sessionId links chat turns| Question | Answer |
|---|---|
| When wouldn't you use AI? | Compliance-critical paths, pure lookup, math, when explainability must be exact |
| Build vs buy? | Ollama local for dev; managed API for prod if SLA/latency matter |
| Cost control? | Cache player data, minimize tokens in FACTS block, cap retries, small model for routing only |
| How do you stay current? | Prompts versioned like code; eval suite runs on every change |
### 30-second answer
Layer 1 PREVENT → RAG facts block, "ONLY use facts below", temperature 0.1
Layer 2 CONSTRAIN → LLM never outputs player ids; ML+DB supply the list
Layer 3 DETECT → FaithfulnessEvaluator (coverage + suspectedFabrications)
Layer 4 CORRECT → Retry prompt listing missed names (score < 0.8)
Layer 5 CONTAIN → Return team[] from DB even if summary is bad; summary is garnish
Layer 6 HUMAN → Thumbs-down on recommendations; implicit quality signal| Catches | Misses |
|---|---|
| Invented player names ("Babe Ruth" not in FACTS) | Wrong attributes ("retired", "aggressive") |
| Missing names from roster | Paraphrases that omit last names |
| Correct-looking prose with subtle factual errors |
Say this: "Faithfulness here is name coverage — a strict subset of full factual accuracy. I'd extend checks to debut/bats/throws if those were in FACTS."
First summary (loose prompt): invented "aggressive approach", "retired/active".
After structured FACTS + 0.1 temp + retry: less embellishment, measurable via faithfulness.score and suspectedFabrications.
Automated layers (RAG, evaluator, retry) are hypotheses until you regression-test them. A golden set is a fixed list of prompts + expected behavior you re-run after every prompt, temperature, or model change — same idea as unit tests for LLM output.
#### Step 1 — Define what "pass" means (quality bar)
For grounded team summaries, a case passes when all of these hold:
| Check | Pass criteria |
|---|---|
| Coverage | faithfulness.score >= 0.8 (or your chosen threshold) |
| Fabrication | suspectedFabrications is empty |
| Constraint | Summary mentions every name in team[] |
| Containment | team[] itself came from ML+DB, not the LLM (always true in your architecture) |
Optional human spot-check: summary is readable and doesn't invent attributes ("retired", "aggressive") even when name coverage is 1.0.
#### Step 2 — Build the golden set (10–20 cases)
Mix happy path, edge cases, and known failure modes:
| # | Input prompt | What you're testing |
|---|---|---|
| 1 | Build a team like Abbott | Baseline RAG summary |
| 2 | Build a team like Aaron | Common name, many matches |
| 3 | Build a team like McGriff | Single clear seed |
| 4 | Same as #1, run 3× | Consistency at temp 0.1 |
| 5 | Build a team like Abbott with loose prompt (A/B) | Before/after FACTS block |
| 6 | Team of 5 with one hard-to-spell name | Coverage stress test |
| 7 | Generic: Why is the sky blue? | No faithfulness gate (control) |
Store as JSON or a test class — inputs are stable; outputs are scored, not exact-string matched (LLM wording varies).
Example record:
{
"prompt": "Build a team like Abbott",
"expectAction": "TEAM_GENERATE",
"minFaithfulness": 0.8,
"maxFabrications": 0
}
#### Step 3 — Run the suite and record metrics
After each change (prompt edit, temperature, retry threshold, model swap):
POST /v1/chat for each golden prompt (fixed seed player if possible).faithfulness.score, suspectedFabrications, latency, retry fired (yes/no).Log to a spreadsheet or ai_metric lines — you want trends over time, not one-off eyeballing.
#### Step 4 — Inspect failures and tune the right knob
| What you see | Likely cause | Fix |
|---|---|---|
| Low coverage, no fabrications | Prompt doesn't demand all names; or "exactly 2 sentences" too tight | Add "mention every name"; relax to 2–3 sentences |
suspectedFabrications non-empty | Model inventing players | Tighten FACTS constraint; lower temp; add fabrication gate (fail/retry if non-empty) |
| Coverage 1.0 but prose invents attributes | Evaluator too narrow | Extend FACTS with debut/bats; add attribute-level checks or human review |
| Pass rate OK but retries fire 80% of the time | Threshold too strict or prompt weak | Fix prompt first; only then lower RETRY_SCORE_THRESHOLD from 0.8 |
| Pass rate low, summaries look fine | Evaluator too strict (e.g. last-name matching) | Fix metric before loosening bar |
| Pass rate drops after model change | New model ignores instructions | Re-tune temp + prompt; consider rules-first for facts |
Key principle: tune the quality bar from failure analysis, not vibes. The bar is the lowest score where outputs are good enough on the golden set at acceptable latency/cost.
#### Step 5 — Lock it in (regression gate)
#### How this connects to your code today
| Golden set check | Code hook |
|---|---|
| Coverage | FaithfulnessEvaluator.evaluate() → score |
| Fabrications | suspectedFabrications list |
| Auto-correct | RETRY_SCORE_THRESHOLD = 0.8 + retry block in TeamChatService |
| Prevent | FACTS/TASK prompt + chat(prompt, 0.1f) |
Interview line: "Hallucination handling isn't a one-time prompt tweak — I regression-test it. Golden set pass rate is how I know whether Layer 3–4 actually work after a change."
| Question | Answer |
|---|---|
| Can low temperature eliminate hallucination? | No — makes wrong answers consistent. Need RAG + verification |
| LLM-as-judge to detect hallucination? | Possible with bigger model; risk: judge hallucinates too. Prefer deterministic checks when facts are structured |
| Goodhart's law? | Model could list all names with nonsense between — coverage 1.0, useless text; need fluency + human eval too |
| Production gate? | Block response if suspectedFabrications non-empty; or return team without LLM summary |
| How do you tune the 0.8 threshold? | Sweep 0.6–1.0 on golden set; pick lowest value with ≥90% pass rate and acceptable retry rate |
Use this 60-second narrative linking all four topics:
/team/feedback, and regenerates — how I use AI is: language and routing only; recommendations and truth stay in ML and SQL."# 1. RAG + agent generate
curl -X POST http://localhost:8080/v1/chat \
-H "Content-Type: application/json" \
-d '{"prompt":"Build a team like Abbott"}'
# Point at: team[] from ML+DB, summary from LLM, faithfulness.score
# 2. Agent memory + feedback tool
curl -X POST http://localhost:8080/v1/chat \
-H "Content-Type: application/json" \
-d '{"sessionId":"<from above>","prompt":"Remove Combs"}'
# Point at: action=TEAM_FEEDBACK, rejectedMember, roster changed
# 3. Hallucination talking point
# If suspectedFabrications non-empty in response, explain detection + retry| Topic | One line |
|---|---|
| RAG | Retrieve from DB → FACTS prompt → generate → faithfulness eval |
| Agent | Route intent → call tools (ML, DB, LLM) → session memory |
| How I use AI | Language + routing only; ML + SQL own facts and recommendations |
| Hallucination | Prevent → detect → correct → contain; golden set regression-tests pass rate |
| File to cite | Topic |
|---|---|
TeamChatService.java | Agent orchestration, RAG prompt, retry loop |
FaithfulnessEvaluator.java | Hallucination detection |
ChatSessionStore.java | Agent memory |
player-service-model/server.py | ML tool (not LLM) |
ChatClientService.java | Temperature, Ollama call |