Vladniag commited on
Commit
a188f8d
·
verified ·
1 Parent(s): 682b098

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -1
README.md CHANGED
@@ -3,4 +3,49 @@ license: mit
3
  language:
4
  - ru
5
  - en
6
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  language:
4
  - ru
5
  - en
6
+ ---
7
+ This Seq2Seq transformer model is designed to translate text, compose headings, generate questions and summarizations. Its size is only 80 million parameters, which allows you to work with good speed on equipment with low computing power.
8
+
9
+ Supported languages: Russian and English.
10
+ Maximum sequence length: 256 tokens.
11
+
12
+ For work, files in the main directory are sufficient.
13
+ q8 is a quantized model of ctranslate2 in INT8. Use it if you want to save disk space and RAM.
14
+ OpenNMT is a averaged OpenNMT model. It can be used in cases where the capabilities of the ctranslate are not enough.
15
+
16
+ Example of use
17
+ You can check the features on the demo site:
18
+ https://tolmacher.wia.su/
19
+ The items "write an article" and "rewrite" an article are implemented in tandem with the Queen 05B model, the rest are performed entirely by the Requestor model.
20
+
21
+ To work on your computer
22
+ 1. Install the Python packages
23
+ pip install ctranslate2 OpenNMT-py==2.* sentencepiece
24
+
25
+ 2. Download model in some dirrectory
26
+
27
+ 3. Use with the Python program
28
+ import ctranslate2
29
+ import sentencepiece as spm
30
+ def requestor0(block, prompt="Summarize", ender="0o0"):
31
+ block+=ender
32
+ tokens = sp.encode(block, out_type=str)
33
+ input_text = "<s><###System:>" + prompt + ": "
34
+ input_tokens = sp.encode(input_text, out_type=str)
35
+ input_tokens.extend(tokens)
36
+ results = translator.translate_batch([input_tokens])
37
+ output_tokens = results[0].hypotheses[0]
38
+ output_text = sp.decode(output_tokens)
39
+ output_text=output_text.replace("<s><###Requestor:>", "").replace(" ⁇ ", "").strip()
40
+ output_text=output_text.split("0o0")[0]
41
+ return output_text
42
+
43
+ sp = spm.SentencePieceProcessor(model_file='140/sentencepiece.model') #140 - the directory to put the model files in
44
+ translator = ctranslate2.Translator('140/', device="cuda")
45
+ text="""The first-ever published research on Tinshemet Cave reveals that Neanderthals and Homo sapiens in the mid-Middle Paleolithic Levant not only coexisted but actively interacted, sharing technology, lifestyles, and burial customs. These interactions fostered cultural exchange, social complexity, and behavioral innovations, such as formal burial practices and the symbolic use of ocher for decoration."""
46
+ text=text.replace("\n","")
47
+ rtext=requestor0(text,"Summarize")
48
+ print(rtext+"\n")
49
+
50
+ The prompta on which the model was trained:
51
+ "Translate to english"; "Translate to russian"; "Generate question", "Make a title" "What is the topic of this text?", "Summarize", "Summarize briefly", "Make a step-by-step plan for this text" and russian analogs for this commnads. However, some combinations that were not present in the training sample also work. For example, "Translate briefly" can give a translation about twice as compact as the original text.