Views
No views yet
1from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
2
3# Load model and tokenizer
4tokenizer = AutoTokenizer.from_pretrained('bigscience/bloomz')
5model = AutoModelForSequenceClassification.from_pretrained('tum-nlp/neural-news-generator-bloomz-7b1-en')
6
7# Create the pipeline for neural news generation and set the repetition penalty >1.1 to punish repetition.
8generator = pipeline('text-generation',
9 model=model,
10 tokenizer=tokenizer,
11 repetition_penalty=1.2)
12
13# Define the prompt
14prompt = "Headline: UK headline inflation rate drops sharply to 6.8% in July, in line with expectations Article: LONDON U.K. headline inflation cooled sharply in July to [EOP]"
15
16# Generate
17generator(prompt, max_length=1000, num_return_sequences=1)
18