rntc commited on
Commit
d029bb4
·
1 Parent(s): 48c2230

change to french biomedical examples

Browse files
Files changed (1) hide show
  1. app.py +41 -101
app.py CHANGED
@@ -2,99 +2,37 @@ from typing import Dict, Union
2
  from gliner import GLiNER
3
  import gradio as gr
4
 
5
- model = GLiNER.from_pretrained("urchade/gliner_multi-v2.1")
6
 
7
  examples = [
8
  [
9
- "Libretto by Marius Petipa, based on the 1822 novella ``Trilby, ou Le Lutin d'Argail`` by Charles Nodier, first presented by the Ballet of the Moscow Imperial Bolshoi Theatre on January 25/February 6 (Julian/Gregorian calendar dates), 1870, in Moscow with Polina Karpakova as Trilby and Ludiia Geiten as Miranda and restaged by Petipa for the Imperial Ballet at the Imperial Bolshoi Kamenny Theatre on January 17–29, 1871 in St. Petersburg with Adèle Grantzow as Trilby and Lev Ivanov as Count Leopold.",
10
- "person, book, location, date, actor, character",
11
- 0.3,
12
- True,
13
- ],
14
- [
15
- """
16
- * Data Scientist, Data Analyst, or Data Engineer with 1+ years of experience.
17
- * Experience with technologies such as Docker, Kubernetes, or Kubeflow
18
- * Machine Learning experience preferred
19
- * Experience with programming languages such as Python, C++, or SQL preferred
20
- * Experience with technologies such as Databricks, Qlik, TensorFlow, PyTorch, Python, Dash, Pandas, or NumPy preferred
21
- * BA or BS degree
22
- * Active Secret OR Active Top Secret or Active TS/SCI clearance
23
- """,
24
- "software package, programing language, software tool, degree, job title",
25
- 0.3,
26
  False,
27
  ],
28
  [
29
- "However, both models lack other frequent DM symptoms including the fibre-type dependent atrophy, myotonia, cataract and male-infertility.",
30
- "disease, symptom",
31
- 0.3,
32
  False,
33
  ],
34
  [
35
- "Synergy between signal transduction pathways is obligatory for expression of c-fos in B and T cell lines: implication for c-fos control via surface immunoglobulin and T cell antigen receptors.",
36
- "DNA, RNA, cell line, cell type, protein",
37
- 0.3,
38
- False,
39
- ],
40
- [
41
- "The choice of the encoder and decoder modules of dnpg can be quite flexible, for instance long short term memory networks (lstm) or convolutional neural network (cnn).",
42
- "short acronym, long acronym",
43
- 0.3,
44
- False,
45
- ],
46
- [
47
- "Amelia Earhart flew her single engine Lockheed Vega 5B across the Atlantic to Paris.",
48
- "person, company, location, airplane",
49
- 0.3,
50
  True,
51
  ],
52
  [
53
- "Feldman is a contributor to NBC Sports Boston's ``State of the Revs`` and ``Revolution Postgame Live`` programs as well as to 98.5 the SportsHub, SiriusXM FC's MLS coverage and to other New England and national radio outlets and podcasts.",
54
- "person, company, location",
55
- 0.3,
56
- False,
57
- ],
58
- [
59
- "On 25 July 1948, on the 39th anniversary of Bleriot's crossing of the English Channel, the Type 618 Nene-Viking flew Heathrow to Paris (Villacoublay) in the morning carrying letters to Bleriot's widow and son (secretary of the FAI), who met it at the airport.",
60
- "date, location, person, organization",
61
- 0.3,
62
- False,
63
- ],
64
- [
65
- "Leo & Ian won the 1962 Bathurst Six Hour Classic at Mount Panorama driving a Daimler SP250 sports car, (that year the 500 mile race for touring cars were held at Phillip Island)",
66
- "person, date, location, organization, competition",
67
- 0.3,
68
- False,
69
- ],
70
- [
71
- "The Shore Line route of the CNS & M until 1955 served, from south to north, the Illinois communities of Chicago, Evanston, Wilmette, Kenilworth, Winnetka, Glencoe, Highland Park, Highwood, Fort Sheridan, Lake Forest, Lake Bluff, North Chicago, Waukegan, Zion, and Winthrop Harbor as well as Kenosha, Racine, and Milwaukee (the ``KRM'') in Wisconsin.",
72
- "location, organization, date",
73
- 0.3,
74
  False,
75
  ],
76
  [
77
- "Comet C/2006 M4 (SWAN) is a non-periodic comet discovered in late June 2006 by Robert D. Matson of Irvine, California and Michael Mattiazzo of Adelaide, South Australia in publicly available images of the Solar and Heliospheric Observatory (SOHO).",
78
- "person, organization, date, location",
79
- 0.3,
80
- False,
81
- ],
82
- [
83
- "From November 29, 2011 to March 31, 2012, Karimloo returned to ``Les Misérables`` to play the lead role of Jean Valjean at The Queen's Theatre, London, for which he won the 2013 Theatregoers' Choice Award for Best Takeover in a Role.",
84
- "person, actor, award, date, location",
85
- 0.3,
86
- False,
87
- ],
88
- [
89
- "A Mexicali health clinic supported by former Baja California gubernatorial candidate Enrique Acosta Fregoso (PRI) was closed on June 15 after selling a supposed COVID-19 ``cure'' for between MXN $10,000 and $50,000.",
90
- "location, organization, person, date, currency",
91
- 0.3,
92
- False,
93
- ],
94
- [
95
- "Built in 1793, it was the home of Mary Young Pickersgill when she moved to Baltimore in 1806 and the location where she later sewed the ``Star Spangled Banner'', in 1813, the huge out-sized garrison flag that flew over Fort McHenry at Whetstone Point in Baltimore Harbor in the summer of 1814 during the British Royal Navy attack in the Battle of Baltimore during the War of 1812.",
96
- "date, person, location, organization, event, flag",
97
- 0.3,
98
  False,
99
  ],
100
  ]
@@ -124,16 +62,24 @@ def ner(
124
  with gr.Blocks(title="GLiNER-M-v2.1") as demo:
125
  gr.Markdown(
126
  """
127
- # GLiNER-base
 
 
 
 
 
 
128
 
129
- GLiNER is a Named Entity Recognition (NER) model capable of identifying any entity type using a bidirectional transformer encoder (BERT-like). It provides a practical alternative to traditional NER models, which are limited to predefined entities, and Large Language Models (LLMs) that, despite their flexibility, are costly and large for resource-constrained scenarios.
130
 
131
  ## Links
132
 
133
- * Model: https://huggingface.co/urchade/gliner_multi-v2.1
134
- * All GLiNER models: https://huggingface.co/models?library=gliner
135
- * Paper: https://arxiv.org/abs/2311.08526
136
- * Repository: https://github.com/urchade/GLiNER
 
 
137
  """
138
  )
139
  with gr.Accordion("How to run this model locally", open=False):
@@ -153,13 +99,13 @@ with gr.Blocks(title="GLiNER-M-v2.1") as demo:
153
  '''
154
  from gliner import GLiNER
155
 
156
- model = GLiNER.from_pretrained("urchade/gliner_mediumv2.1")
157
 
158
  text = """
159
- Cristiano Ronaldo dos Santos Aveiro (Portuguese pronunciation: [kɾiʃˈtjɐnu ʁɔˈnaldu]; born 5 February 1985) is a Portuguese professional footballer who plays as a forward for and captains both Saudi Pro League club Al Nassr and the Portugal national team. Widely regarded as one of the greatest players of all time, Ronaldo has won five Ballon d'Or awards,[note 3] a record three UEFA Men's Player of the Year Awards, and four European Golden Shoes, the most by a European player. He has won 33 trophies in his career, including seven league titles, five UEFA Champions Leagues, the UEFA European Championship and the UEFA Nations League. Ronaldo holds the records for most appearances (183), goals (140) and assists (42) in the Champions League, goals in the European Championship (14), international goals (128) and international appearances (205). He is one of the few players to have made over 1,200 professional career appearances, the most by an outfield player, and has scored over 850 official senior career goals for club and country, making him the top goalscorer of all time.
160
  """
161
 
162
- labels = ["person", "award", "date", "competitions", "teams"]
163
 
164
  entities = model.predict_entities(text, labels)
165
 
@@ -170,18 +116,12 @@ for entity in entities:
170
  )
171
  gr.Code(
172
  """
173
- Cristiano Ronaldo dos Santos Aveiro => person
174
- 5 February 1985 => date
175
- Al Nassr => teams
176
- Portugal national team => teams
177
- Ballon d'Or => award
178
- UEFA Men's Player of the Year Awards => award
179
- European Golden Shoes => award
180
- UEFA Champions Leagues => competitions
181
- UEFA European Championship => competitions
182
- UEFA Nations League => competitions
183
- Champions League => competitions
184
- European Championship => competitions
185
  """
186
  )
187
 
@@ -198,14 +138,14 @@ European Championship => competitions
198
  threshold = gr.Slider(
199
  0,
200
  1,
201
- value=0.3,
202
  step=0.01,
203
  label="Threshold",
204
  info="Lower the threshold to increase how many entities get predicted.",
205
  scale=1,
206
  )
207
  nested_ner = gr.Checkbox(
208
- value=examples[0][2],
209
  label="Nested NER",
210
  info="Allow for nested NER?",
211
  scale=0,
 
2
  from gliner import GLiNER
3
  import gradio as gr
4
 
5
+ model = GLiNER.from_pretrained("rntc/gliner-cbio-30k")
6
 
7
  examples = [
8
  [
9
+ "Le cas présenté concerne un homme âgé de 61 ans (71 kg, 172 cm, soit un indice de masse corporelle de 23,9 kg/m²) admissible à une transplantation pulmonaire en raison d’une insuffisance respiratoire chronique terminale sur emphysème post-tabagique, sous oxygénothérapie continue (1 L/min) et ventilation non invasive nocturne. Il présente, comme principaux antécédents, une dyslipidémie, une hypertension artérielle et un tabagisme sevré estimé à 21 paquets-années (facteurs de risque cardiovasculaires). Le bilan préopératoire a révélé une hypertension artérielle pulmonaire essentiellement postcapillaire conduisant à l’ajout du périndopril (2 mg par jour) et du furosémide (40 mg par jour). La mise en évidence d’un Elispot (enzyme-linked immunospot) positif pour la tuberculose a motivé l’introduction d’un traitement prophylactique par l’association rifampicine-isoniazide (600-300 mg par jour) pour une durée de trois mois.",
10
+ "Maladie, Symptôme, Âge, Poids, Taille, Substance, Traitement, Dosage",
11
+ 0.5,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  False,
13
  ],
14
  [
15
+ "Un patient de 32 ans, ayant des antécédents de polytoxicomanie (cocaïne, ecstasy, amphétamines et cannabis) et d’éthylisme chronique est admis aux urgences pour des signes cliniques apparus dans les trois jours précédents : agitation, hallucinations auditives et visuelles, propos incohérents, anorexie, insomnie, céphalées modérées. Sur le plan hémodynamique la fréquence cardiaque est de 84 bpm, la tension artérielle est de 114/91 mmHg et l’ECG est normal. L’examen clinique est par ailleurs sans particularité en dehors de pupilles en mydriase. Le bilan d’entrée biologique montre des CPK à 535 UI/L, une hémoglobinémie à 17,0 g/dL, une lactacidémie normale à 0,7 mmol/L, de même que la gazométrie (pH 7,41, pCO2 40 mmHg, p02 73 mmHg). L’alcoolémie à l’admission est nulle. Le patient explique qu’il a ingéré 250 mg de désoxypipradrol acheté sur Internet. L’agitation du patient dans un contexte concomitant de sevrage éthylique a nécessité une sédation par oxazépam. À J5 de l’ingestion, le patient était plus calme, se plaignait encore de quelques céphalées et ne présentait ni hallucination, ni fièvre. À J7, l’ensemble des symptômes avait disparu.",
16
+ "Maladie, Symptôme, Âge, Poids, Taille, Substance, Traitement",
17
+ 0.5,
18
  False,
19
  ],
20
  [
21
+ "Une femme de 50 ans d’origine africaine s’est présentée au service des urgences avec des symptômes d’atteinte neurologique de confusion, d’ataxie, de paresthésie et de céphalées. Elle n’avait aucun antécédent médical connu, puisqu’elle n’avait pas consulté de médecin depuis des années. Elle ne prenait aucun médicament ni produit de santé naturel, n’avait pas d’allergie, ne fumait pas et ne consommait pas d’alcool. Les symptômes décrits s’étaient progressivement aggravés au cours des deux dernières semaines. Elle avait aussi noté une perte de poids au cours des derniers mois. Une prise de sang révéla une pancytopénie ainsi qu’une insuffisance rénale avec une clairance de la créatinine estimée à 45 ml/min selon la formule de Cockcroft et Gault pour un poids de 48,2 kg et un taux de créatinine sérique de 98 µmol/L7. Les valeurs de laboratoire à l’admission de la patiente sont détaillées dans le tableau I. Les examens radiologiques, tels qu’une tomoden­ sitométrie axiale cérébrale ainsi que des imageries cérébrales par résonance magnétique et des tests microbiologiques ont permis aux médecins de poser un diagnostic de toxoplasmose cérébrale associée à un œdème cérébral. Par la suite, d’autres analyses ont révélé la présence du VIH et du VHC. À son admission, le taux de lymphocytes T CD4 était de 46 cellules/µl (numération normale : 700 à 1100 cellules/µl) et la charge virale était de 140 896 copies/ml.",
22
+ "Maladie, Symptôme, Âge, Poids, Taille, Substance, Traitement",
23
+ 0.5,
 
 
 
 
 
 
 
 
 
 
 
 
24
  True,
25
  ],
26
  [
27
+ "Une patiente caucasienne de 32 ans, pesant 68 kg et ne présentant aucune allergie médicamenteuse ni aucun antécédent médical pertinent hormis un asthme allergique, a été admise à l’unité de greffe de cellules hématopoïétiques. Quatre mois avant cette admission, la patiente se plaignait de fatigue et d’ecchymoses. Des examens hématologiques avaient permis de poser un diagnostic de leucémie aiguë lymphoblastique. Une rémission complète a été obtenue après un traitement d’induction consistant en quatre cycles de chimiothérapie de type hyperCVAD (cyclophosphamide hyperfractionnée, vincristine, doxorubicine, dexaméthasone). Les analyses cytogénétiques ont révélé l’absence du chromosome de Philadelphie, mais la présence d’un réarrangement du gène MML (mixed lineage leukemia) représentait un risque élevé de récidive de la leucémie. Une greffe de cellules hématopoïétiques a alors été recommandée avec le concours d’un donneur non apparenté, la patiente n’ayant pas de donneur compatible dans sa fratrie. Le régime de conditionnement utilisé a été l’association de cyclophosphamide à haute dose et de radiothérapie pancorporelle. À l’admission de la patiente pour la greffe, les analyses suivantes étaient normales : fonctions rénales (créatinine : 62 μmol/l), hépatiques (bilirubine totale : 5 μmol/l; alanine aminotransférase : 5 U/l; aspartate aminotransférase : 13 U/l) et hématologiques (globules blancs : 4,1 × 109/l; neutrophiles : 2,4 × 109/l; plaquettes : 236 × 109/l; hémoglobine : 122 g/l).",
28
+ "Maladie, Symptôme, Âge, Poids, Taille, Substance, Traitement",
29
+ 0.5,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  False,
31
  ],
32
  [
33
+ "Le diagnostic de phéochromocytome vésical a été suspecté, le dosage de l'acide vanyl-mandélique urinaire (VMA) était normal, le dosage des cathécholamines n'a pas été réalisé.",
34
+ "Maladie, Symptôme, Âge, Poids, Taille, Substance, Traitement",
35
+ 0.5,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  False,
37
  ],
38
  ]
 
62
  with gr.Blocks(title="GLiNER-M-v2.1") as demo:
63
  gr.Markdown(
64
  """
65
+ <img src="https://camembert-bio-model.fr/authors/camembert-bio/camembert-bio-ner-logo.png" alt="drawing" width="250"/>
66
+
67
+ # CamemBERT-bio-ner
68
+
69
+ CamemBERT-bio-ner is a Named Entity Recognition (NER) model capable of identifying any french biomedical entity type using a BERT-like encoder. It provides a practical alternative to traditional NER models, which are limited to predefined entities, and Large Language Models (LLMs) that, despite their flexibility, are costly and large for resource-constrained scenarios.
70
+
71
+ [CamemBERT-bio](https://huggingface.co/almanach/camembert-bio-base) is used as a backbone.
72
 
73
+ This model is based on the fantastic work of [Urchade Zaratiana](https://huggingface.co/urchade) on the [GLiNER](https://github.com/urchade/GLiNER) architecture.
74
 
75
  ## Links
76
 
77
+ * Model: https://huggingface.co/almanach/camembert-bio-ner
78
+ * Backbone model: https://huggingface.co/almanach/camembert-bio-base
79
+ * GLiNER library: https://github.com/urchade/GLiNER
80
+ * Developed by: [Rian Touchent](https://rian-t.github.io), [Eric Villemonte de La Clergerie](http://pauillac.inria.fr/~clerger/)
81
+ * Logo by: [Alix Chagué](https://alix-tz.github.io/), [Rian Touchent](https://rian-t.github.io)
82
+ * License: MIT
83
  """
84
  )
85
  with gr.Accordion("How to run this model locally", open=False):
 
99
  '''
100
  from gliner import GLiNER
101
 
102
+ model = GLiNER.from_pretrained("almanach/camembert-bio-ner")
103
 
104
  text = """
105
+ Mme A.P. âgée de 52 ans, non tabagique, ayant un diabète de type 2 a été hospitalisée pour une pneumopathie infectieuse. Cette patiente présentait depuis 2 ans des infections respiratoires traités en ambulatoire. L’examen physique a trouvé une fièvre à 38ºc et un foyer de râles crépitants de la base pulmonaire droite.
106
  """
107
 
108
+ labels = ["Âge", "Patient", "Maladie", "Symptômes"]
109
 
110
  entities = model.predict_entities(text, labels)
111
 
 
116
  )
117
  gr.Code(
118
  """
119
+ Mme A.P. => Patient
120
+ 52 ans => Âge
121
+ pneumopathie infectieuse => Maladie
122
+ infections respiratoires => Maladie
123
+ fièvre => Symptômes
124
+ râles crépitants => Symptômes
 
 
 
 
 
 
125
  """
126
  )
127
 
 
138
  threshold = gr.Slider(
139
  0,
140
  1,
141
+ value=0.5,
142
  step=0.01,
143
  label="Threshold",
144
  info="Lower the threshold to increase how many entities get predicted.",
145
  scale=1,
146
  )
147
  nested_ner = gr.Checkbox(
148
+ value=False,
149
  label="Nested NER",
150
  info="Allow for nested NER?",
151
  scale=0,