Token Classification
GLiNER
PyTorch
multilingual
ravi3647 commited on
Commit
327667c
1 Parent(s): 4c1169a

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +108 -0
  2. config.json +28 -0
  3. pytorch_model.bin +3 -0
README.md ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ language:
4
+ - multilingual
5
+ pipeline_tag: token-classification
6
+ datasets:
7
+ - Universal-NER/Pile-NER-type
8
+ library_name: gliner
9
+ ---
10
+
11
+ # Model Card for GLiNER-multi
12
+
13
+ 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.
14
+
15
+ This version has been trained on the **Pile-NER** dataset (Research purpose). Commercially permission versions are available (**urchade/gliner_smallv2**, **urchade/gliner_mediumv2**, **urchade/gliner_largev2**)
16
+
17
+ ## Links
18
+
19
+ * Paper: https://arxiv.org/abs/2311.08526
20
+ * Repository: https://github.com/urchade/GLiNER
21
+
22
+ ## Installation
23
+ To use this model, you must install the GLiNER Python library:
24
+ ```
25
+ !pip install gliner
26
+ ```
27
+
28
+ ## Usage
29
+ Once you've downloaded the GLiNER library, you can import the GLiNER class. You can then load this model using `GLiNER.from_pretrained` and predict entities with `predict_entities`.
30
+
31
+ ```python
32
+ from gliner import GLiNER
33
+
34
+ model = GLiNER.from_pretrained("urchade/gliner_multi")
35
+
36
+ text = """
37
+ 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.
38
+ """
39
+
40
+ labels = ["person", "award", "date", "competitions", "teams"]
41
+
42
+ entities = model.predict_entities(text, labels)
43
+
44
+ for entity in entities:
45
+ print(entity["text"], "=>", entity["label"])
46
+ ```
47
+
48
+ ```
49
+ Cristiano Ronaldo dos Santos Aveiro => person
50
+ 5 February 1985 => date
51
+ Saudi Pro League => competitions
52
+ Al Nassr => teams
53
+ Portugal national team => teams
54
+ Ballon d'Or => award
55
+ UEFA Men's Player of the Year Awards => award
56
+ European Golden Shoes => award
57
+ UEFA Champions Leagues => competitions
58
+ UEFA European Championship => competitions
59
+ UEFA Nations League => competitions
60
+ Champions League => competitions
61
+ European Championship => competitions
62
+ ```
63
+
64
+ ```python
65
+ from gliner import GLiNER
66
+
67
+ model = GLiNER.from_pretrained("urchade/gliner_multi")
68
+
69
+ text = """
70
+ Это старый-добрый Римантадин, только в сиропе.
71
+ """
72
+ # Gold: Римантадин - Drugname, сиропе - Drugform
73
+
74
+ labels = ["Drugname", "Drugform"]
75
+
76
+ entities = model.predict_entities(text, labels)
77
+
78
+ for entity in entities:
79
+ print(entity["text"], "=>", entity["label"])
80
+ ```
81
+
82
+ ```
83
+ Римантадин => Drugname
84
+ сиропе => Drugform
85
+ ```
86
+
87
+ ## Named Entity Recognition benchmark result
88
+
89
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317233cc92fd6fee317e030/Y5f7tK8lonGqeeO6L6bVI.png)
90
+
91
+ ## Model Authors
92
+ The model authors are:
93
+ * [Urchade Zaratiana](https://huggingface.co/urchade)
94
+ * Nadi Tomeh
95
+ * Pierre Holat
96
+ * Thierry Charnois
97
+
98
+ ## Citation
99
+ ```bibtex
100
+ @misc{zaratiana2023gliner,
101
+ title={GLiNER: Generalist Model for Named Entity Recognition using Bidirectional Transformer},
102
+ author={Urchade Zaratiana and Nadi Tomeh and Pierre Holat and Thierry Charnois},
103
+ year={2023},
104
+ eprint={2311.08526},
105
+ archivePrefix={arXiv},
106
+ primaryClass={cs.CL}
107
+ }
108
+ ```
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size_sup": -1,
3
+ "max_types": 25,
4
+ "shuffle_types": true,
5
+ "random_drop": true,
6
+ "max_neg_type_ratio": 1,
7
+ "max_len": 384,
8
+ "lr_encoder": "1e-5",
9
+ "lr_others": "5e-5",
10
+ "num_steps": 30000,
11
+ "warmup_ratio": 0.1,
12
+ "train_batch_size": 8,
13
+ "eval_every": 5000,
14
+ "max_width": 12,
15
+ "model_name": "microsoft/mdeberta-v3-base",
16
+ "fine_tune": true,
17
+ "subtoken_pooling": "first",
18
+ "hidden_size": 768,
19
+ "span_mode": "marker",
20
+ "dropout": 0.4,
21
+ "name": "abl",
22
+ "root_dir": "log_main",
23
+ "train_data": "/gpfswork/rech/ohy/upa43yu/instruct_ner/train_instruct.json",
24
+ "prev_path": "none",
25
+ "gpu": "ohy@a100",
26
+ "run_time": "05:30:00",
27
+ "log_dir": "/gpfsdswork/projects/rech/bwq/upa43yu/GLiNER/log_main/mdeberta-v3-base_1"
28
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3351ae4cdfd929e2bc91f667ad1478717f85e37990917cb21aa83908557a1f97
3
+ size 1166909406