PKU-Alignment/PKU-SafeRLHF
Viewer • Updated • 164k • 14.6k • 185
How to use anonymousML123/llama3-8b-pku-SFT-Instruct-Baseline-NoInstruct with Transformers:
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("anonymousML123/llama3-8b-pku-SFT-Instruct-Baseline-NoInstruct", dtype="auto")Fine-tuned Llama-3.1-8B using SFT (Supervised Fine-Tuning on chosen responses only) on the PKU-SafeRLHF dataset for improved safety alignment.
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.1-8B",
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "anonymousML123/llama3-8b-pku-SFT-Instruct-Baseline-NoInstruct")
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("anonymousML123/llama3-8b-pku-SFT-Instruct-Baseline-NoInstruct")
# Generate
messages = [{"role": "user", "content": "Explain quantum computing"}]
input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to("cuda")
with torch.no_grad():
outputs = model.generate(input_ids, max_new_tokens=128, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Llama 3.1 Community License (same as base model)
@misc{llama3_8b_pku_SFT_Instruct_Baseline_NoInstruct_2024,
author = {User},
title = {llama3-8b-pku-SFT-Instruct-Baseline-NoInstruct},
year = {2024},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/anonymousML123/llama3-8b-pku-SFT-Instruct-Baseline-NoInstruct}}
}
Base model
meta-llama/Llama-3.1-8B