File size: 775 Bytes
11649f5
 
 
 
 
 
7de84a2
80b59d1
 
 
 
 
 
 
 
7de84a2
 
80b59d1
7de84a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
datasets:
- CarperAI/openai_summarize_tldr
metrics:
-rouge1: 0.3156
---

### Example usage

<p>

</p>

```python
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = AutoModelForCausalLM.from_pretrained("KookyGhost/GPT2-small-summarization")

prompt = "Summarize this: Reddit user shares a long story about learning to code with free online resources and eventually landing their first developer job."

inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
outputs = model.generate(
    **inputs,
    max_new_tokens=60,
    do_sample=True,
    top_k=50,
    top_p=0.95,
    temperature=0.7
)

summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(summary)