Comprehensive testing of large language models for extraction of structured data in pathology
TL;DR Highlight
Open-source LLMs matched GPT-4 accuracy when structuring pathology reports
Who Should Read
Backend developer in healthcare turning free-text documents into structured data who worries about API cost and privacy
Core Mechanics
- Open-source matched GPT-4
- On extracting 11 key parameters from pathology reports, open-source models reached accuracy comparable to GPT-4.
- Compared were Llama2 13B/70B, Llama3 8B/70B, and Qwen2.5 7B.
- Lower cost and fewer privacy worries
- Open-source models can run in your own environment, so they are cheaper than proprietary APIs and ease privacy concerns.
- This fits organizations handling sensitive documents like hospitals.
- Accuracy varies a lot by setup
- Precision differed significantly across models and configurations.
- Prompt strategy and quantization (shrinking a model) drove these differences.
- Tested in English and German
- 579 annotated reports were prepared in German and English versions.
- The dataset is public and usable as a benchmark.
Evidence
- Evaluated on 579 reports
- Annotated pathology reports in German and English versions.
- Each report required 11 key parameters to be extracted.
- Six models compared
- The one proprietary model was GPT-4.
- Open-source: Llama2 13B, Llama2 70B, Llama3 8B, Llama3 70B, Qwen2.5 7B.
- Open-source precision similar to GPT-4
- The paper says open-source models extract data with high precision, matching GPT-4 accuracy.
- The summary gives no specific figures.
How to Apply
- Compare extraction accuracy on 20 of your docs
- Pick 20 real documents today and write the ground-truth JSON by hand.
- Run the same prompt on your current API model and a local open-source model, then count correct fields.
- Run sensitive docs on local open-source models
- Apply this to extraction pipelines where external APIs are hard to use for privacy reasons.
- Check on a small sample that accuracy is GPT-4 level before switching.
- Test prompt and quantization combinations in a grid
- Cross 2-3 prompt strategies with 2-3 quantization levels and record accuracy for each.
- Deploy the lightest combination that clears your accuracy target.
Try It
# Paste into Claude or ChatGPT (simplified version of the paper's method: prompt-based field extraction)
Extract the following fields from the report below and answer with JSON only.
Fields: {{list of fields to extract}}
Rules:
- Use null for values not in the text.
- Do not guess or fill in.
- Keep values as worded in the original.
Report:
{{document}}Terminology
Related Papers
Gemini 4 Neon is the new #1 on the Models Engineering Index
Gemini 4 Neon ranks first on the Models Engineering Index with 68.0, combining multiple benchmarks.
LLMs can read and write executables byte by byte from a hex dump
Given only a hex dump and no tools, an LLM analyzed, patched and wrote working executables.
Claude was trained on protein sequences at scale
Next-amino-acid tests on obscure proteins show only the latest Claude models predict them
Remembered as Brief: Stored Preferences SilentlyRemove Decision-Critical Information
A stored 'keep it short' preference silently drops warnings; listing must-know points first restores content.
All AI-generated code should be Open Source
A blog argues AI-generated code should be open source; most HN commenters disagreed.
What thousands of conversations look like inside a language model
Mapping Qwen3-1.7B states showed Chinese sitting apart from English, while German and Croatian overlapped it.
AI, activity, and outcomes in software engineering
AI sped up writing code, but shipping speed did not rise as much, says a talk
LLMs Play Zachtronics' TIS-100
16 LLMs played TIS-100 and set 133 new Pareto frontier points across 18 puzzles
Original Abstract (Expand)
Pathology departments generate large volumes of unstructured data as free-text diagnostic reports. Converting these reports into structured formats for analytics or artificial intelligence projects requires substantial manual effort by specialized personnel. While recent studies show promise in using advanced language models for structuring pathology data, they primarily rely on proprietary models, raising cost and privacy concerns. Additionally, important aspects such as prompt engineering and model quantization for deployment on consumer-grade hardware remain unaddressed. We created a dataset of 579 annotated pathology reports in German and English versions. Six language models (proprietary: GPT-4; open-source: Llama2 13B, Llama2 70B, Llama3 8B, Llama3 70B, and Qwen2.5 7B) were evaluated for their ability to extract eleven key parameters from these reports. Additionally, we investigated model performance across different prompt engineering strategies and model quantization techniques to assess practical deployment scenarios. Here we show that open-source language models extract structured data from pathology reports with high precision, matching the accuracy of proprietary GPT-4 model. The precision varies significantly across different models and configurations. These variations depend on specific prompt engineering strategies and quantization methods used during model deployment. Open-source language models demonstrate comparable performance to proprietary solutions in structuring pathology report data. This finding has significant implications for healthcare institutions seeking cost-effective, privacy-preserving data structuring solutions. The variations in model performance across different configurations provide valuable insights for practical deployment in pathology departments. Our publicly available bilingual dataset serves as both a benchmark and a resource for future research. Pathology departments produce many diagnostic reports as free text, which is hard to analyze or use in research and computer projects. Converting this free text into more standard organized information like test results or diagnoses, makes it easier to use. This task often requires human experts and takes time. Large language models (LLMs), which are advanced computer systems designed to understand and generate human-like text, might simplify this process. Here, we tested six LLMs, including freely available models and the commercial GPT-4 model, using 579 pathology reports in English and German. Our results show that freely available models can perform as well as commercial, providing a cheaper solution while avoiding privacy concerns. The shared dataset will support future research in pathology data processing. Grothey et al. examine the performance of large language models in structuring pathology reports. Findings demonstrate similar accuracy between commercial and open-source models providing a cost-effective, privacy-conscious solution to extract structured data with high precision from bilingual datasets.