Downloads · 30 days
6
2% of all-time downloads
SGaleshchuk/Llama-2-13b-summarization_uk_dpo
Llama-2-13b-summarization_uk_dpo is a summarization model from SGaleshchuk. Use it when you need a shorter version of a longer text. It is set up for peft. The card lists the license as apache-2.0.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
6
2% of all-time downloads
All-time downloads
303
Public
Repo size
2.3 GB
Likes
1
Public
Click a slice to open those files.
.safetensors105 MB · 98%
From the Hugging Face model README
This model is a fine-tuned version of SGaleshchuk/Llama-2-13b-hf_uk_rank-32_ft on summarization dataset.
# tested with colab+A100 GPU
!pip install -q -U peft transformers==4.30
!pip install flash-attn --no-build-isolation
!pip install einops bitsandbytes accelerate
# unpatch flash attention
import torch
from peft import AutoPeftModelForCausalLM
from transformers import AutoTokenizer
model_id = "SGaleshchuk/Llama-2-13b-summarization_uk_dpo"
# load base LLM model and tokenizer
model = AutoPeftModelForCausalLM.from_pretrained(
model_id,
low_cpu_mem_usage=True,
torch_dtype=torch.float16,
load_in_4bit=True)
tokenizer = AutoTokenizer.from_pretrained(model_id)
def prepare_instruction(text):
prompt = """The article to summarize in maximum 100 words:{text}. Summary:""" # adapt to your needs
return prompt.format(
text=text,
)
def summarization(text):
instruction = prepare_instruction(text)
input_ids = tokenizer(instruction, return_tensors="pt", truncation=True).input_ids.cuda()
with torch.inference_mode():
outputs = model.generate(
input_ids=input_ids,
max_new_tokens=128,
do_sample=True,
top_p=0.9,
temperature=1e-2,
)
result = tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0]
result = result[len(instruction) :]
print(result)
return result
text = """your text here to summarize"
result = summarization(text)
The following hyperparameters were used during training:
Read more in our paper: https://aclanthology.org/2024.unlp-1.15/