Update README.md
Browse files
README.md
CHANGED
|
@@ -195,6 +195,37 @@ print(nel_pipeline(sentence))
|
|
| 195 |
'rOffset': 33}]
|
| 196 |
```
|
| 197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
The type of the entity is `UNK` because the model was not trained on the entity type. The `confidence_nel` score
|
| 199 |
indicates the model's confidence in the prediction.
|
| 200 |
|
|
|
|
| 195 |
'rOffset': 33}]
|
| 196 |
```
|
| 197 |
|
| 198 |
+
----
|
| 199 |
+
|
| 200 |
+
### Batched predictions
|
| 201 |
+
|
| 202 |
+
```python
|
| 203 |
+
from transformers import AutoTokenizer, pipeline
|
| 204 |
+
|
| 205 |
+
NEL_MODEL_NAME = "impresso-project/nel-mgenre-multilingual"
|
| 206 |
+
|
| 207 |
+
nel_tokenizer = AutoTokenizer.from_pretrained(NEL_MODEL_NAME)
|
| 208 |
+
|
| 209 |
+
nel_pipeline = pipeline(
|
| 210 |
+
"generic-nel",
|
| 211 |
+
model=NEL_MODEL_NAME,
|
| 212 |
+
tokenizer=nel_tokenizer,
|
| 213 |
+
trust_remote_code=True,
|
| 214 |
+
device="cpu",
|
| 215 |
+
)
|
| 216 |
+
|
| 217 |
+
sentences = [
|
| 218 |
+
"Le 0ctobre 1894, [START] Dreyfvs [END] est arrêté à Paris.",
|
| 219 |
+
"En 1912, [START] Giollitti [END] était encore au pouvoir en Italie.",
|
| 220 |
+
"La ville de [START] Lpzbourg [END] est importante dans la région."
|
| 221 |
+
]
|
| 222 |
+
|
| 223 |
+
results = nel_pipeline(sentences)
|
| 224 |
+
|
| 225 |
+
from pprint import pprint
|
| 226 |
+
pprint(results)
|
| 227 |
+
```
|
| 228 |
+
|
| 229 |
The type of the entity is `UNK` because the model was not trained on the entity type. The `confidence_nel` score
|
| 230 |
indicates the model's confidence in the prediction.
|
| 231 |
|