Mini-Intelligence / README.md
Yahya308's picture
Mini Intelligence v2.0.0
89aab85 verified
|
Raw History Blame Contribute Delete
15.6 kB
metadata
license: apache-2.0
base_model: convaiinnovations/laya
base_model_relation: finetune
language:
  - en
library_name: transformers
pipeline_tag: text-classification
inference: false
tags:
  - llm-routing
  - model-routing
  - router
  - modernbert
  - multi-label-classification

Mini Intelligence v2

Mini Intelligence is a small query router. Given an English query, it estimates, for each of 20 open language models of roughly 7–9B parameters, the probability that the model answers the query correctly. It selects the model with the highest estimate and returns all 20 scores. The caller can then send the query to the selected model.

Version 2.0.0 is a full fine-tune of the English Laya encoder (ModernBERT-large: 28 layers, about 395M parameters) with a 20-output prediction head. It was trained on outcomes recorded by LLMRouterBench, as part of a master's thesis on LLM routing.

  • This repository: the fine-tuned encoder as a standard transformers ModernBERT checkpoint, the prediction head, the tokenizer and the router configuration.
  • Code, command-line tool and verification tools: github.com/yahya308/Mini-Intelligence (tag v2.0.0).

Usage

With the Mini Intelligence package

git clone --branch v2.0.0 https://github.com/yahya308/Mini-Intelligence.git
cd Mini-Intelligence
python -m pip install .
mini-intelligence "Write a Python function that merges two sorted lists."
from mini_intelligence import MiniIntelligence

router = MiniIntelligence()  # downloads this repository at the commit pinned by the package
decision = router.route("Write a Python function that merges two sorted lists.")
print(decision["selected_model"], decision["probabilities"][decision["selected_model"]])

The package checks the SHA-256 of every downloaded file before loading. It runs in float32 on CPU or CUDA by default. On a CUDA GPU, bfloat16 autocast is available with precision="bfloat16".

With transformers only

The encoder is a standard ModernBertModel. This snippet reproduces the package's probabilities exactly:

import json

import torch
from huggingface_hub import snapshot_download
from safetensors.torch import load_file
from torch import nn
from transformers import AutoTokenizer, ModernBertModel

path = snapshot_download("Yahya308/Mini-Intelligence", revision="v2.0.0")
config = json.load(open(f"{path}/router_config.json", encoding="utf-8"))
tokenizer = AutoTokenizer.from_pretrained(path)
encoder = ModernBertModel.from_pretrained(path, dtype=torch.float32, attn_implementation="sdpa").eval()
head = nn.Sequential(nn.LayerNorm(1024), nn.Linear(1024, 128), nn.GELU(), nn.Dropout(0.1), nn.Linear(128, 20))
head.load_state_dict({k.removeprefix("layers."): v for k, v in load_file(f"{path}/head.safetensors").items()})
head.eval()

query = "Write a Python function that merges two sorted lists."
ids = tokenizer(query.replace(tokenizer.mask_token, " "), add_special_tokens=False)["input_ids"]
if len(ids) > 423:
    ids = ids[:211] + ids[-212:]
ids = torch.tensor([[tokenizer.cls_token_id, *ids, tokenizer.sep_token_id]])
with torch.inference_mode():
    cls = encoder(input_ids=ids, attention_mask=torch.ones_like(ids)).last_hidden_state[:, 0]
    probs = head(cls).sigmoid()[0]
print(config["models"][int(probs.argmax())], float(probs.max()))

The snippet was tested with transformers 5.17.0, the version the package pins.

What changed from v1

v1.0.0 v2.0.0
Adaptation Rank-8 LoRA on one matrix (the output projection of the final encoder layer's MLP); rest of the encoder frozen Full fine-tune of every encoder parameter, embeddings included
Learned parameters 165,012 394,917,524 (encoder 394,781,696; head 135,828)
Released weights Adapter and head only; base Laya weights downloaded at load time Complete encoder (standard ModernBERT checkpoint) and head, on this page
Runtime dependency laya package transformers only
Default inference precision bfloat16 encoder on GPU float32 on CPU or GPU (bfloat16 optional)
Mean over the 5 official splits, Sample-Avg / Dataset-Avg 70.10% / 71.35% 70.78% / 72.40%
ARC-Challenge (held out, released checkpoint) 93.69% 94.03%

The input (423-token head and tail view), representation (CLS), head architecture, candidate pool and selection policies are unchanged. v1 remains available at the v1.0.0 tag of the GitHub repository.

Model details

  • Base model: convaiinnovations/laya, revision e333cb7c823cd1787276228260f56d02fbf5180b (English; ModernBERT-large encoder).
  • Input: the query text only. The tokenizer's mask token is replaced by a space. The encoder reads [CLS], up to 423 query tokens and [SEP]. Longer queries are represented by their first 211 and last 212 tokens.
  • Representation: the CLS vector after the encoder's final normalization.
  • Prediction head: LayerNorm, a 128-unit linear layer, GELU, dropout 0.1 and a 20-unit linear layer, followed by a sigmoid. There is one output per candidate.
  • Selection policies:
    • raw (default): select the candidate with the highest predicted success.
    • gated: select the fallback model, Qwen3-8B, unless the top candidate's predicted success exceeds Qwen3-8B's by at least a margin chosen on validation data. For this checkpoint, the chosen margin is 0.0, so the gated policy never falls back and gives the same choices as raw. It is kept for compatibility with v1.

Files

File Content SHA-256
config.json ModernBERT configuration (Laya's encoder configuration) 1fb7072c9ede80879dd68e8457faf69b1989909d3ce6e902db0873d7b02234ac
model.safetensors Fine-tuned encoder, float32 (1.58 GB) 7e29152f140bc4dadaf78152bc99210bda242a91a4ae66723aebe797a245b41e
head.safetensors Prediction head, float32 cf24e4e656b54404f06c72513eb2e03ca1929fe55f58965e397286fe2b495155
tokenizer.json, tokenizer_config.json Laya's tokenizer, unchanged 6c8aaa9a…, 50044de6…
router_config.json Candidate order, input view, policy, training summary, file checksums

The encoder and head tensors are an exact split of the training checkpoint (49acc7067cad04b3ecf944ede735080082bc7fc598970226d1cdc674d7ad7f37), with no conversion: every tensor is bit-identical.

Candidates (output order)

  1. DeepHermes-3-Llama-3-8B-Preview
  2. DeepSeek-R1-0528-Qwen3-8B
  3. DeepSeek-R1-Distill-Qwen-7B
  4. Fin-R1
  5. GLM-Z1-9B-0414
  6. Intern-S1-mini
  7. Llama-3.1-8B-Instruct
  8. Llama-3.1-8B-UltraMedical
  9. Llama-3.1-Nemotron-Nano-8B-v1
  10. MiMo-7B-RL-0530
  11. MiniCPM4.1-8B
  12. NVIDIA-Nemotron-Nano-9B-v2
  13. OpenThinker3-7B
  14. Qwen2.5-Coder-7B-Instruct
  15. Qwen3-8B (fallback model of the gated policy)
  16. cogito-v1-preview-llama-8B
  17. gemma-2-9b-it
  18. glm-4-9b-chat
  19. granite-3.3-8b-instruct
  20. internlm3-8b-instruct

Training

  • Data: queries from the 15 datasets of LLMRouterBench's 20-model setting. They cover mathematics, code generation, logical and general reasoning, knowledge and domain question answering (including medicine and finance), and emotion recognition in dialogue.
  • Targets: LLMRouterBench records, for each query, whether each of the 20 candidates answered it correctly. These 20 binary outcomes are the multi-label targets. The loss is binary cross-entropy.
  • Released checkpoint: trained on all 11,481 queries of the 15 datasets, split by prompt text into 9,759 fitting and 1,722 validation queries. ARC-Challenge was not used for training or for any selection.
  • Optimization:
    • Every encoder parameter and the head are trained.
    • AdamW (betas 0.9 and 0.999, epsilon 1e-8), weight decay 0.01. The encoder's LayerNorm weights are not decayed.
    • Learning rate 5e-5 for the encoder and 1e-3 for the head. The encoder rate was chosen from {1e-5, 2e-5, 5e-5} on the validation part of one official split.
    • Linear warm-up over the first 6% of steps, then linear decay to zero. Gradient clipping at 1.0.
    • Batches of 16 queries of similar length.
    • Up to 5 epochs, with early stopping after 2 epochs without improvement. The epoch with the lowest validation loss is kept; for this checkpoint, epoch 3.
  • Precision: float32 weights with bfloat16 autocast. The final encoder layer's MLP runs in float32.
  • Hardware: one NVIDIA L40S GPU, about 12.5 minutes of training for this checkpoint.
  • Gated policy: the fallback model is the best single candidate on the fitting queries (Qwen3-8B). The margin was chosen from {always fall back, 0.2, 0.1, 0.05, 0.025, 0.01, 0.0} by routed accuracy on the validation queries.

Evaluation

Official LLMRouterBench protocol (the training recipe)

The recipe was evaluated with LLMRouterBench's official protocol: the split_by_dataset_then_prompt split, 70% training and 30% test within each dataset, 5 seeds (42, 999, 2024, 2025 and 3407), the 20-model pool and the 15 datasets. For each split, a separate model was trained with the same recipe on that split's training part. These numbers therefore describe the recipe, not the exact checkpoint on this page.

The metrics measure how often the selected model's recorded answer was correct:

  • Sample-Avg: accuracy over all test queries.
  • Dataset-Avg: the mean of the 15 per-dataset accuracies.

Mean ± standard deviation over the 5 splits:

Method Sample-Avg Dataset-Avg
Mini Intelligence v2, raw (this recipe) 70.78 ± 0.58% 72.40 ± 1.06%
Mini Intelligence v2, gated 70.40 ± 0.83% 72.08 ± 0.93%
Mini Intelligence v1, raw 70.10 ± 0.92% 71.35 ± 1.11%
Best single model (Qwen3-8B) 66.72 ± 0.87% 68.01 ± 1.08%
  • Compared with v1: +0.68 points Sample-Avg and +1.05 points Dataset-Avg on average. In paired bootstrap tests per split (2,000 resamples, 95% intervals), the Sample-Avg gain was above zero in 3 of the 5 splits. The Dataset-Avg gain was not distinguishable from zero in any split. v1 and v2 were trained and evaluated on different GPUs.
  • Gated policy: on these splits, the validation-chosen margin was 0.0 in three splits. Gating did not improve accuracy.

For context only, the LLMRouterBench paper (arXiv:2601.07206, Table 11; same 20 candidates, 15 datasets, 70/30 splits and five seeds as our evaluation) reports these Dataset-Avg values for published routers:

Router (published numbers) Dataset-Avg
Avengers 71.94%
MODEL-SAT 71.88%
EmbedLLM 71.24%
GraphRouter 70.29%
RouterDC 61.33%

We did not re-run these routers. The paper marks the values of MODEL-SAT, EmbedLLM, GraphRouter and RouterDC as peak scores on the test set, and gives no intervals. Our numbers come from different hardware and runs, so we make no claim of a significant difference: v2 is on par with the strongest published routers.

Held-out ARC-Challenge (this exact checkpoint)

ARC-Challenge was never used for training or selection. On its 1,172 queries:

Method Accuracy
Mini Intelligence v2 (raw = gated) 94.03%
Best single model (Qwen3-8B) 93.77%
Mini Intelligence v1 (raw) 93.69%
  • The difference from the best single model (+0.26 points, 95% paired bootstrap interval −0.77 to +1.28) is not significant. ARC-Challenge is near the ceiling for this pool: the best possible choice per query would reach 97.44%.
  • Probability quality: averaged over the 20 candidates, the Brier score is 0.139 and the log loss 0.445. Over the five official test splits, the means were 0.194 and 0.564; v1 had 0.198 and 0.575. A constant prediction of 0.5 gives 0.25 and 0.693.

Reproducibility

The training run stored its ARC-Challenge probabilities (NVIDIA L40S, bfloat16 autocast). The released files were checked against them:

  • Same machine. The package and the original training code, both in float32 on an NVIDIA RTX 4070 Laptop GPU, gave the same probabilities to within 1.2e-7 for all 1,172 queries, with identical choices.
  • Against the training run.
    • Float32 on the RTX 4070 differs from the stored bfloat16 probabilities by at most 0.042 (mean 0.0013).
    • 1,168 of 1,172 choices are identical (99.66%). The 4 different choices are near ties (the top two stored probabilities differ by less than 0.001), and in each case both models had the same recorded outcome.
    • Routed accuracy is the same: 94.03%.
  • CPU versus GPU. Float32 on CPU and on the GPU differ by at most 2e-5, with identical choices.

tools/verify_release.py in the GitHub repository repeats this check on your machine. It compares against reference probabilities keyed by a SHA-256 hash of each prompt. You need the ARC-Challenge prompts from LLMRouterBench; they are not distributed.

Limitations

  • Measured on benchmark task types only. Routing quality was measured on LLMRouterBench queries.
  • Unfamiliar task types. On queries unlike the training tasks, the router can over-rely on patterns learned from similar-looking training tasks. It can then route poorly, for example by sending a whole family of queries to one model that is weak on them. Evaluate it on your own data, and compare it with simply using the best single model, before relying on it.
  • Fixed pool. It only routes among these 20 specific models, as run by LLMRouterBench. It cannot score other models, other versions of these models or a different candidate set.
  • Estimates, not guarantees. The probabilities are estimates of benchmark correctness learned from about 11,500 queries. They are not calibrated confidences.
  • English only. Long queries are seen only through their first 211 and last 212 tokens.
  • No cost or latency. Cost, latency, answer length and user preferences are not modeled.
  • Numerical precision. Running in bfloat16 instead of float32 changes the probabilities by up to about 0.04. It can flip choices between near-tied candidates.

Training data, licenses and attribution

  • Training labels: the training queries and per-model outcomes come from LLMRouterBench (Li et al., 2026). No benchmark questions, model outputs or outcome labels are redistributed here or in the GitHub repository.
  • Base model: Laya by Convai Innovations, Apache License 2.0. Laya is built on ModernBERT-large (Answer.AI and LightOn, Apache License 2.0). The tokenizer files are Laya's, unchanged, from revision e333cb7.
  • License: Apache License 2.0 (see LICENSE). Attribution is in NOTICE.

Citation

@software{mini_intelligence_2026,
  author  = {yahya308},
  title   = {Mini Intelligence: a fine-tuned Laya router that predicts success across 20 language models},
  version = {2.0.0},
  year    = {2026},
  url     = {https://github.com/yahya308/Mini-Intelligence}
}

@article{li2026llmrouterbench,
  title   = {LLMRouterBench: A Massive Benchmark and Unified Framework for LLM Routing},
  author  = {Li, Hao and Zhang, Yiqun and Guo, Zhaoyan and Wang, Chenxu and Tang, Shengji and Zhang, Qiaosheng and Chen, Yang and Qi, Biqing and Ye, Peng and Bai, Lei and Wang, Zhen and Hu, Shuyue},
  journal = {arXiv preprint arXiv:2601.07206},
  year    = {2026}
}

Please also credit the upstream Laya model.