MILP-OptiScribe-4B

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-4B; on Hugging Face its name starts with MILP.

MILP-OptiScribe-4B 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 Qwen/Qwen3.5-4B fine-tuned with reinforcement learning (stage 10 of the curriculum below) so that the instances it writes are valid, of the requested size, hard for a MILP solver and varied.

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 (750 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.8 h
9 171-225 150 10,000 10,000 20 s 3.2 h
10 226-350 300 10,000 10,000 50 s 9.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 350 variables; larger sizes were never trained.

Valid instances in the requested size range, out of 256 (MILP-OptiScribe-4B, with the untrained Qwen3.5-4B in brackets):

Family 171-225 variables 226-350 variables 351-500 variables 501-750 variables 751-1000 variables
Bin packing 256 (base 125) 253 (base 77) 249 (base 37) 87 (base 5) 38 (base 3)
CFL 256 (base 9) 254 (base 1) 144 (base 7) 1 (base 0) 0 (base 0)
FCMCNF 255 (base 57) 255 (base 40) 252 (base 51) 247 (base 19) 191 (base 17)
GISP 256 (base 86) 249 (base 56) 174 (base 16) 91 (base 4) 3 (base 2)
Knapsack 28 (base 0) 23 (base 1) 4 (base 1) 0 (base 0) 0 (base 0)
Max-Cut 256 (base 196) 256 (base 157) 223 (base 31) 65 (base 7) 4 (base 1)

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 74 (base 1) 255 (base 1) 490 (base 1) 972 (base 3,525) 1,660 (base 6,457)
CFL 315 (base 23) 632 (base 1) 1,163 (base 7) 100,000 (base โ€“) โ€“ (base โ€“)
FCMCNF 1 (base 1) 2 (base 1) 2 (base 1) 4 (base 1) 7 (base 1)
GISP 125 (base 5) 267 (base 9) 618 (base 29) 1,247 (base 40) 3,867 (base 173)
Knapsack 562 (base โ€“) 2,190 (base 50,000) 4,949 (base 3,329) โ€“ (base โ€“) โ€“ (base โ€“)
Max-Cut 866 (base 172) 1,692 (base 491) 15,124 (base 1,702) 100,000 (base 7,947) 100,000 (base 579)

Validity by size range SCIP nodes Variety Root gap

Released instances

PSquare-SinglaLab-IITR/MILP-OptiScribe-Dataset-1M holds 1,000,000 instances: 500,000 written by this model (config MILP-OptiScribe-4B: 5 families ร— 4 size ranges, 111-500 variables, ร— 25,000) and 500,000 by MILP-OptiScribe-12B. 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, Qwen3.5-4B, 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.

Random sample of MILP-OptiScribe-4B instances vs the base model

Each panel shows one metric for one family. In every size range, the left column is Qwen3.5-4B (grey rings) and the right column is MILP-OptiScribe-4B (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.5% (22.6%) 174 (2) 7.3% (3.0%) 1 (1) 0.0% (0.0%) 11.4% (9.0%) 89.1 (82.9) 95.8
CFL 88.1% (4.7%) 365 (14โ€ ) 3.9% (0.9%โ€ ) 39 (7โ€ ) 2.2% (0.5%โ€ ) 24.6% (12.1%โ€ ) 90.4 (90.9โ€ ) โ€“
FCMCNF 97.8% (24.8%) 1 (1) 0.0% (0.0%) 1 (1) 0.0% (0.0%) 54.5% (49.7%) 93.3 (91.0) 96.0
GISP 91.6% (23.4%) 169 (5) 0.0% (0.0%) 59 (1) 15.0% (0.0%) 231.9% (177.6%) 68.1 (71.4) 93.2
Max-Cut 96.8% (49.7%) 1,191 (259) 0.9% (0.0%) 1,869 (979) 19.5% (10.1%) 79.3% (65.3%) 85.6 (89.5) 95.6

Bold: MILP-OptiScribe-4B; in brackets: the untrained Qwen3.5-4B 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 171-225: 209; CFL 226-350: 26; CFL 351-500: 188). 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-4B", 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

Compute hardware support from Power Grid Corporation of India Limited (POWERGRID).

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-4B 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, Qwen/Qwen3.5-4B, 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
-
Safetensors
Model size
4B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for PSquare-SinglaLab-IITR/MILP-OptiScribe-4B

Finetuned
Qwen/Qwen3.5-4B
Finetuned
(1,608)
this model

Paper for PSquare-SinglaLab-IITR/MILP-OptiScribe-4B