cointegrated commited on
Commit
a2c22aa
·
1 Parent(s): d9e083d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +78 -0
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+
4
+ ---
5
+ language: ["ru", "en"]
6
+ tags:
7
+ - russian
8
+ license: mit
9
+ ---
10
+ This is a smaller version of the [google/mt5-base](https://huggingface.co/google/mt5-base) with only some Rusian and English embeddings left.
11
+
12
+ The model has been fine-tuned for several tasks with sentences or short paragraphs:
13
+ * translation (`translate ru-en` and `translate en-ru`)
14
+ * Paraphrasing (`paraphrase`)
15
+ * Filling gaps in a text (`fill`). The gaps can be denoted as `___` or `_3_`, where `3` is the approximate number of words that should be inserted.
16
+ * Restoring the text from a noisy bag of words (`assemble`)
17
+ * Simplification of texts (`simplify`)
18
+ * Dialogue response generation (`reply` based on fiction and `answer` based on online forums)
19
+ * Open-book question answering (`comprehend`)
20
+ * Asking questions about a text (`ask`)
21
+ * News title generation (`headline`)
22
+
23
+ For each task, the task name is joined with the input text by the ` | ` separator.
24
+
25
+ The model can be run with the following code:
26
+ ```
27
+ # !pip install transformers sentencepiece
28
+ import torch
29
+ from transformers import T5ForConditionalGeneration, T5Tokenizer
30
+ tokenizer = T5Tokenizer.from_pretrained("cointegrated/rut5-base-multitask")
31
+ model = T5ForConditionalGeneration.from_pretrained("cointegrated/rut5-base-multitask")
32
+
33
+ def generate(text, **kwargs):
34
+ inputs = tokenizer(text, return_tensors='pt')
35
+ with torch.no_grad():
36
+ hypotheses = model.generate(**inputs, num_beams=5, **kwargs)
37
+ return tokenizer.decode(hypotheses[0], skip_special_tokens=True)
38
+ ```
39
+
40
+ The model can be applied to each of the pretraining tasks:
41
+
42
+ ```
43
+ print(generate('translate ru-en | Каждый охотник желает знать, где сидит фазан.'))
44
+ # Each hunter wants to know, where he is.
45
+
46
+ print(generate('paraphrase | Каждый охотник желает знать, где сидит фазан.',
47
+ encoder_no_repeat_ngram_size=1, repetition_penalty=0.5, no_repeat_ngram_size=1))
48
+ # В любом случае каждый рыбак мечтает познакомиться со своей фермой
49
+
50
+ print(generate('fill | Каждый охотник _3_, где сидит фазан.'))
51
+ # смотрит на озеро
52
+
53
+ print(generate('assemble | охотник каждый знать фазан сидит'))
54
+ # Каждый охотник знает, что фазан сидит.
55
+
56
+ print(generate('simplify | Местным продуктом-специалитетом с защищённым географическим наименованием по происхождению считается люнебургский степной барашек.', max_length=32))
57
+ # Местным продуктом-специалитетом считается люнебургский степной барашек.
58
+
59
+ print(generate('reply | Помогите мне закадрить девушку'))
60
+ # Что я хочу?
61
+
62
+ print(generate('answer | Помогите мне закадрить девушку'))
63
+ # я хочу познакомиться с девушкой!!!!!!!!
64
+
65
+ print(generate("comprehend | На фоне земельного конфликта между владельцами овец и ранчеро разворачивается история любви овцевода Моргана Лейна, "
66
+ "прибывшего в США из Австралии, и Марии Синглетон, владелицы богатого скотоводческого ранчо. Вопрос: откуда приехал Морган?"))
67
+ # из Австралии
68
+
69
+ print(generate("ask | На фоне земельного конфликта между владельцами овец и ранчеро разворачивается история любви овцевода Моргана Лейна, "
70
+ "прибывшего в США из Австралии, и Марии Синглетон, владелицы богатого скотоводческого ранчо.", max_length=32))
71
+ # Что разворачивается на фоне земельного конфликта между владельцами овец и ранчеро?
72
+
73
+ print(generate("headline | На фоне земельного конфликта между владельцами овец и ранчеро разворачивается история любви овцевода Моргана Лейна, "
74
+ "прибывшего в США из Австралии, и Марии Синглетон, владелицы богатого скотоводческого ранчо.", max_length=32))
75
+ # На фоне земельного конфликта разворачивается история любви овцевода Моргана Лейна и Марии Синглетон
76
+ ```
77
+
78
+ However, it is strongly recommended that you fine tune the model for your own task.