NLP-Community commited on
Commit
1173e66
1 Parent(s): 91311e2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -1
README.md CHANGED
@@ -17,4 +17,24 @@ widget:
17
  example_title: Example 2
18
  - text: 'generate title: History, Computer, Software'
19
  example_title: Example 3
20
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  example_title: Example 2
18
  - text: 'generate title: History, Computer, Software'
19
  example_title: Example 3
20
+ ---
21
+
22
+ ,,,python
23
+ def generate_title(keywords):
24
+ input_ids = tokenizer(keywords, return_tensors="pt", padding="longest", truncation=True, max_length=32).input_ids.to(device)
25
+ outputs = model.generate(
26
+ input_ids,
27
+ num_beams=3,
28
+ num_beam_groups=3,
29
+ num_return_sequences=3,
30
+ repetition_penalty=7.0,
31
+ diversity_penalty=4.0,
32
+ no_repeat_ngram_size=3,
33
+ temperature=0.9,
34
+ max_length=32
35
+ )
36
+ return tokenizer.batch_decode(outputs, skip_special_tokens=True)
37
+
38
+ keywords = 'This repository contains a fine-tuned model for generating high-quality product descriptions.'
39
+ generate_title(keywords)
40
+ ,,,