Trained on 10,000 examples from
sahil2801/CodeAlpaca-20k, a code instruction-following dataset covering code generation, debugging, explanation, and review tasks across Python, JavaScript, Java, C, SQL, and more.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained("sriksven/CodeLens-7B")
4tokenizer = AutoTokenizer.from_pretrained("sriksven/CodeLens-7B")
5
6messages = [
7 {
8 "role": "system",
9 "content": "You are an expert code reviewer and programmer. Analyze code, find bugs, suggest improvements, and write clean efficient solutions.",
10 },
11 {
12 "role": "user",
13 "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",
14 },
15]
16
17inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
18outputs = model.generate(inputs, max_new_tokens=512)
19print(tokenizer.decode(outputs[0], skip_special_tokens=True))
1from unsloth import FastLanguageModel
2
3model, tokenizer = FastLanguageModel.from_pretrained(
4 model_name="sriksven/CodeLens-7B",
5 max_seq_length=2048,
6 load_in_4bit=True,
7)
8FastLanguageModel.for_inference(model)
Loss decreased steadily from 2.17 to 0.27 over 500 steps (~13 epochs), indicating strong learning on the code instruction data.