Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3
4# Load base model and tokenizer
5base_model = AutoModelForCausalLM.from_pretrained(
6 "Qwen/Qwen2.5-Coder-3B-Instruct-AWQ",
7 torch_dtype=torch.float16,
8 device_map="auto"
9)
10tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-3B-Instruct-AWQ")
11
12# Load distilled adapter
13model = PeftModel.from_pretrained(base_model, "Vinitha2004/qwen2.5-coder-1.5b-instruct-awq-gguf-merged-temperature2")
14
15# Generate code
16input_text = "Original Code:\ndef add(a, b):\n return a + b\n\nUpdate Snippet:\n// ... existing code ...\ndef add(a: int, b: int) -> int:\n// ... existing code ...\n\nUpdated Code:\n"
17inputs = tokenizer(input_text, return_tensors="pt")
18outputs = model.generate(**inputs, max_new_tokens=100)
19result = tokenizer.decode(outputs[0], skip_special_tokens=True)
20print(result)adapter_config.json: LoRA configurationadapter_model.safetensors: Trained LoRA weights (59MB)