Skip to main content

Clarifying Questions

Problem Statement​

Hospital visitors frequently describe symptoms in everyday language rather than naming a specific condition or department. A query like "ik ben altijd moe" (I'm always tired) is perfectly valid, but fatigue is a symptom shared across many medical disciplines: endocrinologie (hormonal), hematologie (blood disorders), gastro-enterologie (digestive), psychiatrie (mental health), and more. The pattern of resolving information-need ambiguity through a follow-up query rather than guessing aligns with the conversational-IR tradition of clarification questions (@manning2008ir) and with the broader RAG move toward interactive grounding (@gao2024ragsurvey).

When a symptom maps to three or more departments, the system faces a dilemma. It can either:

  1. Guess which department is most relevant -- risking a wrong answer that sends the patient to the wrong specialist.
  2. Mention all departments in a broad response -- overwhelming the patient with information and no clear next step.

Neither approach serves the patient well. The clarifying questions system solves this by asking the user to narrow down before generating a response. Instead of guessing, it presents clickable department cards so the patient can self-select the most relevant specialization with a single tap.


Architecture Overview​

The clarifying questions system operates through three layers that work in sequence:

Layer 1: Intent Classification​

The LLM-based intent classifier analyzes the user query and assigns one of several intent labels. When the query describes symptoms without naming a specific condition or department, it returns the label "ambiguous symptom description".

The classifier may also extract a condition (e.g., "vermoeidheid" from "ik ben altijd moe"), though this is not guaranteed -- informal phrasing often results in no extracted entity.

Layer 2: Ambiguity Detection​

Once the intent is classified as ambiguous, the system checks whether the described condition actually maps to multiple departments. This check has two paths:

Primary path -- when the classifier extracts a condition:

  1. Look up the condition in an index of condition → departments (an automatically inverted version of the curated department → conditions list)
  2. If the condition maps to ≥ 3 departments, trigger clarification

Fallback path -- when no condition was extracted (common with informal phrasing):

  1. Take the reformulated query from the classifier
  2. Scan it against all known conditions in the index
  3. Match the first condition with ≥ 3 departments

The fallback scanner checks longer condition names before shorter ones to avoid partial matches -- for example, "borstpijn" (chest pain) is checked before "pijn" (pain).

Layer 3: Clarification Cards​

When ambiguity is confirmed, the backend sends a special "clarification" message containing up to 4 department options, each with:

  • Department name (e.g., "Endocrinologie")
  • Patient-friendly reason (e.g., "Hormonen en stofwisselingsziekten")
  • Icon (emoji representing the specialty)
  • Pre-built query (e.g., "Welke artsen werken bij de afdeling Endocrinologie van ZOL?")

The frontend renders these as clickable cards. When the user clicks one, the pre-built query is sent as a new message, and the normal RAG pipeline processes it with full context.


Pipeline Integration​

The ambiguity check is one of the early-exit checks that run before retrieval, in a strict order:

Order matters. The ambiguity check runs before the cache check. If the cache check ran first, a previously cached text response for the same query would be returned, bypassing the clarification cards entirely. This was an explicit design decision documented in ADR-0046.

For an ambiguous query the flow is: classification, then the early exits in order (error, guardrails, ambiguity, cache), and the ambiguity check short-circuits the pipeline by returning the clarification cards. No retrieval and no answer generation takes place.


Data Sources​

Three static data structures power the clarification system. All are initialized when the taxonomy loads and remain in memory.

Department-to-conditions knowledge​

A curated mapping of department → conditions, covering standard Belgian hospital departments. It includes both formal medical terminology and patient-language Dutch symptom descriptions (e.g., "vermoeidheid", "buikpijn", "duizeligheid", "kortademigheid").

Example entries:

DepartmentConditions (sample)
endocrinologievermoeidheid, diabetes, schildklier, gewichtsverlies, haaruitval
hematologievermoeidheid, bloedziekten, leukemie, trombose
gastro-enterologievermoeidheid, buikpijn, maagklachten, gewichtsverlies
psychiatrievermoeidheid, depressie, angst, slaapproblemen

This is the source of truth for condition-department associations. It is maintained manually and enriched via LLM-assisted extraction, with human review before use.

Condition-to-departments index​

An automatically inverted version of the list above. For each condition, it lists all departments that handle it. A lookup for "vermoeidheid" returns four departments (endocrinologie, gastro-enterologie, hematologie, psychiatrie), which exceeds the threshold of 3.

Patient-friendly department descriptions​

A short patient-friendly description and an icon for each department, used to build the clarification cards. It covers the standard Belgian hospital departments. Departments not found in this mapping receive a generic fallback description ("Meer informatie") and icon.


The Fallback Scanner​

When the LLM classifies the intent as ambiguous but does not extract a condition (common with informal phrasing like "ik ben moe" or "ik heb altijd pijn"), a fallback scanner searches the reformulated query for any known condition name.

Key design decisions:

  1. Longest-first matching. Condition names are checked from longest to shortest. This prevents "pijn" (pain) from matching before "buikpijn" (abdominal pain) or "borstpijn" (chest pain), which would produce overly broad department lists.

  2. First match wins. The scanner returns as soon as it finds a condition meeting the threshold. This is intentional -- ambiguous queries typically center on a single symptom.

  3. Substring matching. The check is a substring match, not an exact match. This allows the reformulated query "vermoeidheid en altijd moe" to match the condition "vermoeidheid".

  4. Configurable threshold. The default threshold of 3 can be overridden, though in practice the default is always used.


Frontend Component​

The frontend renders the department options as an animated card list.

Each card displays:

  • An emoji icon representing the medical specialty
  • A patient-friendly reason in bold (e.g., "Hormonen en stofwisselingsziekten")
  • The department name in smaller text below

The last card is always a phone fallback -- a styled link to the hospital's helpdesk number for patients who prefer human guidance.

When a patient clicks a department card, the pre-built query (e.g., "Welke artsen werken bij de afdeling Endocrinologie van ZOL?") is sent as a new user message. The conversation history is preserved, so the system understands the context. Cards use the hospital's brand colours and have subtle hover and tap animations.


Configuration​

ParameterDefaultDescription
Department threshold3Minimum number of departments before clarification triggers. Queries mapping to 2 departments use the existing "mention both" behavior.
Max cards4Maximum department options shown. If a condition maps to more than 4 departments, only the first 4 are displayed.
Phone numberZOL helpdesk (public number)Shown on the phone fallback card.
Hospital namePer-tenant settingUsed in the pre-built query template: "Welke artsen werken bij de afdeling {dept} van {hospital}?"

Cost and Latency​

The clarification system adds no extra LLM call and negligible latency because:

  • All data comes from static in-memory maps (no database queries)
  • The pipeline short-circuits before retrieval and generation
  • The only LLM call is the intent classification, which runs regardless

ADR Reference​

ADR-0046 (Clarifying Questions for Ambiguous Queries) documents the full design decision, including:

  • Why the threshold was set at 3 (not 2 or 4)
  • Why static mappings were chosen over LLM-generated options
  • The trade-off of requiring one extra click for previously-answered queries
  • The new "clarification" message type in the streaming protocol

  • Query Pipeline -- Full pipeline flow showing where clarification fits
  • Query Enrichment Pipeline -- The enrichment step that runs after clarification is skipped
  • ADR-0046 -- Architecture decision record