Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- EmergentMethods/AskNews-NER-v0
|
5 |
+
---
|
6 |
+
# Model Card for Model ID
|
7 |
+
|
8 |
+
This model is a fine-tune of [GLiNER](https://huggingface.co/urchade/gliner_medium-v2.1) aimed at improving accuracy across a broad range of topics, especially with respect to long-context news entity extraction. As hown in the table below, these fine-tunes improved upon the base GLiNER model zero-shot accuracy by up to 7.5% across 18 benchmark datasets.
|
9 |
+
|
10 |
+
![results table](assets/zero-shot_20_table.png)
|
11 |
+
|
12 |
+
The underlying dataset, [AskNews-NER-v0](https://huggingface.co/datasets/EmergentMethods/AskNews-NER-v0) was engineered with the objective of diversifying global perspectives by enforcing country/language/topic/temporal diversity. All data used to fine-tune this model was synthetically generated. WizardLM 13B v2.0 was used for translation/summarization of open-web news articles, while Llama3 70b instruct was used for entity extraction. Both the diversification and fine-tuning methods are presented in a [pre-print submitted to NeurIps2024](https://linktoarxiv.org).
|
13 |
+
|
14 |
+
# Usage
|
15 |
+
|
16 |
+
```python
|
17 |
+
from gliner import GLiNER
|
18 |
+
|
19 |
+
model = GLiNER.from_pretrained("EmergentMethods/gliner_medium_news-v2.1")
|
20 |
+
|
21 |
+
text = """
|
22 |
+
The Chihuahua State Public Security Secretariat (SSPE) arrested 35-year-old Salomón C. T. in Ciudad Juárez, found in possession of a stolen vehicle, a white GMC Yukon, which was reported stolen in the city's streets. The arrest was made by intelligence and police analysis personnel during an investigation in the border city. The arrest is related to a previous detention on February 6, which involved armed men in a private vehicle. The detainee and the vehicle were turned over to the Chihuahua State Attorney General's Office for further investigation into the case.
|
23 |
+
"""
|
24 |
+
|
25 |
+
labels = ["person", "location", "date", "event", "facility", "vehicle", "number", "organization"]
|
26 |
+
|
27 |
+
entities = model.predict_entities(text, labels)
|
28 |
+
|
29 |
+
for entity in entities:
|
30 |
+
print(entity["text"], "=>", entity["label"])
|
31 |
+
```
|
32 |
+
|
33 |
+
Output:
|
34 |
+
|
35 |
+
```
|
36 |
+
Chihuahua State Public Security Secretariat => organization
|
37 |
+
SSPE => organization
|
38 |
+
35-year-old => number
|
39 |
+
Salomón C. T. => person
|
40 |
+
Ciudad Juárez => location
|
41 |
+
GMC Yukon => vehicle
|
42 |
+
February 6 => date
|
43 |
+
Chihuahua State Attorney General's Office => organization
|
44 |
+
```
|
45 |
+
|
46 |
+
## Model Details
|
47 |
+
|
48 |
+
### Model Description
|
49 |
+
|
50 |
+
<!-- Provide a longer summary of what this model is. -->
|
51 |
+
|
52 |
+
The synthetic data underlying this news fine-tune was pulled from the [AskNews API](https://docs.asknews.app). We enforced diveristy across country/language/topic/time.
|
53 |
+
|
54 |
+
Countries:
|
55 |
+
|
56 |
+
![country distribution](assets/countries_distribution.png)
|
57 |
+
|
58 |
+
Entity types:
|
59 |
+
|
60 |
+
![entities](assets/entity-types_limited.png)
|
61 |
+
|
62 |
+
Topics:
|
63 |
+
|
64 |
+
![topics](assets/topics_fig_connected.png)
|
65 |
+
|
66 |
+
|
67 |
+
- **Developed by:** [Emergent Methods](https://www.emergentmethods.ai/)
|
68 |
+
- **Funded by:** [Emergent Methods](https://www.emergentmethods.ai/)
|
69 |
+
- **Shared by:** [Emergent Methods](https://www.emergentmethods.ai/)
|
70 |
+
- **Model type:** microsoft/deberta
|
71 |
+
- **Language(s) (NLP):** English (en), and translated French, Spanish, German, Swedish, Italian, Arabic, Chinese, Norwegian, Danish, Dutch, Russian, Ukranian
|
72 |
+
- **License:** Apache 2.0
|
73 |
+
- **Finetuned from model:** [GLiNER](https://huggingface.co/urchade/gliner_medium-v2.1)
|
74 |
+
|
75 |
+
### Model Sources [optional]
|
76 |
+
|
77 |
+
<!-- Provide the basic links for the model. -->
|
78 |
+
|
79 |
+
- **Repository:** To be added
|
80 |
+
- **Paper:** To be added
|
81 |
+
- **Demo:** To be added
|
82 |
+
|
83 |
+
## Uses
|
84 |
+
|
85 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
86 |
+
|
87 |
+
### Direct Use
|
88 |
+
|
89 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
90 |
+
|
91 |
+
As the name suggests, this model is aimed at generalist entity extraction. Although we used news to fine-tune this model, it improved accuracy across 18 benchmark datasets by up to 7.5%. This means that the broad and diversified underlying dataset has helped it to recognize and extract more entity types.
|
92 |
+
|
93 |
+
This model is shockingly compact, and can be used for high-throughput production usecases. This is another reason we have licensed this as Apache 2.0. Currently, [AskNews](https://asknews.app) is using this fine-tune for entity extraction in their system.
|
94 |
+
|
95 |
+
|
96 |
+
## Bias, Risks, and Limitations
|
97 |
+
|
98 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
99 |
+
|
100 |
+
Although the goal of the dataset is to reduce bias, and improve diversity, it is still biased to western languages and countries. This limitation originates from the abilities of Llama2 for the translation and summary generations. Further, any bias originating in Llama2 training data will also be present in this dataset, since Llama2 was used to summarize the open-web articles. Further, any biases present in Llama3 will be present in the present dataaset since Llama3 was used to extract entities from the summaries.
|
101 |
+
|
102 |
+
![countries distribution](figures/topics_fig_connected.png)
|
103 |
+
|
104 |
+
|
105 |
+
## How to Get Started with the Model
|
106 |
+
|
107 |
+
Use the code below to get started with the model.
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
## Training Details
|
112 |
+
|
113 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
114 |
+
|
115 |
+
The training dataset is [AskNews-NER-v0](https://huggingface.co/datasets/EmergentMethods/AskNews-NER-v0).
|
116 |
+
|
117 |
+
Other training details can be found in the [companion paper](https://linktoarxiv.org).
|
118 |
+
|
119 |
+
|
120 |
+
|
121 |
+
## Environmental Impact
|
122 |
+
|
123 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
124 |
+
|
125 |
+
- **Hardware Type:** 1xA4500
|
126 |
+
- **Hours used:** 10
|
127 |
+
- **Carbon Emitted:** 0.6 kg (According to [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute))
|
128 |
+
|
129 |
+
|
130 |
+
## Citation
|
131 |
+
|
132 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
133 |
+
|
134 |
+
**BibTeX:**
|
135 |
+
|
136 |
+
To be added
|
137 |
+
|
138 |
+
**APA:**
|
139 |
+
|
140 |
+
To be added
|
141 |
+
|
142 |
+
## Model Authors
|
143 |
+
|
144 |
+
Elin Törnquist, Emergent Methods elin at emergentmethods.ai
|
145 |
+
Robert Caulk, Emergent Methods rob at emergentmethods.ai
|
146 |
+
|
147 |
+
|
148 |
+
## Model Contact
|
149 |
+
|
150 |
+
Elin Törnquist, Emergent Methods elin at emergentmethods.ai
|
151 |
+
Robert Caulk, Emergent Methods rob at emergentmethods.ai
|