Views
No views yet

disease, drug, body_part, …). The density is then the ratio of characters inside the extracted spans to the document's total characters.1from gliner2 import GLiNER2
2
3extractor = GLiNER2.from_pretrained("doctolib-lab/finemed-entity-extractor-fr")
4
5# 8-class taxonomy; passing descriptions (not just the keys) improves extraction
6labels = {
7 "disease": "Pathological condition: disease, syndrome, infection, cancer, injury, symptom, clinical finding, mental disorder",
8 "drug": "Chemical substance for therapy: prescription medication, vaccine, therapeutic compound, drug class, contrast agent",
9 "body_part": "Anatomical structure: organ, tissue, bone, muscle, blood vessel, nerve, cell, body fluid, anatomical region",
10 "medical_procedure": "Clinical action with methodology: surgery, diagnostic test, medical examination, laboratory test, imaging procedure",
11 "molecular_marker": "Molecular entity or biochemical substance: gene, protein, enzyme, receptor, genetic variant, biochemical analyte",
12 "clinical_device": "Manufactured medical object: surgical tool, implant, prosthetic, diagnostic scanner, monitoring equipment",
13 "vital_function": "Physiological parameter name: heart rate, blood pressure, respiratory rate, temperature, oxygen saturation",
14 "living_beings": "Non-human organism in biomedical context: bacterium, virus, fungus, parasite, pathogen, model organism",
15}
16
17text = "Le patient présente une pneumonie traitée par amoxicilline ..."
18results = extractor.batch_extract_entities([text], labels, threshold=0.5)
19print(results[0]["entities"])
20# {"disease": ["pneumonie"], "drug": ["amoxicilline"], ...}medical_entity_density, run extraction over the middle 512 tokens of each document, then divide the characters covered by the extracted spans by the document's total character count. Taking the middle window skips boilerplate at the document boundaries and keeps corpus-scale inference tractable.| class | covers |
|---|---|
disease | disease, syndrome, infection, cancer, injury, symptom, clinical finding, mental disorder |
drug | prescription medication, vaccine, therapeutic compound, drug class, contrast agent |
body_part | organ, tissue, bone, muscle, blood vessel, nerve, cell, body fluid, anatomical region |
medical_procedure | surgery, diagnostic test, medical examination, laboratory test, imaging procedure |
molecular_marker | gene, protein, enzyme, receptor, genetic variant, biochemical analyte |
clinical_device | surgical tool, implant, prosthetic, diagnostic scanner, monitoring equipment |
vital_function | heart rate, blood pressure, respiratory rate, temperature, oxygen saturation |
living_beings | bacterium, virus, fungus, parasite, pathogen, model organism |
medical_entity_extract_prompt.txt (Pass 1) and medical_entity_review_prompt.txt (Pass 2).