File size: 1,099 Bytes
352ba4f
 
 
 
 
 
 
37d1fab
352ba4f
 
 
37d1fab
352ba4f
37d1fab
 
 
 
 
 
1173e66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
license: openrail
inference:
  parameters:
    temperature: 0.7
    max_length: 24
language:
- en
library_name: transformers
pipeline_tag: text2text-generation
tags:
- text-generation-inference
widget:
- text: 'generate title: Importance, Dataset, AI'
  example_title: Example 1
- text: 'generate title: Amazon, Product, Business'
  example_title: Example 2
- text: 'generate title: History, Computer, Software'
  example_title: Example 3
---

,,,python
def generate_title(keywords):
    input_ids = tokenizer(keywords, return_tensors="pt", padding="longest", truncation=True, max_length=32).input_ids.to(device)
    outputs = model.generate(
        input_ids,
        num_beams=3,
        num_beam_groups=3,
        num_return_sequences=3,
        repetition_penalty=7.0,
        diversity_penalty=4.0,
        no_repeat_ngram_size=3,
        temperature=0.9,
        max_length=32
    )
    return tokenizer.batch_decode(outputs, skip_special_tokens=True)

keywords = 'This repository contains a fine-tuned model for generating high-quality product descriptions.'
generate_title(keywords)
,,,