File size: 2,117 Bytes
dd96e9e
 
cce806f
 
 
 
 
 
 
 
 
 
 
dd96e9e
cce806f
 
 
 
 
 
 
887c97f
 
bcb833c
887c97f
 
cce806f
 
 
 
 
 
13eed6f
cce806f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
language:
- ru
metrics:
- f1
library_name: transformers
tags:
- russian
- conversation
- chats
- embeddings
- coherence
---
# Model Card

This model is trained to predict whether two given messages from some group chat with many members can have a `reply_to` relationship.

# Training details

It's based on [Conversational RuBERT](https://docs.deeppavlov.ai/en/master/features/models/bert.html) (cased, 12-layer, 768-hidden, 12-heads, 180M parameters) that was trained on several social media datasets. We fine-tuned it with the data from several Telegram chats. The positive `reply_to` examples were obtained by natural user annotation. The negative ones were obtained by shuffling the messages. 
The task perfectly aligns with the Next Sentence Prediction task, so the fine-tuning was done in that manner. 

It achieves the 0.83 F1 score on the gold test set from our [reply recovery dataset](https://data.mendeley.com/datasets/xm86yszck2).

See the [paper](https://www.dialog-21.ru/media/5871/buyanoviplusetal046.pdf) for more details.

# Usage

**Note:** if two messages have `reply_to` relationship, then **they have "zero" label**. This is because of the NSP formulation.
```python
from transformers import AutoTokenizer, BertForNextSentencePrediction
tokenizer = AutoTokenizer.from_pretrained("astromis/rubert_reply_recovery", )
model = BertForNextSentencePrediction.from_pretrained("rubert_reply_recovery", )

inputs = tokenizer(['Где можно получить СНИЛС?', 'Я тут уже много лет'], ["Можете в МФЦ", "Куда отправить это письмо?"], return_tensors='pt',
                                truncation=True, max_length=512, padding = 'max_length',)
output = model(**inputs)
print(output.logits.argmax(dim=1))
# tensor([0, 1])
```


# Citation

```bibtex
@article{Buyanov2023WhoIA,
  title={Who is answering to whom? Modeling reply-to relationships in Russian asynchronous chats},
  author={Igor Buyanov and Darya Yaskova and Ilya Sochenkov},
  journal={Computational Linguistics and Intellectual Technologies},
  year={2023}
}
```