File size: 3,248 Bytes
8d87eb5
 
a46f501
 
 
 
 
 
 
 
 
 
 
 
8d87eb5
 
f2af238
8d87eb5
c4c15c3
0f069a3
c4c15c3
0f069a3
 
 
c4c15c3
8d87eb5
c4c15c3
8d87eb5
f63d650
 
 
 
 
 
 
8d87eb5
0f069a3
 
8d87eb5
b5bfb41
a46f501
8d87eb5
0f069a3
 
 
 
 
 
 
 
 
 
 
a46f501
8d87eb5
0f069a3
8d87eb5
 
0f069a3
 
 
8d87eb5
 
 
 
 
 
 
 
 
 
0f069a3
 
 
 
 
 
 
8d87eb5
 
 
 
bf10a6d
9a85ec8
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
license: mit
datasets:
- RCC-MSU/collection3
language:
- ru
metrics:
- accuracy
- f1
- precision
- recall
base_model:
- cointegrated/rubert-tiny2
pipeline_tag: token-classification
---

# 📰 Ner-rubert-tiny-RuNews

A model for **Named Entity Recognition (NER)** in **Russian-language news texts**.

🔍 Based on [**RuBERT-tiny2**](https://huggingface.co/cointegrated/rubert-tiny2) and fine-tuned on the news corpus [**Collection3**](https://huggingface.co/datasets/RCC-MSU/collection3), focusing on texts mentioning **Sberbank**, **Yandex**, and other media and governmental entities.

---

## 💡 What the model can do

It recognizes the following types of named entities:

| Label      | Meaning                                        |
|------------|------------------------------------------------|
| `PER`      | Persons                                        |
| `ORG`      | Organizations                                  |
| `LOC`      | Locations                                      |
| `GEOPOLIT` | Geopolitical entities (countries, regions)     |
| `MEDIA`    | Media outlets and resources                    |

---


## 🛠️ Example usage

```python
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline

label2id = {
    'O': 0,
    'B-GEOPOLIT': 1, 'I-GEOPOLIT': 2,
    'B-MEDIA': 3,    'I-MEDIA': 4,
    'B-LOC': 5,      'I-LOC': 6,
    'B-ORG': 7,      'I-ORG': 8,
    'B-PER': 9,      'I-PER': 10
}
id2label = {v: k for k, v in label2id.items()}

model_id = "r1char9/ner-rubert-tiny-RuNews"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(
    model_id,
    num_labels=len(label2id),
    id2label=id2label,
    label2id=label2id
)

ner_pipeline = pipeline(
    "ner",
    model=model,
    tokenizer=tokenizer,
    aggregation_strategy="simple"
)

text = (
    "Генеральный директор Сбербанка Герман Греф на конференции в Москве заявил, "
    "что сотрудничество с Яндексом в области искусственного интеллекта выходит на новый уровень. "
    "Он также отметил, что правительство Российской Федерации поддерживает развитие цифровой экономики, "
    "особенно в рамках Евразийского экономического союза."
)

results = ner_pipeline(text)

for entity in results:
    print(entity)

# {'entity_group': 'ORG', 'score': 0.951569, 'word': 'Сбербанка', 'start': 21, 'end': 30}
# {'entity_group': 'PER', 'score': 0.9922959, 'word': 'Герман Греф', 'start': 31, 'end': 42}
# {'entity_group': 'LOC', 'score': 0.60198957, 'word': 'Москве', 'start': 60, 'end': 66}
# {'entity_group': 'ORG', 'score': 0.6973838, 'word': 'Яндексом', 'start': 96, 'end': 104}
# {'entity_group': 'GEOPOLIT', 'score': 0.9631994, 'word': 'Российской Федерации', 'start': 203, 'end': 223}
# {'entity_group': 'ORG', 'score': 0.85091865, 'word': 'Евразийского экономического союза.', 'start': 284, 'end': 318}
```