sriksven commited on
Commit
1db59c0
·
verified ·
1 Parent(s): 4ab92f9

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +140 -0
README.md ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-7B-Instruct
4
+ tags:
5
+ - code
6
+ - code-review
7
+ - programming
8
+ - qlora
9
+ - unsloth
10
+ - qwen2.5
11
+ - bug-detection
12
+ datasets:
13
+ - sahil2801/CodeAlpaca-20k
14
+ language:
15
+ - en
16
+ pipeline_tag: text-generation
17
+ library_name: transformers
18
+ model-index:
19
+ - name: CodeLens-7B
20
+ results: []
21
+ ---
22
+
23
+ # CodeLens-7B
24
+
25
+ A fine-tuned **Qwen2.5-7B-Instruct** model specialized for **code review, bug detection, and programming assistance**. It analyzes code snippets, identifies issues, suggests improvements, and writes clean solutions across multiple programming languages.
26
+
27
+ ## Key Details
28
+
29
+ | | |
30
+ |---|---|
31
+ | **Base model** | Qwen/Qwen2.5-7B-Instruct |
32
+ | **Method** | QLoRA (4-bit NF4, rank 16, alpha 16) |
33
+ | **Library** | Unsloth + TRL SFTTrainer |
34
+ | **Dataset** | sahil2801/CodeAlpaca-20k (10K examples) |
35
+ | **Hardware** | NVIDIA RTX A5000 (24GB VRAM) on RunPod |
36
+ | **Training time** | ~2.65 hours (500 steps) |
37
+ | **Final loss** | 0.450 |
38
+ | **Parameters trained** | 40.4M of 7.66B (0.53%) |
39
+ | **Format** | ChatML |
40
+ | **Output** | Merged 16-bit safetensors |
41
+
42
+ ## Dataset
43
+
44
+ Trained on 10,000 examples from [sahil2801/CodeAlpaca-20k](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k), a code instruction-following dataset covering code generation, debugging, explanation, and review tasks across Python, JavaScript, Java, C, SQL, and more.
45
+
46
+ ## Usage
47
+
48
+ ### Transformers
49
+
50
+ ```python
51
+ from transformers import AutoModelForCausalLM, AutoTokenizer
52
+
53
+ model = AutoModelForCausalLM.from_pretrained("sriksven/CodeLens-7B")
54
+ tokenizer = AutoTokenizer.from_pretrained("sriksven/CodeLens-7B")
55
+
56
+ messages = [
57
+ {
58
+ "role": "system",
59
+ "content": "You are an expert code reviewer and programmer. Analyze code, find bugs, suggest improvements, and write clean efficient solutions.",
60
+ },
61
+ {
62
+ "role": "user",
63
+ "content": "Review this Python function for bugs and improvements:\n\ndef find_duplicates(lst):\n seen = []\n dupes = []\n for i in lst:\n if i in seen:\n dupes.append(i)\n seen.append(i)\n return dupes",
64
+ },
65
+ ]
66
+
67
+ inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
68
+ outputs = model.generate(inputs, max_new_tokens=512)
69
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
70
+ ```
71
+
72
+ ### Unsloth (faster inference)
73
+
74
+ ```python
75
+ from unsloth import FastLanguageModel
76
+
77
+ model, tokenizer = FastLanguageModel.from_pretrained(
78
+ model_name="sriksven/CodeLens-7B",
79
+ max_seq_length=2048,
80
+ load_in_4bit=True,
81
+ )
82
+ FastLanguageModel.for_inference(model)
83
+ ```
84
+
85
+ ## Capabilities
86
+
87
+ - **Code review** — analyze code for bugs, anti-patterns, and style issues
88
+ - **Bug detection** — identify logical errors, off-by-one mistakes, edge cases
89
+ - **Code generation** — write functions, classes, and scripts from descriptions
90
+ - **Code explanation** — explain what a piece of code does step by step
91
+ - **Refactoring suggestions** — propose cleaner, more efficient alternatives
92
+ - **Multi-language** — Python, JavaScript, Java, C/C++, SQL, HTML/CSS, and more
93
+
94
+ ## Intended Use
95
+
96
+ - Local code review assistant
97
+ - Programming tutoring and education
98
+ - Code quality tooling in CI/CD pipelines
99
+ - Prototyping developer tools with local LLMs
100
+
101
+ ## Limitations
102
+
103
+ - Trained on instruction-following code data, not real code review conversations from PRs
104
+ - May not catch security vulnerabilities that require deep context
105
+ - Code suggestions should be tested before use in production
106
+ - Best with shorter code snippets (functions/classes) rather than full files
107
+ - No execution or testing capability — suggestions are pattern-based
108
+
109
+ ## Training Metrics
110
+
111
+ Loss decreased steadily from 2.17 to 0.27 over 500 steps (~13 epochs), indicating strong learning on the code instruction data.
112
+
113
+ | Step | Loss | Epoch |
114
+ |---|---|---|
115
+ | 10 | 2.168 | 0.26 |
116
+ | 100 | 0.503 | 2.05 |
117
+ | 250 | 0.430 | 6.41 |
118
+ | 400 | 0.310 | 10.26 |
119
+ | 500 | 0.278 | 12.83 |
120
+
121
+ ## Training Infrastructure
122
+
123
+ | | |
124
+ |---|---|
125
+ | **GPU** | NVIDIA RTX A5000 24GB |
126
+ | **Cloud** | RunPod ($0.27/hr) |
127
+ | **Framework** | Unsloth 2026.5.2 + TRL + Transformers 5.5.0 |
128
+ | **Precision** | BF16 training, 4-bit NF4 base quantization |
129
+ | **Optimizer** | AdamW 8-bit |
130
+ | **Learning rate** | 2e-4, linear decay |
131
+ | **Batch size** | 16 effective (4 per device × 4 accumulation) |
132
+ | **Packing** | Enabled |
133
+
134
+ ## Source Code
135
+
136
+ Training scripts: [github.com/sriksven/LLM-FineTune-Suite](https://github.com/sriksven/LLM-FineTune-Suite)
137
+
138
+ ## License
139
+
140
+ Apache 2.0