Views
No views yet
meta-llama/Llama-2-7b-hf for chat / instruction-following tasks.| Path | Description |
|---|---|
adapter_config.json | PEFT / LoRA configuration (rank, alpha, target modules …) |
adapter_model.bin | Serialised adapter weights |
examples/chat/zero_shot/prompt.json | Zero-shot chat prompt template |
examples/chat/few_shot/prompt.json | Few-shot chat prompt template |
1from peft import PeftModel, PeftConfig
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4repo_id = "dongbobo/adapter-checkpoint-lora"
5
6config = PeftConfig.from_pretrained(repo_id)
7tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
8base = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path)
9model = PeftModel.from_pretrained(base, repo_id)
10model.eval()
11
12inputs = tokenizer("Hello, how are you?", return_tensors="pt")
13outputs = model.generate(**inputs, max_new_tokens=128)
14print(tokenizer.decode(outputs[0], skip_special_tokens=True))1{
2 "template": {
3 "system": "You are a helpful, respectful, and honest assistant ...",
4 "user": "{{user_message}}",
5 "assistant": ""
6 }
7}1{
2 "template": {
3 "system": "You are a helpful, respectful, and honest assistant ...",
4 "shots": ["..."],
5 "user": "{{user_message}}",
6 "assistant": ""
7 }
8}adapter_config.json for the full schema):| Parameter | Value |
|---|---|
peft_type | LORA |
task_type | CAUSAL_LM |
r | 8 |
lora_alpha | 16 |
lora_dropout | 0.05 |
target_modules | q_proj, v_proj |
bias | none |