This model is a fine-tuned version of
Qwen/Qwen2.5-Coder-1.5B-Instruct specialized for generating OCaml code.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "kiranpg/Qwen2.5-OCamler-1.5B-Instruct"
4
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
7
8messages = [
9 {"role": "user", "content": "Write an OCaml function to compute the factorial of a number."}
10]
11
12text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
13inputs = tokenizer(text, return_tensors="pt").to(model.device)
14
15outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
16print(tokenizer.decode(outputs[0], skip_special_tokens=True))
This model is designed for generating OCaml code solutions given natural language problem descriptions. It has been fine-tuned on OCaml programming problems using GRPO with real-time feedback from the OCaml compiler and test suite to improve its ability to produce correct, idiomatic OCaml code.
Trained using
TRL's GRPOTrainer with OCaml compiler verification for rewards. The reward system uses a graduated structure: