Update README.md
Browse files
README.md
CHANGED
@@ -50,8 +50,8 @@ device = "cuda"
|
|
50 |
tokenizer = AutoTokenizer.from_pretrained("Ateeqq/keywords-title-generator", token='your_token')
|
51 |
model = AutoModelForSeq2SeqLM.from_pretrained("Ateeqq/keywords-title-generator", token='your_token').to(device)
|
52 |
|
53 |
-
def generate_title(
|
54 |
-
input_ids = tokenizer(f'generate title: {
|
55 |
outputs = model.generate(
|
56 |
input_ids,
|
57 |
num_beams=5,
|
@@ -65,8 +65,8 @@ def generate_title(question):
|
|
65 |
)
|
66 |
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
67 |
|
68 |
-
|
69 |
-
generate_title(
|
70 |
```
|
71 |
### Output:
|
72 |
```
|
|
|
50 |
tokenizer = AutoTokenizer.from_pretrained("Ateeqq/keywords-title-generator", token='your_token')
|
51 |
model = AutoModelForSeq2SeqLM.from_pretrained("Ateeqq/keywords-title-generator", token='your_token').to(device)
|
52 |
|
53 |
+
def generate_title(keywords):
|
54 |
+
input_ids = tokenizer(f'generate title: {keywords}', return_tensors="pt", padding="longest", truncation=True, max_length=24).input_ids.to(device)
|
55 |
outputs = model.generate(
|
56 |
input_ids,
|
57 |
num_beams=5,
|
|
|
65 |
)
|
66 |
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
67 |
|
68 |
+
keywords = 'book, history, kids'
|
69 |
+
generate_title(keywords)
|
70 |
```
|
71 |
### Output:
|
72 |
```
|