Token Classification
Transformers
Safetensors
French
bert
newsagency
ner
historical
impresso
multilingual
Instructions to use impresso-project/ner-newsagency-bert-fr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use impresso-project/ner-newsagency-bert-fr with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="impresso-project/ner-newsagency-bert-fr")# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("impresso-project/ner-newsagency-bert-fr") model = AutoModelForTokenClassification.from_pretrained("impresso-project/ner-newsagency-bert-fr") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- config.json +9 -0
- newsagency_ner.py +4 -1
config.json
CHANGED
|
@@ -5,6 +5,15 @@
|
|
| 5 |
],
|
| 6 |
"attention_probs_dropout_prob": 0.1,
|
| 7 |
"classifier_dropout": null,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"gradient_checkpointing": false,
|
| 9 |
"hidden_act": "gelu",
|
| 10 |
"hidden_dropout_prob": 0.1,
|
|
|
|
| 5 |
],
|
| 6 |
"attention_probs_dropout_prob": 0.1,
|
| 7 |
"classifier_dropout": null,
|
| 8 |
+
"custom_pipelines": {
|
| 9 |
+
"newsagency-ner": {
|
| 10 |
+
"impl": "newsagency_ner.NewsAgencyModelPipeline",
|
| 11 |
+
"pt": [
|
| 12 |
+
"AutoModelForTokenClassification"
|
| 13 |
+
],
|
| 14 |
+
"tf": []
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
"gradient_checkpointing": false,
|
| 18 |
"hidden_act": "gelu",
|
| 19 |
"hidden_dropout_prob": 0.1,
|
newsagency_ner.py
CHANGED
|
@@ -167,8 +167,11 @@ class NewsAgencyModelPipeline(Pipeline):
|
|
| 167 |
input_ids = torch.tensor([inputs["input_ids"]], dtype=torch.long).to(
|
| 168 |
self.model.device
|
| 169 |
)
|
|
|
|
|
|
|
|
|
|
| 170 |
with torch.no_grad():
|
| 171 |
-
outputs = self.model(input_ids)
|
| 172 |
return outputs, text_sentence
|
| 173 |
|
| 174 |
def postprocess(self, outputs, **kwargs):
|
|
|
|
| 167 |
input_ids = torch.tensor([inputs["input_ids"]], dtype=torch.long).to(
|
| 168 |
self.model.device
|
| 169 |
)
|
| 170 |
+
attention_mask = torch.tensor([inputs["attention_mask"]], dtype=torch.long).to(
|
| 171 |
+
self.model.device
|
| 172 |
+
)
|
| 173 |
with torch.no_grad():
|
| 174 |
+
outputs = self.model(input_ids, attention_mask)
|
| 175 |
return outputs, text_sentence
|
| 176 |
|
| 177 |
def postprocess(self, outputs, **kwargs):
|