In modern healthcare, it is common to have unstructured data in Electronic Health Records (EHRs). It often consists of free text characterized by abbreviations, acronyms, jargon, and inconsistent syntax. This lack of structure makes such data inaccessible for automated research. Due to the strict privacy regulations and hardware constraints of clinical environments, this thesis evaluates the performance of locally deployable open-source Large Language Models (LLMs) in correcting and extracting structured information from noisy, non-English medical text. A modular, automated pipeline was developed to test seven model families (Gemma3, Llama3, MedGemma, Mistral, GPT-OSS, Qwen3, and DeepSeek) ranging from 4 to 70 billion parameters, executed locally via the Ollama framework. The models were evaluated on two main tasks: a correction task to fix typos and expand Italian obstetric acronyms, and an extraction task to retrieve 28 specific clinical fields, such as Apgar scores and blood gas values. Performance was measured against an expert-validated gold standard of 100 notes, analyzing various prompt engineering strategies (e.g., few-shot, positive instructions, domain-specific acronym lists, and prompt repetition) and using both string-based metrics and semantic embedding similarities. The results demonstrated that local LLMs can successfully clean and extract clinical data, though capabilities strongly depend on architecture and prompt design. For note correction, directly injecting domain knowledge into the prompt—such as a list of common acronyms—significantly outperformed other techniques like few-shot prompting or simply scaling up the model size. For structured data extraction, some smaller models (notably Qwen3 Small) surprisingly matched or even outperformed their larger counterparts, proving that instruction-following capabilities often matter more than raw parameter counts. Among the tested architectures, Mistral and Gemma3 models provided the most favorable trade-off between high semantic accuracy and low inference latency, making them highly suitable for real-world deployment. Ultimately, this research establishes a concrete methodological foundation showing that small LLMs can successfully unlock the value of unstructured historical clinical data without the need for privacy-compromising cloud APIs or computationally expensive fine-tuning.
Nella sanità moderna, la presenza di dati non strutturati all'interno delle cartelle cliniche elettroniche (EHR) è un fenomeno comune. Questi dati spesso consistono in testi liberi caratterizzati da abbreviazioni, acronimi, gergo tecnico e una sintassi incoerente. La mancanza di struttura rende queste informazioni inutilizzabili per la ricerca. A causa delle rigide normative sulla privacy e dei limiti hardware degli ambienti clinici, questa tesi valuta le prestazioni di Large Language Models (LLM) open-source, eseguibili localmente, nella correzione ed estrazione di informazioni strutturate da testi medici rumorosi in lingua italiana. Abbiamo sviluppato una pipeline modulare e automatizzata per testare sette famiglie di modelli (Gemma3, Llama3, MedGemma, Mistral, GPT-OSS, Qwen3 e DeepSeek) con un numero di parametri compreso tra 4 e 70 miliardi, eseguiti localmente tramite il framework Ollama. I modelli sono stati valutati su due task principali: uno di correzione per eliminare refusi ed espandere acronimi ostetrici, e uno di estrazione per estrarre 28 valori clinici, come i punteggi Apgar e i valori dell'emogasanalisi. Le prestazioni sono state misurate rispetto a un gold standard di 100 note validate da esperti, analizzando diverse strategie di prompt engineering (ad esempio, few-shot, istruzioni positive, liste di acronimi dominio-specifici e ripetizione del prompt) e utilizzando sia metriche basate sulle stringhe che metriche basate sulla semantica (similarità di embeddings). I risultati dimostrano che gli LLM locali sono in grado di pulire ed estrarre con successo i dati clinici, sebbene le capacità dipendano fortemente dall'architettura e dalla progettazione del prompt. Per la correzione delle note, l'inserimento diretto di conoscenza di dominio nel prompt — come un elenco di acronimi comuni — ha superato altre tecniche come il few-shot prompting o il semplice aumento delle dimensioni del modello. Per l'estrazione di dati strutturati, alcuni modelli più piccoli (in particolare Qwen3 Small) hanno eguagliato o superato le loro controparti più grandi, dimostrando che le capacità di seguire le istruzioni (instruction-following) possono influire più del solo numero di parametri. Tra le architetture testate, i modelli Mistral e Gemma3 si sono dimostrate il miglior compromesso tra alta accuratezza semantica e bassa latenza di inferenza, rendendoli particolarmente adatti per l'implementazione in contesti reali. In definitiva, questa ricerca stabilisce una solida base metodologica dimostrando che gli LLM di piccole dimensioni possono valorizzare con successo i dati clinici storici non strutturati, senza ricorrere ad API cloud che potrebbero compromettere la privacy o a processi di fine-tuning computazionalmente onerosi.
Evaluating Large Language Models on free-text data in an italian obstetric context
Carta, Gianluca
2025/2026
Abstract
In modern healthcare, it is common to have unstructured data in Electronic Health Records (EHRs). It often consists of free text characterized by abbreviations, acronyms, jargon, and inconsistent syntax. This lack of structure makes such data inaccessible for automated research. Due to the strict privacy regulations and hardware constraints of clinical environments, this thesis evaluates the performance of locally deployable open-source Large Language Models (LLMs) in correcting and extracting structured information from noisy, non-English medical text. A modular, automated pipeline was developed to test seven model families (Gemma3, Llama3, MedGemma, Mistral, GPT-OSS, Qwen3, and DeepSeek) ranging from 4 to 70 billion parameters, executed locally via the Ollama framework. The models were evaluated on two main tasks: a correction task to fix typos and expand Italian obstetric acronyms, and an extraction task to retrieve 28 specific clinical fields, such as Apgar scores and blood gas values. Performance was measured against an expert-validated gold standard of 100 notes, analyzing various prompt engineering strategies (e.g., few-shot, positive instructions, domain-specific acronym lists, and prompt repetition) and using both string-based metrics and semantic embedding similarities. The results demonstrated that local LLMs can successfully clean and extract clinical data, though capabilities strongly depend on architecture and prompt design. For note correction, directly injecting domain knowledge into the prompt—such as a list of common acronyms—significantly outperformed other techniques like few-shot prompting or simply scaling up the model size. For structured data extraction, some smaller models (notably Qwen3 Small) surprisingly matched or even outperformed their larger counterparts, proving that instruction-following capabilities often matter more than raw parameter counts. Among the tested architectures, Mistral and Gemma3 models provided the most favorable trade-off between high semantic accuracy and low inference latency, making them highly suitable for real-world deployment. Ultimately, this research establishes a concrete methodological foundation showing that small LLMs can successfully unlock the value of unstructured historical clinical data without the need for privacy-compromising cloud APIs or computationally expensive fine-tuning.| File | Dimensione | Formato | |
|---|---|---|---|
|
2026_03_Carta_thesis.pdf
accessibile in internet per tutti
Descrizione: THESIS
Dimensione
3 MB
Formato
Adobe PDF
|
3 MB | Adobe PDF | Visualizza/Apri |
|
2026_03_Carta_executive_summary.pdf
accessibile in internet per tutti
Descrizione: EX SUMMARY
Dimensione
716.75 kB
Formato
Adobe PDF
|
716.75 kB | Adobe PDF | Visualizza/Apri |
I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.
https://hdl.handle.net/10589/253129