knkarthick/samsum
Viewer • Updated • 16.4k • 5.87k • 42
How to use Wothmag07/mistral-finetuned-samsum 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="Wothmag07/mistral-finetuned-samsum") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Wothmag07/mistral-finetuned-samsum", device_map="auto")This model is a fine-tuned version of mistralai/Mistral-7B-Instruct-v0.3. It has been trained using TRL.
from peft import AutoPeftModelForCausalLM
from transformers import GenerationConfig
from transformers import AutoTokenizer
import torch
dialogue = """
Alex: Hey, are you free this weekend?
Sarah: Yeah, what's up?
Alex: Want to go to that new restaurant downtown?
Sarah: The Italian one? I heard it's really good!
Alex: That's the one. How about Saturday around 7?
Sarah: Perfect! Should I make a reservation?
Alex: Good idea, I'll call them now.
"""
test_prompt = f"""
###Human: Summarize this following dialogue: {dialogue}
###Assistant: """
tokenizer = AutoTokenizer.from_pretrained("Wothmag07/mistral-finetuned-samsum")
model = AutoPeftModelForCausalLM.from_pretrained("Wothmag07/mistral-finetuned-samsum",
low_cpu_mem_usage=True,
return_dict=True,
torch_dtype=torch.bfloat16,
device_map="cuda")
inputs = tokenizer(test_prompt, return_tensors="pt").to("cuda")
output = model.generate(**inputs, do_sample=True, top_p=0.9, temperature=0.8, max_new_tokens=150)
tokenizer.decode(output[0], skip_special_tokens=True)
This model was trained with SFT.
Cite TRL as:
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}
Base model
mistralai/Mistral-7B-v0.3