EdinburghNLP/xsum
Viewer • Updated • 227k • 32.2k • 145
How to use Deepu1965/xsum-llama1b-instruct-lora with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "summarization" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# 'pip install "transformers<5.0.0'
from transformers import pipeline
pipe = pipeline("summarization", model="Deepu1965/xsum-llama1b-instruct-lora") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Deepu1965/xsum-llama1b-instruct-lora", dtype="auto")This model is a LoRA fine-tuned version of meta-llama/Llama-3.2-1B-Instruct for extreme summarization on the XSum dataset.
Evaluated on 200 validation samples:
| Metric | Score |
|---|---|
| ROUGE-1 | 0.1912 |
| ROUGE-2 | 0.0548 |
| ROUGE-L | 0.1374 |
| ROUGE-Lsum | 0.1415 |
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
# Load base model
model_name = "meta-llama/Llama-3.2-1B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map="auto"
)
# Load LoRA adapters
model = PeftModel.from_pretrained(model, "Deepu1965/xsum-llama1b-instruct-lora")
# Prepare input
document = "Your news article here..."
prompt = (
"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n"
"You are a helpful assistant that summarizes news articles into one concise sentence.\n"
"<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"
f"Summarize this article in one sentence:\n\n{document}\n"
"<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128)
summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
@misc{llama32-xsum-lora,
author = {Your Name},
title = {LLaMA 3.2 1B XSum LoRA},
year = {2025},
publisher = {HuggingFace},
url = {https://huggingface.co/Deepu1965/xsum-llama1b-instruct-lora}
}