← Clinical AI & Healthcare Evidence, systems and care.

Query understanding: from patient language to clinical search

🌿 Growing
#rag#query-rewriting#ner#hyde#retrieval
TL;DR

A patient says 'my shoulder went numb after the dog pulled the leash'. A clinical corpus is written in terms like 'traction injury with paresthesia'. Three techniques bridge that gap before retrieval even runs: query rewriting, entity extraction, and hypothetical-document embeddings.

Method note: the techniques here are cited to their primary papers. I studied them in the DeepLearning.AI RAG course; nothing proprietary is reproduced. The diagram is my own.

Context

Retrieval quietly assumes the query and the documents speak the same language. In clinical settings they almost never do. A person describes a symptom in plain words, sometimes with a whole backstory, while the guidelines and papers are written in clinical terminology. If you search the corpus with the raw sentence, the best passage may never surface, not because retrieval is weak but because the words do not line up. Query understanding fixes the query before the search runs.

The concept

Three techniques do most of the work, and they compose.

Query rewriting uses a language model to translate the user’s phrasing into the terminology the corpus uses. “It hurts when I bend over” becomes “low back pain in trunk flexion, possible discogenic origin”. Same meaning, words the documents actually contain.

Named entity recognition pulls structured entities out of the text so they can drive metadata filters. From “I’ve had an L4-L5 herniation for three weeks” a model can extract a spinal level, a condition, and a duration, and those become filters that shrink the search to the right slice. Zero-shot NER models find the categories you name, but only the categories you name (Zaratiana et al., 2023). If you never define “spinal level”, it will not look for one.

HyDE, hypothetical document embeddings, flips the matching problem. Instead of embedding the question and hoping it lands near an answer written in a different style, a model first drafts a hypothetical answer, and you embed that. Now you are matching an answer-shaped text against real answers, which are closer in style than a question ever is (Gao et al., 2022). The cost is one extra model call before the search.

TechniqueWhat it doesBest for
Query rewritingLay language into corpus terminologyBridging patient words and clinical text
Entity extraction (NER)Pulls structured fields to filter onNarrowing the search space precisely
HyDEMatches an answer-shaped draft, not the questionComplex questions where rewriting is not enough
"it hurts when I bend over, I have an L4-L5 herniation" rewrite → "low back pain in flexion" NER → level=L4-L5, condition=herniation retrieval over the right slice of the corpus
A patient sentence becomes a clinical query plus metadata filters before search runs. My own diagram.

Where this connects

  • Clinical AI. This is the layer that lets a lay person reach a specialized corpus without knowing its vocabulary. Rewriting carries the meaning across, entity extraction turns loose phrases into safe filters (a level, a duration, a region), and the whole thing keeps a system from missing the right protocol just because the patient did not use the textbook word. It pairs naturally with honest retrieval evaluation, since you can test whether rewriting actually raises recall.
  • Data science and beyond. The pattern generalizes to any search where users and documents speak different dialects: legal, technical support, e-commerce. Normalizing the query, extracting structured filters, and matching answer-shaped text are reusable moves whenever the gap between how people ask and how content is written is the real bottleneck.

Nota de método: las técnicas están citadas a sus artículos primarios. Las estudié en el curso de RAG de DeepLearning.AI; no se reproduce nada propietario. El diagrama es propio.

Contexto

La recuperación asume en silencio que la consulta y los documentos hablan el mismo idioma. En lo clínico casi nunca es así. Una persona describe un síntoma con palabras llanas, a veces con toda una historia, mientras las guías y los papers están escritos en terminología clínica. Si buscas en el corpus con la frase cruda, el mejor pasaje puede no aparecer nunca, no porque la recuperación sea débil sino porque las palabras no coinciden. Entender la consulta arregla la consulta antes de que corra la búsqueda.

El concepto

Tres técnicas hacen casi todo el trabajo, y se combinan.

La reescritura de la consulta usa un modelo de lenguaje para traducir la forma de hablar del usuario a la terminología que usa el corpus. “Me duele cuando me agacho” se vuelve “dolor lumbar en flexión de tronco, posible origen discogénico”. El mismo significado, con las palabras que los documentos de verdad contienen.

El reconocimiento de entidades saca entidades estructuradas del texto para que alimenten filtros de metadata. De “tengo una hernia L4-L5 desde hace tres semanas” un modelo puede extraer un nivel espinal, una condición y una duración, y eso se vuelven filtros que reducen la búsqueda a la porción correcta. Los modelos de NER zero-shot encuentran las categorías que nombras, pero solo las que nombras (Zaratiana et al., 2023). Si nunca defines “nivel espinal”, no lo va a buscar.

HyDE, embeddings de documento hipotético, le da vuelta al problema de emparejar. En vez de embeber la pregunta y esperar que caiga cerca de una respuesta escrita en otro estilo, un modelo primero redacta una respuesta hipotética, y embebes esa. Ahora estás emparejando un texto con forma de respuesta contra respuestas reales, que están más cerca en estilo de lo que una pregunta jamás está (Gao et al., 2022). El costo es una llamada extra al modelo antes de la búsqueda.

TécnicaQué haceMejor para
Reescritura de consultaLenguaje lego a terminología del corpusCruzar las palabras del paciente y el texto clínico
Extracción de entidades (NER)Saca campos estructurados para filtrarReducir el espacio de búsqueda con precisión
HyDEEmpareja un borrador con forma de respuesta, no la preguntaPreguntas complejas donde reescribir no basta
"me duele cuando me agacho, tengo hernia L4-L5" reescribe → "dolor lumbar en flexión" NER → nivel=L4-L5, condición=hernia recuperación sobre la porción correcta del corpus
Una frase de paciente se vuelve una consulta clínica más filtros de metadata antes de buscar. Diagrama propio.

Dónde conecta

  • Clinical AI. Esta es la capa que deja que una persona lega llegue a un corpus especializado sin conocer su vocabulario. La reescritura carga el significado al otro lado, la extracción de entidades convierte frases sueltas en filtros seguros (un nivel, una duración, una región), y todo junto evita que un sistema se pierda el protocolo correcto solo porque el paciente no usó la palabra de libro. Combina de forma natural con una evaluación honesta de la recuperación, porque puedes probar si reescribir de verdad sube el recall.
  • Data science y más allá. El patrón se generaliza a cualquier búsqueda donde usuarios y documentos hablan dialectos distintos: legal, soporte técnico, e-commerce. Normalizar la consulta, extraer filtros estructurados y emparejar texto con forma de respuesta son movimientos reutilizables cada vez que la brecha entre cómo pregunta la gente y cómo está escrito el contenido es el cuello de botella real.

Sources