Distilling Closed-Source LLM's Knowledge for Locally Stable and Economic Biomedical Entity Linking

Yihao Ai, Zhiyuan Ning, Weiwei Dai, Pengfei Wang, Yi Du, Wenjuan Cui, Kunpeng Liu, Yuanchun Zhou

Abstract

Biomedical Entity Linking (BEL) is a critical task for clinical data standardization, yet it faces significant challenges due to "transfer distortion" across diverse medical domains and the high cost of human annotation. While closed-source Large Language Models (LLMs) like GPT-4 demonstrate impressive few-shot capabilities, their reliance on commercial APIs introduces concerns regarding operational costs, latency, and long-term stability in clinical environments. This paper presents RPDR (Retrieval, Prompting-based data generation, and Distillation for Re-ranking), a framework designed to bridge the gap between high-performing closed-source models and efficient, locally deployable open-source models. By leveraging a "teacher" LLM to generate high-quality synthetic re-ranking data, we successfully distill specialized medical knowledge into smaller "student" models. Our experiments show that these distilled models not only achieve state-of-the-art accuracy—often surpassing their teachers—but also operate at a fraction of the cost, providing a sustainable path for local clinical NLP infrastructure.

1. Introduction

Biomedical Entity Linking (BEL) involves mapping non-standard medical mentions found in clinical text (e.g., "heart attack") to standardized codes in a formal knowledge base like ICD-10 or SNOMED-CT. This task is complicated by the vast variability in medical terminology across different languages and clinical specialties, a phenomenon the authors define as "transfer distortion."

Traditional supervised models struggle with this distortion unless provided with massive amounts of human-labeled data, which is both expensive and time-consuming to acquire. While Large Language Models (LLMs) offer a solution through few-shot learning, relying on closed-source APIs for large-scale medical processing is often unfeasible. Commercial APIs are subject to price fluctuations, latency issues, and potential deprecation, making them risky for stable, long-term clinical applications. There is a pressing need for high-performance models that can be deployed locally on private infrastructure.

2. Methodology: The RPDR Framework

The researchers propose the RPDR framework, which consists of three primary stages: Retrieval, Prompting-based data generation, and Distillation for Re-ranking.

2.1 Candidate Retrieval

The process begins with a BERT-based bi-encoder (specifically SapBERT for English-language tasks) to perform initial candidate retrieval. This step quickly identifies the top-$k$ most similar standard entities from a target knowledge base for a given mention, narrowing the search space for the more computationally intensive re-ranking phase.

2.2 Prompting-based Training Data Generation

To avoid the high costs of human expert labeling, the framework utilizes a high-capacity "teacher" model (such as GPT-3.5 Turbo or DeepSeek V3). The teacher is prompted to re-rank the retrieved candidates for unannotated mentions, effectively creating a high-quality synthetic dataset that captures the teacher's reasoning and domain knowledge.

2.3 Distillation for Candidate Re-ranking

The synthetic data generated by the teacher is used to fine-tune a smaller, open-source "student" model. The authors utilized LoRA (Low-Rank Adaptation) to train models like BenTsao (for Chinese) or Llama-2-7B (for English). This distillation process allows the student model to "imitate" the complex reasoning of the much larger teacher model while remaining small enough for local deployment.

3. Experimental Setup

The RPDR framework was evaluated on two distinct datasets to test its cross-lingual and cross-domain generalizability:

  • Aier Dataset: A private Chinese medical dataset of clinical records annotated by professionals and mapped to the ICD-10 knowledge base.
  • Ask A Patient: A public English dataset containing adverse drug reaction mentions from social media and blog posts, mapped to SNOMED-CT and AMT.

4. Results and Discussion

4.1 Performance and Accuracy

The distilled student models demonstrated remarkable performance, often exceeding the raw accuracy of the teacher models they were trained on. On the Aier dataset, the distilled student achieved an Acc@1 of 0.740, surpassing the raw GPT-3.5 Turbo teacher (0.731). Overall, RPDR achieved a 0.019 Acc@1 improvement on the Aier dataset and a 0.036 Acc@1 improvement on the Ask A Patient dataset compared to baseline models in low-resource scenarios.

4.2 The Importance of Domain Pre-training

The choice of the base student model is critical. The authors found that starting with a model already exposed to medical knowledge (e.g., BenTsao) yielded significantly better results than using a general-purpose model like Llama-2. This suggests that distillation is most effective when the student model has a foundational understanding of the target domain.

4.3 Economic and Operational Efficiency

One of the most significant findings was the economic viability of the distilled models. A local Llama-2 model was nearly 8x cheaper to operate than GPT-3.5 Turbo and 1.5x cheaper than DeepSeek V3. Specifically, the cost per task dropped from $0.294 (GPT-3.5) to $0.038 (Local Llama-2), proving that high-performance medical NLP can be achieved without a massive cloud computing budget.

4.4 Data Scaling and Noise

The study identified a point of diminishing returns regarding synthetic data. Performance peaked at approximately 2,500 generated samples. Beyond this threshold, the introduction of "noisy" or incorrect re-rankings from the teacher model began to degrade the student's performance, highlighting the need for high-quality rather than high-quantity synthetic data.

5. Conclusion and Future Work

The RPDR framework successfully demonstrates that the knowledge of expensive, closed-source LLMs can be distilled into smaller, local models for Biomedical Entity Linking. This approach provides a stable, cost-effective, and high-performance solution for clinical settings.

Future research will focus on addressing the "teacher noise" problem. The authors suggest developing methods to filter out incorrect mention-candidate pairs during the distillation process, which would allow for larger-scale training without performance degradation. Additionally, improving the initial retrieval step remains a priority, as the system's ultimate accuracy is currently capped by the bi-encoder's ability to include the correct entity in the top-$k$ candidates.

Summary updated

BibTeX
@inproceedings{ai2025distilling,
  author = {Yihao Ai and Zhiyuan Ning and Weiwei Dai and Pengfei Wang and Yi Du and Wenjuan Cui and Kunpeng Liu and Yuanchun Zhou},
  title = {{Distilling Closed-Source LLM's Knowledge for Locally Stable and Economic Biomedical Entity Linking}},
  booktitle = {ICIC},
  year = {2025},
  doi = {10.1007/978-981-95-0027-7\_9},
}
Figure