Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,48 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- ru
|
4 |
+
tags:
|
5 |
+
- causal-lm
|
6 |
+
- text-generation
|
7 |
+
license:
|
8 |
+
- apache-2.0
|
9 |
+
inference: false
|
10 |
+
widget:
|
11 |
+
- text: "Как обрести просветление?<s>"
|
12 |
+
example_title: "Википедия"
|
13 |
---
|
14 |
+
# RuGPT3Medium-tathagata
|
15 |
+
## Model description
|
16 |
+
This is the model for text generation for Russian based on [rugpt3medium_based_on_gpt2](https://huggingface.co/sberbank-ai/rugpt3medium_based_on_gpt2).
|
17 |
+
## Intended uses & limitations
|
18 |
+
#### How to use
|
19 |
+
|
20 |
+
```python
|
21 |
+
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
22 |
+
import torch
|
23 |
+
DEVICE = torch.device("cuda:0")
|
24 |
+
|
25 |
+
model_name_or_path = "sberbank-ai/rugpt3medium_based_on_gpt2"
|
26 |
+
tokenizer = GPT2Tokenizer.from_pretrained(model_name_or_path)
|
27 |
+
model = GPT2LMHeadModel.from_pretrained('model').to(DEVICE)
|
28 |
+
text = "В чем смысл жизни?\n"
|
29 |
+
input_ids = tokenizer.encode(text, return_tensors="pt").to(DEVICE)
|
30 |
+
model.eval()
|
31 |
+
with torch.no_grad():
|
32 |
+
out = model.generate(input_ids,
|
33 |
+
do_sample=True,
|
34 |
+
num_beams=4,
|
35 |
+
temperature=1.1,
|
36 |
+
top_p=0.9,
|
37 |
+
top_k=50,
|
38 |
+
max_length=250,
|
39 |
+
min_length=50,
|
40 |
+
early_stopping=True,
|
41 |
+
num_return_sequences=3,
|
42 |
+
no_repeat_ngram_size=3
|
43 |
+
)
|
44 |
+
|
45 |
+
generated_text = list(map(tokenizer.decode, out))[0]
|
46 |
+
print()
|
47 |
+
print(generated_text)
|
48 |
+
```
|