Views
No views yet
modeling_llama.py with this code for it work[!WARNING] WIP + output of this model is gibberish bc cross attn needs training
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3model_name ="pszemraj/ModernBERT2Olmo-large_1b-cfg2"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
6
7ARTICLE_TO_SUMMARIZE = (
8 "PG&E stated it scheduled the blackouts in response to forecasts for high winds "
9 "amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were "
10 "scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow."
11)
12prompt = f"summarize dis botmon: {ARTICLE_TO_SUMMARIZE}"
13inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
14
15# autoregressively generate summary (uses greedy decoding by default)
16generated_ids = model.generate(
17 **inputs,
18 min_new_tokens=10,
19 max_new_tokens=100,
20)
21generated_text = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
22print(generated_text)