Instructions to use PSquare-SinglaLab-IITR/MILP-OptiScribe-12B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PSquare-SinglaLab-IITR/MILP-OptiScribe-12B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="PSquare-SinglaLab-IITR/MILP-OptiScribe-12B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("PSquare-SinglaLab-IITR/MILP-OptiScribe-12B") model = AutoModelForMultimodalLM.from_pretrained("PSquare-SinglaLab-IITR/MILP-OptiScribe-12B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use PSquare-SinglaLab-IITR/MILP-OptiScribe-12B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PSquare-SinglaLab-IITR/MILP-OptiScribe-12B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PSquare-SinglaLab-IITR/MILP-OptiScribe-12B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/PSquare-SinglaLab-IITR/MILP-OptiScribe-12B
- SGLang
How to use PSquare-SinglaLab-IITR/MILP-OptiScribe-12B 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 "PSquare-SinglaLab-IITR/MILP-OptiScribe-12B" \ --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": "PSquare-SinglaLab-IITR/MILP-OptiScribe-12B", "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 "PSquare-SinglaLab-IITR/MILP-OptiScribe-12B" \ --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": "PSquare-SinglaLab-IITR/MILP-OptiScribe-12B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use PSquare-SinglaLab-IITR/MILP-OptiScribe-12B with Docker Model Runner:
docker model run hf.co/PSquare-SinglaLab-IITR/MILP-OptiScribe-12B
MILP-OptiScribe-12B
Developed by: PSquareLab and SinglaLab, IIT Roorkee (joint work). Hugging Face organization: PSquare-SinglaLab-IITR.
Paper: Teaching LLMs to Generate Challenging MILP Instances via Solver Feedback. In the paper this model is called OptiScribe-12B; on Hugging Face its name starts with MILP.
MILP-OptiScribe-12B writes complete mixed-integer linear programming (MILP) instances on request. Given a prompt that names one of six problem families and the size wanted, it writes the whole instance (sets, parameters, variables, objective, constraints and a JSON data block) in a compact algebraic text format. It is google/gemma-4-12B-it fine-tuned with reinforcement learning (stage 11 of the curriculum below) so that the instances it writes are valid, of the requested size, hard for a MILP solver and varied.
- 500,000 instances generated by this model are in
PSquare-SinglaLab-IITR/MILP-OptiScribe-Dataset-1M (config
MILP-OptiScribe-12B), together with 500,000 from the companion model - Companion model: PSquare-SinglaLab-IITR/MILP-OptiScribe-4B (Qwen3.5-4B base)
Problem families
| Family | What the prompt fixes (geometry) |
|---|---|
| Bin packing | items, bins |
| CFL (capacitated facility location) | facilities, customers |
| FCMCNF (fixed-charge multi-commodity network flow) | nodes, commodities |
| GISP (generalized independent set problem) | graph nodes |
| Knapsack | items, knapsacks |
| Max-Cut | graph nodes |
Training
- Method: GRPO (Group Relative Policy Optimization, TRL implementation) with LoRA (low-rank adaptation) adapters, merged into the full weights after training. bf16.
- Hyperparameters (every stage): learning rate 5e-05, LoRA rank 16 (alpha 32, dropout 0), KL (Kullback-Leibler) penalty beta 0.1, gradient clip 0.5, 64 sampled completions per step, all from one family (families rotate step by step), sampling temperature 1.0, top-p 0.95, thinking mode off.
- Reward: R = G x (0.70 H + 0.15 s_size + 0.30 s_div)
- G (gate) = 1 only if the output parses, every data list has its declared length, values are inside the ranges the prompt states, the family checks pass and SCIP solves it within the stage's limits; otherwise R = 0.
- H (hardness) = 0.75 s_nodes + 0.25 s_postgap, with s_nodes = clip(log(SCIP branch-and-bound nodes) / log(N_ref), 0, 1) and s_postgap = min(1, gap left after root cuts / 0.10).
- s_size = exp(-3 |n - n*| / n*), n = variables written, n* = variables requested.
- s_div = how different the instance's numbers are from the other valid completions in its group, scaled so that independently random instances score 1.
- Curriculum (1,050 GRPO steps in total, one NVIDIA GB300 GPU):
| Stage | Variables | Steps | N_ref | SCIP node cap | Solve time limit | Wall time |
|---|---|---|---|---|---|---|
| 7 | 76-110 | 150 | 10,000 | 10,000 | 20 s | 2.2 h |
| 8 | 111-170 | 150 | 10,000 | 10,000 | 20 s | 2.4 h |
| 9 | 171-225 | 150 | 10,000 | 10,000 | 20 s | 2.7 h |
| 10 | 226-350 | 300 | 10,000 | 10,000 | 50 s | 9.0 h |
| 11 | 351-500 | 300 | 50,000 | 50,000 | 600 s | 17.4 h |
Full per-stage settings: training/stages.json.
Evaluation
256 prompts per family and size range, one sample each (temperature 1.0, top-p 0.95), the same prompts and seeds for every model. This model was trained up to 500 variables; larger sizes were never trained.
Valid instances in the requested size range, out of 256 (MILP-OptiScribe-12B, with the untrained Gemma-4-12B in brackets):
| Family | 171-225 variables | 226-350 variables | 351-500 variables | 501-750 variables | 751-1000 variables |
|---|---|---|---|---|---|
| Bin packing | 256 (base 253) | 256 (base 256) | 256 (base 242) | 232 (base 159) | 124 (base 95) |
| CFL | 236 (base 46) | 253 (base 16) | 244 (base 32) | 48 (base 4) | 15 (base 0) |
| FCMCNF | 249 (base 25) | 251 (base 22) | 252 (base 44) | 196 (base 10) | 163 (base 12) |
| GISP | 256 (base 190) | 256 (base 120) | 254 (base 66) | 62 (base 3) | 1 (base 0) |
| Knapsack | 200 (base 53) | 170 (base 39) | 70 (base 17) | 2 (base 0) | 0 (base 0) |
| Max-Cut | 255 (base 171) | 251 (base 107) | 252 (base 10) | 2 (base 0) | 0 (base 0) |
Median SCIP branch-and-bound nodes of the valid instances (higher = harder; node cap 50,000 up to 500 variables, 100,000 above):
| Family | 171-225 variables | 226-350 variables | 351-500 variables | 501-750 variables | 751-1000 variables |
|---|---|---|---|---|---|
| Bin packing | 86 (base 1) | 428 (base 10) | 424 (base 472) | 594 (base 2,189) | 816 (base 2,580) |
| CFL | 558 (base 43) | 1,337 (base 430) | 3,982 (base 709) | 24,067 (base 550) | 100,000 (base โ) |
| FCMCNF | 1 (base 1) | 1 (base 1) | 1 (base 1) | 1 (base 1) | 1 (base 1) |
| GISP | 33 (base 3) | 65 (base 9) | 160 (base 23) | 280 (base 31) | 2,979 (base โ) |
| Knapsack | 276 (base 293) | 480 (base 934) | 1,898 (base 3,066) | 4,120 (base โ) | โ (base โ) |
| Max-Cut | 741 (base 79) | 1,588 (base 343) | 10,440 (base 911) | 94,382 (base โ) | โ (base โ) |
Released instances
PSquare-SinglaLab-IITR/MILP-OptiScribe-Dataset-1M holds 1,000,000 instances: 500,000 written by
this model (config MILP-OptiScribe-12B: 5 families ร 4 size ranges, 111-500 variables, ร 25,000) and 500,000 by
MILP-OptiScribe-4B. Each one passed parsing, size, value-range, family-structure, SCIP-feasibility and exact-copy checks.
Hardness and variety were measured on a random sample: 250 instances per family and size range, drawn uniformly at random from the 25,000 released (5,000 per model; seeded, so the sample is reproducible). Each was solved with SCIP 10.0 (PySCIPOpt 6.2.1) and Gurobi 13.0.3, one thread each, default settings, seed 0, node limit 50,000. For comparison, the untrained base model, Gemma-4-12B, was given the same prompts with the same seeds and sampling settings, and its outputs were checked in the same way. Up to 250 that passed per family and size range were solved with the same settings. These base-model instances are not part of this release.
Each panel shows one metric for one family. In every size range, the left column is Gemma-4-12B (grey rings) and the right column is MILP-OptiScribe-12B (dots). Each dot is one instance; for variety, each dot is one Vendi draw. Solid line: median; dashed line: mean. Dotted line: the 50,000-node cap, or the seeded random generator's variety.
| Family | Pass rate | SCIP nodes (median) | SCIP at node cap | Gurobi nodes (median) | Root gap (median) | LP gap (median) | Variety (Vendi) | Variety, seeded random |
|---|---|---|---|---|---|---|---|---|
| Bin packing | 99.9% (72.1%) | 175 (5) | 8.8% (1.9%) | 1 (1) | 0.0% (0.0%) | 12.4% (8.1%) | 94.0 (82.9) | 95.8 |
| CFL | 96.4% (17.2%) | 594 (46โ ) | 5.0% (0.6%โ ) | 39 (22โ ) | 2.4% (0.9%โ ) | 20.4% (15.1%โ ) | 91.5 (95.1โ ) | โ |
| FCMCNF | 98.7% (15.3%) | 1 (1) | 0.0% (0.0%) | 1 (1) | 0.0% (0.0%) | 42.0% (44.6%) | 93.4 (83.5) | 96.0 |
| GISP | 99.5% (59.2%) | 51 (7) | 0.0% (0.0%) | 27 (1) | 13.5% (0.0%) | 248.9% (198.4%) | 86.7 (86.7) | 93.2 |
| Max-Cut | 99.0% (45.7%) | 1,098 (150โ ) | 0.6% (0.0%โ ) | 1,686 (277โ ) | 18.1% (5.3%โ ) | 77.2% (58.0%โ ) | 85.9 (91.7โ ) | 95.6 |
Bold: MILP-OptiScribe-12B; in brackets: the untrained Gemma-4-12B on the same prompts. Each value weights the four size ranges equally (medians over the family's instances with equal weight per range; pass rate and variety: mean over the ranges). โ the base model has fewer than 250 passing instances in some ranges (CFL 226-350: 246; Max-Cut 351-500: 165). Variety, seeded random: our own generator for the same sizes with fresh random numbers (none for CFL).
How to read the metrics:
- Branch-and-bound nodes: the nodes each solver needed to prove optimality. Instances that stop at the node cap count as 50,000. Node counts are not comparable across solvers. More nodes means harder for that solver at these settings.
- Root gap: |z* - z_root| / |z*|, where z* is the optimal value and z_root is Gurobi's bound after the root node (after cuts).
- LP gap: |z* - z_LP| / |z*|, where z_LP is the value of the LP relaxation. Both gaps need the optimal value z*, taken from Gurobi, or from SCIP when Gurobi did not prove optimality. Instances where neither solver proved optimality within the node cap have no gap (4 of 5,000 for this model). GISP's LP gap can exceed 100%.
- Variety: the Vendi score (Friedman and Dieng, TMLR 2023) of 100 instances, as the median of 200 random draws; the maximum is 100. The similarity of two instances is the share of positions where their free data arrays hold the same value, and 0 for different sizes. It detects copied or repeated numbers, not differences in structure.
- Pass rate: the share of prompts whose output passed every check, including the exact-copy check.
- Base-model numbers: they come only from base outputs that passed the checks. Where the base pass rate is low, those outputs may be the easier ones.
Per-instance results of the sample are in release_sample/solve_results.parquet
(config release_sample): released id, model, solver status, nodes, whether the node cap was hit, z*, z_LP, z_root
and both gaps. Solve times are left out because they were measured while other jobs shared the CPUs.
How to use
Use the chat template with thinking off, temperature 1.0 and top-p 0.95, the settings the model was trained with. A
training prompt (CFL, 171-225 variables) with its worked example instance is in example_prompt.txt.
from vllm import LLM, SamplingParams
llm = LLM(model="PSquare-SinglaLab-IITR/MILP-OptiScribe-12B", dtype="bfloat16", max_model_len=8192)
tok = llm.get_tokenizer()
prompt = open("example_prompt.txt").read()
text = tok.apply_chat_template([{"role": "user", "content": prompt}], tokenize=False,
add_generation_prompt=True, enable_thinking=False)
out = llm.generate([text], SamplingParams(temperature=1.0, top_p=0.95, max_tokens=2048))
print(out[0].outputs[0].text)
Always check what the model writes before using it: parse it, check list lengths and value ranges, and solve it or at least find a feasible solution. The released datasets apply exactly these checks.
Limitations
- Sizes inside a range come from a fixed menu of 2-5 requested geometries per family and range (for Max-Cut and GISP, graphs of 11-21 nodes), so not every variable count is represented.
- Beyond the trained sizes, validity drops sharply for knapsack, Max-Cut and GISP (see the table).
- FCMCNF instances are almost always solved at the root node by SCIP (median 1 node): valid and varied, but easy.
- Hardness is measured with SCIP default settings on one thread; other solvers and settings rank instances differently.
Acknowledgements
Two of the three worked CFL examples in the training prompts follow the constraint structure of two problem
classes, milp_776-medium and milp_430-easy, from Microsoft's
MILP-Evolve dataset (Li et al., Towards Foundation
Models for Mixed Integer Linear Programming, ICLR 2025). Their numbers were generated by our own code; no
MILP-Evolve data is included. The other examples were written by hand or generated by our own code.
License
MILP-OptiScribe-12B is released under CC BY-NC 4.0: free for non-commercial use (research, teaching) with attribution. Commercial use is not permitted without a separate licence from the authors; contact pareek@ee.iitr.ac.in and jsingla@bt.iitr.ac.in.
The base model, google/gemma-4-12B-it, is licensed under Apache 2.0
(licence); its licence text is in LICENSE.base-model. The
changes made to it are described under Training above.
Citation
@misc{singla2026teachingllmsgeneratechallenging,
title={Teaching LLMs to Generate Challenging MILP Instances via Solver Feedback},
author={Jitin Singla and Parikshit Pareek and Pratik Jawanpuria and Parag Singla},
year={2026},
eprint={2609.37356},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2609.37356},
}
- Downloads last month
- -




