Downloads · 30 days
31
7% of all-time downloads
philschmid/shepherd-2-hf-int4
shepherd-2-hf-int4 is a text generation model from philschmid. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as llama2.
The following bitsandbytes quantization config was used during training: - loadin8bit: False - loadin4bit: True - llmint8threshold: 6.0 - llmint8skipmodules: None - llmint8enablefp32cpuoffload: False - llmint8hasfp16w…
Downloads · 30 days
31
7% of all-time downloads
All-time downloads
419
Public
Repo size
27 GB
Likes
1
Public
Click a slice to open those files.
.bin13.5 GB · 100%
From the Hugging Face model README
from datasets import load_dataset
from random import randrange
import torch
from peft import AutoPeftModelForCausalLM
from transformers import AutoTokenizer
output_dir = "philschmid/shepherd-2-hf-int4"
# load base LLM model and tokenizer
model = AutoPeftModelForCausalLM.from_pretrained(
output_dir,
low_cpu_mem_usage=True,
torch_dtype=torch.float16,
load_in_4bit=True,
)
tokenizer = AutoTokenizer.from_pretrained(output_dir)
# Load dataset from the hub and get a sample
dataset = load_dataset("philschmid/meta-shepherd-human-data", split="train")
sample = dataset[randrange(len(dataset))]
prompt = f"""### Question: {sample['question']}
### Answer:
{sample['answer']}
### Feedback:
"""
input_ids = tokenizer(prompt, return_tensors="pt", truncation=True).input_ids.cuda()
# with torch.inference_mode():
outputs = model.generate(input_ids=input_ids, max_new_tokens=100, do_sample=True, top_p=0.9,temperature=0.9)
print(prompt[:-14])
print("---"*35)
print(f"### Generated Feedback:\n{tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0][len(prompt):]}")
print(f"### Ground truth Feedback:\n{sample['feedback']}")
The following bitsandbytes quantization config was used during training: