Instructions to use nilenso/Qwen2.5-OCamler-1.5B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nilenso/Qwen2.5-OCamler-1.5B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nilenso/Qwen2.5-OCamler-1.5B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nilenso/Qwen2.5-OCamler-1.5B-Instruct") model = AutoModelForCausalLM.from_pretrained("nilenso/Qwen2.5-OCamler-1.5B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nilenso/Qwen2.5-OCamler-1.5B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nilenso/Qwen2.5-OCamler-1.5B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nilenso/Qwen2.5-OCamler-1.5B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nilenso/Qwen2.5-OCamler-1.5B-Instruct
- SGLang
How to use nilenso/Qwen2.5-OCamler-1.5B-Instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nilenso/Qwen2.5-OCamler-1.5B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nilenso/Qwen2.5-OCamler-1.5B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nilenso/Qwen2.5-OCamler-1.5B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nilenso/Qwen2.5-OCamler-1.5B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nilenso/Qwen2.5-OCamler-1.5B-Instruct with Docker Model Runner:
docker model run hf.co/nilenso/Qwen2.5-OCamler-1.5B-Instruct
Qwen2.5-OCamler-1.5B-Instruct
This model is a fine-tuned version of Qwen/Qwen2.5-Coder-1.5B-Instruct specialized for generating OCaml code.
Model Details
- Base Model: Qwen/Qwen2.5-Coder-1.5B-Instruct
- Fine-tuning Method: Generative Representational Preference Optimization (GRPO) with LoRA
- Training Dataset: kiranpg/ocaml-training-problems
- Training Code: ocamler-grpo
Training Configuration
GRPO Parameters
| Parameter | Value |
|---|---|
| Batch Size | 2 |
| Gradient Accumulation Steps | 4 |
| Effective Batch Size | 8 |
| Learning Rate | 5e-6 |
| Number of Epochs | 3 |
| Max Prompt Length | 800 |
| Max Completion Length | 700 |
| LR Scheduler Type | cosine |
| Warmup Ratio | 0.03 |
| Weight Decay | 0.01 |
| Max Grad Norm | 1.0 |
| Optimizer | adamw_8bit |
| Dataloader Num Workers | 2 |
LoRA Configuration
| Parameter | Value |
|---|---|
| LoRA Rank (r) | 32 |
| LoRA Alpha | 64 |
| LoRA Dropout | 0.05 |
Training Settings
| Parameter | Value |
|---|---|
| Logging Steps | 1 |
| Eval Steps | 500 |
| Save Steps | 100 |
| Save Total Limit | 30 |
GRPO-Specific Parameters
| Parameter | Value |
|---|---|
| Num Generations | 8 |
| Temperature | 1.0 |
| Beta (KL coefficient) | 0.01 |
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "kiranpg/Qwen2.5-OCamler-1.5B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
messages = [
{"role": "user", "content": "Write an OCaml function to compute the factorial of a number."}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Intended Use
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.
Limitations
- The model may not always produce syntactically correct OCaml code
- Complex algorithmic problems may require multiple attempts
- The model works best with clear, well-specified problem descriptions
Training Infrastructure
Trained using TRL's GRPOTrainer with OCaml compiler verification for rewards. The reward system uses a graduated structure:
- Type checking: 25% (partial credit scaled by error count)
- Compilation: 10% (partial credit based on type check)
- Tests: 65% (all-or-nothing for passing)
- Downloads last month
- 13
Model tree for nilenso/Qwen2.5-OCamler-1.5B-Instruct
Base model
Qwen/Qwen2.5-1.5B