Edit model card
YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/models-cards#model-card-metadata)


  • en thumbnail: widget:
  • text: "topic climate source washington post title "


Model description

GPT2-medium fine tuned on a largish news corpus conditioned on a topic, source, title

Intended uses & limitations

How to use

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")
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))
Downloads last month
Hosted inference API
Text Generation
This model can be loaded on the Inference API on-demand.