From Reports to Relations: Large Language Models for Knowledge Graph Extraction in Digital Pathology
摘要
Large language models (LLMs) are increasingly used to structure free-text clinical data. However, many practical approaches rely on rigid schema-based outputs, which limit semantic flexibility and downstream reuse. In this study, we propose an alternative representation: prompting an open-weight LLM to directly extract knowledge graph triples. Unlike findings in pre-defined field-based outputs such as JSON, graph-based outputs naturally capture relationships between entities, supporting more flexible querying, integration, and visualization. We apply our method to a curated subset of Dutch soft tissue tumor pathology reports and compare the graph-based extractions with structured JSON outputs. Across 20 reports for 24 specimens, both formats achieved high macro-averaged F1 scores (≥0.9) for most fields, with JSON marginally outperforming in certain categories. In addition to their competitive accuracy, graph outputs offer improved structural consistency and semantic clarity, making them a promising foundation for generating ground-truth labels in downstream tasks such as imaging-based AI applications. These findings support the use of knowledge graph-based outputs as a solution for structuring complex medical narratives.