RedHitMark commited on
Commit
c9a8f43
·
verified ·
1 Parent(s): 049ab2d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -1
README.md CHANGED
@@ -5,4 +5,22 @@ language:
5
  base_model:
6
  - GroNLP/gpt2-small-italian
7
  pipeline_tag: text-generation
8
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  base_model:
6
  - GroNLP/gpt2-small-italian
7
  pipeline_tag: text-generation
8
+ ---
9
+
10
+ ```
11
+ from transformers import AutoTokenizer, AutoModelForCausalLM
12
+
13
+ tokenizer = AutoTokenizer.from_pretrained("VerbACxSS/sempl-it-gpt2-small-italian", model_max_length=1024)
14
+ model = AutoModelForCausalLM.from_pretrained("VerbACxSS/sempl-it-gpt2-small-italian")
15
+
16
+ model.eval()
17
+
18
+ text_to_simplify = 'Nella fattispecie, questo documento è di natura prescrittiva'
19
+ prompt = f'### [Input]:\n{text_to_simplify}\n\n###[Output]:\n'
20
+
21
+ x = tokenizer(prompt, max_length=1024, truncation=True, padding=True, return_tensors='pt').input_ids
22
+ y = model.generate(x, max_length=1024)[0]
23
+ y_dec = tokenizer.decode(y, max_length=1024, truncation=True)
24
+ output = y_dec.split('###[Output]:\n')[1].split('<|endoftext|>')[0].strip()
25
+ print(output)
26
+ ```