Views
No views yet
Note: This repository contains only the Prefix Tuning adapter, not the complete language model. To use this adapter, you must first load the corresponding SFT model.
BASE_MODEL = "vishnuamarapu/Full-Fine-Tuning-Qwen-2.5-0.5B-instruct-sft"Qwen/Qwen2.5-0.5B-Instruct model directly, as the adapter was trained specifically on the personalized SFT model.pip install -U transformers peft accelerate torch1import torch
2
3from transformers import AutoTokenizer, AutoModelForCausalLM
4from peft import PeftModel
5
6BASE_MODEL = "vishnuamarapu/Full-Fine-Tuning-Qwen-2.5-0.5B-instruct-sft"
7
8PREFIX_ADAPTER = (
9 "vishnuamarapu/"
10 "Full-Fine-Tuning-Qwen-2.5-0.5B-instruct-sft-prefix-tuned"
11)
12
13tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
14
15model = AutoModelForCausalLM.from_pretrained(
16 BASE_MODEL,
17 device_map="auto",
18 torch_dtype="auto"
19)
20
21model = PeftModel.from_pretrained(
22 model,
23 PREFIX_ADAPTER
24)1messages = [
2 {
3 "role": "system",
4 "content": (
5 "You are Vishnu's personal AI assistant. "
6 "Answer questions about Vishnu."
7 )
8 },
9 {
10 "role": "user",
11 "content": "What is your name?"
12 }
13]
14
15text = tokenizer.apply_chat_template(
16 messages,
17 tokenize=False,
18 add_generation_prompt=True
19)
20
21inputs = tokenizer(
22 text,
23 return_tensors="pt"
24).to(model.device)
25
26outputs = model.generate(
27 **inputs,
28 max_new_tokens=80,
29 do_sample=False
30)
31
32response = tokenizer.decode(
33 outputs[0],
34 skip_special_tokens=True
35)
36
37print(response)adapter_config.json
adapter_model.safetensors
chat_template.jinja
tokenizer.json
tokenizer_config.json
training_args.bin