This model is a fine-tuned version of
google/gemma-2-2b-it on the
open-r1/codeforces-cots dataset for competitive programming problem solving.
This model has been fine-tuned using LoRA (Low-Rank Adaptation) on competitive programming problems from Codeforces. It's designed to help generate solutions for algorithmic and data structure problems commonly found in competitive programming contests.
This model is intended for generating solutions to competitive programming problems, particularly those similar to Codeforces problems. It can:
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3import torch
4
5# Load the base model
6base_model = AutoModelForCausalLM.from_pretrained(
7 "google/gemma-2-2b-it",
8 torch_dtype=torch.float16,
9 device_map="auto"
10)
11
12# Load the fine-tuned LoRA adapters
13model = PeftModel.from_pretrained(
14 base_model,
15 "Aswith77/gemma-2-2b-it-finetune-codeforces-cots"
16)
17
18# Load tokenizer
19tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
20
21# Generate code for a problem
22problem = """
23Given an array of integers, find the maximum sum of a contiguous subarray.
24Input: [-2,1,-3,4,-1,2,1,-5,4]
25Output: 6 (subarray [4,-1,2,1])
26"""
27
28inputs = tokenizer(problem, return_tensors="pt")
29outputs = model.generate(
30 **inputs,
31 max_length=512,
32 temperature=0.7,
33 do_sample=True,
34 pad_token_id=tokenizer.eos_token_id
35)
36
37solution = tokenizer.decode(outputs[0], skip_special_tokens=True)
38print(solution)
The model was trained on the
open-r1/codeforces-cots dataset, specifically using 1,000 competitive programming problems and their solutions from Codeforces.
The model achieved a training loss of 0.3715, showing good convergence from an initial loss of 0.9303. The loss curve demonstrated steady improvement throughout training without signs of overfitting.
Training was conducted on a single Tesla T4 GPU for approximately 20 minutes, resulting in minimal environmental impact compared to larger scale training runs.
Created by Aswith77 during fine-tuning experiments with competitive programming datasets.
For questions or issues regarding this model, please open an issue in the model repository.