Views
No views yet
| Property | Value |
|---|---|
| Base model | codellama/CodeLlama-7b-hf |
| Fine-tuning method | QLoRA (LoRA + 4-bit NF4 quantization) |
| LoRA rank | 8 |
| LoRA alpha | 16 |
| LoRA dropout | 0.1 |
| Target modules | q_proj, v_proj |
| Training dataset | CodeSearchNet Python (500-sample subset) |
| Training hardware | Google Colab T4 (16GB VRAM) |
| Epochs | 3 |
| Optimizer | AdamW |
| Learning rate | 2e-4 |
| Effective batch size | 16 (4 × 4 gradient accumulation) |
evaluate_functional_correctness scorer with 10 samples per problem.| Metric | Paper (full dataset, BF16) | This adapter (500 samples, QLoRA) |
|---|---|---|
| pass@1 | 37.8% | 26.83% |
| pass@5 | 58.4% | 35.91% |
| pass@10 | 66.1% | 38.41% |
The gap relative to the paper is expected: this adapter was trained on a 500-sample subset due to Colab free-tier constraints, and uses 4-bit quantization instead of full BF16 precision.
sedanurkilic/Python-Code-Completion-CodeLlama-7B- codebase. Each CodeSearchNet sample was formatted as:[INST] {docstring} [/INST]
{function_body}1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
3from peft import PeftModel
4
5bnb_config = BitsAndBytesConfig(
6 load_in_4bit=True,
7 bnb_4bit_quant_type="nf4",
8 bnb_4bit_use_double_quant=True,
9 bnb_4bit_compute_dtype=torch.bfloat16,
10)
11
12tokenizer = AutoTokenizer.from_pretrained("sedaklc/codellama-7b-qlora-humaneval")
13tokenizer.pad_token = tokenizer.eos_token
14
15base_model = AutoModelForCausalLM.from_pretrained(
16 "codellama/CodeLlama-7b-hf",
17 quantization_config=bnb_config,
18 device_map="auto",
19 torch_dtype=torch.bfloat16,
20)
21model = PeftModel.from_pretrained(base_model, "sedaklc/codellama-7b-qlora-humaneval")
22model.eval()
23
24prompt = "[INST] Return the n-th Fibonacci number. [/INST]\n"
25inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
26
27with torch.no_grad():
28 output = model.generate(
29 **inputs,
30 max_new_tokens=256,
31 temperature=0.2,
32 top_p=0.95,
33 do_sample=True,
34 pad_token_id=tokenizer.eos_token_id,
35 )
36
37new_tokens = output[0][inputs["input_ids"].shape[1]:]
38print(tokenizer.decode(new_tokens, skip_special_tokens=True))