Downloads · 30 days
38
1% of all-time downloads
ktrapeznikov/gpt2-medium-topic-news-v2
gpt2-medium-topic-news-v2 is a text generation model from ktrapeznikov. Use it when you need the model to write or continue text. It is set up for transformers.
GPT2-medium fine tuned on a largish news corpus conditioned on a topic, source, title
Downloads · 30 days
38
1% of all-time downloads
All-time downloads
6.9K
Public
Repo size
4.3 GB
Likes
1
Public
Click a slice to open those files.
.bin1.4 GB · 50%
From the Hugging Face model README
GPT2-medium fine tuned on a largish news corpus conditioned on a topic, source, title
To generate a news article text conditioned on a topic, source, title or some subsets, prompt model with:
f"topic {topic} source"
f"topic {topic} source {source} title"
f"topic {topic} source {source} title {title} body"
Try the following tags for topic: climate, weather, vaccination.
Zero shot generation works pretty well as long as topic is a single word and not too specific.
device = "cuda:0"
tokenizer = AutoTokenizer.from_pretrained("ktrapeznikov/gpt2-medium-topic-small-set")
model = AutoModelWithLMHead.from_pretrained("ktrapeznikov/gpt2-medium-topic-small-set")
model.to(device)
topic = "climate"
prompt = tokenizer(f"topic {topics} source straitstimes title", return_tensors="pt")
out = model.generate(prompt["input_ids"].to(device), do_sample=True,max_length=500, early_stopping=True, top_p=.9)
print(tokenizer.decode(out[0].cpu(), skip_special_tokens=True))