Downloads · 30 days
6
1% of all-time downloads
sooolee/bart-large-cnn-samsum-lora
bart-large-cnn-samsum-lora is a summarization model from sooolee. Use it when you need a shorter version of a longer text. It is set up for adapter-transformers. The card lists the license as apache-2.0.
This model is a further fine-tuned version of facebook/bart-large-cnn on the samsum dataset.
Downloads · 30 days
6
1% of all-time downloads
All-time downloads
591
Public
Repo size
4.8 MB
Likes
1
Public
Click a slice to open those files.
.bin4.8 MB · 59%
From the Hugging Face model README
This model is a further fine-tuned version of facebook/bart-large-cnn on the samsum dataset.
The base model bart-large-cnn is a fine-tuned verstion of BART model on the CNN Daily Mail dataset.
Check out sooolee/flan-t5-base-cnn-samsum-lora the model fine-tuned for the same purpose.
Summarizes transcripts such as YouTube transcripts.
The following hyperparameters were used during training:
Note 'max_new_tokens=60' is used in the example below to control the summary size. BART model has max generation length = 142 (default) and min generation length = 56.
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
# Load peft config for pre-trained checkpoint etc.
peft_model_id = "sooolee/bart-large-cnn-finetuned-samsum-lora"
config = PeftConfig.from_pretrained(peft_model_id)
# load base LLM model and tokenizer
model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path, device_map='auto')
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
# Load the Lora model
model = PeftModel.from_pretrained(model, peft_model_id, device_map='auto')
# Tokenize the text inputs
texts = "<e.g. Transcript>"
inputs = tokenizer(texts, return_tensors="pt", padding=True, ) # truncation=True
# Make inferences
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
with torch.no_grad():
output = self.model.generate(input_ids=inputs["input_ids"].to(device), max_new_tokens=60, do_sample=True, top_p=0.9)
summary = self.tokenizer.batch_decode(output.detach().cpu().numpy(), skip_special_tokens=True)
summary