Adapter Checkpoint β€” LoRA on Llama-2-7b

This repository contains a LoRA adapter checkpoint fine-tuned on top of meta-llama/Llama-2-7b-hf using PEFT.


Repository layout

.
β”œβ”€β”€ adapter_config.json          # PEFT / LoRA hyper-parameters
β”œβ”€β”€ adapter_model.bin            # Trained adapter weights
β”œβ”€β”€ README.md                    # This file
└── examples/
    └── chat/
        β”œβ”€β”€ zero_shot/
        β”‚   └── prompt.json      # Zero-shot chat prompt template
        └── few_shot/
            └── prompt.json      # Few-shot chat prompt template

Prompt templates

Two ready-to-use prompt templates are included for chat inference:

Strategy Path Description
Zero-shot examples/chat/zero_shot/prompt.json Single-turn; no demonstrations β€” the model relies on its instruction-following capability.
Few-shot examples/chat/few_shot/prompt.json Prepends three (user, assistant) demonstration turns before the live query.

Quick start

from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
import json, pathlib

# Load adapter config and base model
config = PeftConfig.from_pretrained("dongbobo/adapter-checkpoint")
base   = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path)
model  = PeftModel.from_pretrained(base, "dongbobo/adapter-checkpoint")
tok    = AutoTokenizer.from_pretrained(config.base_model_name_or_path)

# Load a prompt template
template = json.loads(
    pathlib.Path("examples/chat/zero_shot/prompt.json").read_text()
)

# Build prompt
user_msg = "Explain the concept of attention in transformers."
prompt   = (
    f"<s>[INST] <<SYS>>\n{template['template']['system']}\n<</SYS>>\n\n"
    f"{user_msg} [/INST]"
)

inputs  = tok(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=256)
print(tok.decode(outputs[0], skip_special_tokens=True))

Adapter hyper-parameters

Parameter Value
PEFT type LORA
Task type CAUSAL_LM
Rank (r) 16
LoRA alpha 32
LoRA dropout 0.05
Target modules q_proj, v_proj
Bias none

License

Released under the Apache 2.0 license.
The base model (meta-llama/Llama-2-7b-hf) is subject to its own Llama 2 Community License.

Downloads last month
101
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for dongbobo/adapter-checkpoint

Adapter
(2339)
this model