Downloads · 30 days
24
32% of all-time downloads
synthiumjp/competence-gate-qwen3.5-4b
competence-gate-qwen3.5-4b is a machine learning model from synthiumjp. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for mlx. The card lists the license as apache-2.0.
A small (~10 MB) LoRA adapter that adds calibrated tool-gating to Qwen/Qwen3.5-4B: it decides when to answer directly, when to look something up, and when to retrieve from your own documents — based on the model's int…
Downloads · 30 days
24
32% of all-time downloads
All-time downloads
75
Public
Repo size
53.3 MB
Likes
6
Public
Click a slice to open those files.
.safetensors42.5 MB · 80%
From the Hugging Face model README
A small (~10 MB) LoRA adapter that adds calibrated tool-gating to
Qwen/Qwen3.5-4B: it decides when to answer directly, when to look something up,
and when to retrieve from your own documents — based on the model's internal
competence signal rather than its (saturated) verbalised confidence. It ships
with an orchestration substrate that routes private-flavoured queries to a local
retriever instead of public web search.
Scope note (read this). The validated, benchmark-supported claim here is parametric tool-call routing — deciding when to answer from the model's own knowledge vs. defer to a tool — and the privacy-routing result below. The gate does not improve grounded document QA (answering faithfully from a provided passage): on that task it does not help and can push toward answering. Grounded-abstention is a separate construct the gate was not trained for; see Scope & what this does not do below. Claims are kept to what external benchmarks support.
Built by Jon-Paul Cacioli (synthiumjp.github.io). The validity-screening and metacognitive-measurement methods used here are shared with Signal & Thread, an independent AI- measurement lab.
This is an open research release, not a commercial product. It is a capability demonstrator — it shows what the science used to measure AI looks like when applied to build a calibrated system. Nothing here is sold, and it is not part of any measurement service. Apache-2.0.
This is an adapter, not a model. The base Qwen3.5-4B (Apache-2.0) is pulled at load time; only the ~10 MB gate is distributed here. The adapter is useless without the orchestration substrate (included) — the gate makes decisions, the substrate enforces them.
This card is written as an instrument-validation dossier: every claim below is reported with its effect size, confidence interval, or screening control, and its honest limitations. Numbers that came in smaller under tightening are reported at the tightened value, not the first look.
A linear probe on the model's layer-18 hidden state predicts whether the model will answer a factual question correctly, at within-difficulty-band AUROC 0.868 (difficulty-balanced PopQA, n=420), passing validity screening (VRS). The signal is distributed in the DeltaNet recurrent state (linear-attention component alone matches the full state), a first-reported architectural finding.
Distilled into a behavioural gate, it significantly out-discriminates Qwen3.5-4B's native "call vs answer" behaviour: Δd′ = 0.46, 95% CI [0.01, 0.89], P(Δ>0) = 0.976 (pooled held-out n=420, 5000-sample bootstrap). Of items the gate caught that the base missed, 87% were genuinely wrong — it catches real errors, not just calling more.
A two-signal variant routes private-document questions to a local retriever instead of public web search. On held-out private queries (n=60), it significantly reduces the rate at which confidential queries are mis-routed to public search: 0.217 → 0.100, reduction 0.117, 95% CI [0.017, 0.217] (CI excludes zero). This is the clinically load-bearing safety property.
Retrieval-appropriateness ("this needs an external source") and factual competence ("did I answer correctly") are separable internal signals at different layers: retrieval-appropriateness is decodable from layer 1 (comprehension-time), factual competence from layer 18 (post-answer). Screened at n=126 against three controls — embedding-layer AUROC at chance (0.49), permutation-null clean (0.56), and a margin over a lexically-adversarial bag-of-words control. AUROC≈1.0 indicates in-sample separability, not 1.0 generalisation; pending replication at scale.
The GGUF build reproduces the validated (MLX) gate's decisions at --lora-scaled qwen_gate.gguf:8. On a 24-item probe, agreement is 0.83, with perfect
agreement on safety-critical directions: zero false tool-calls on
known-answerable questions, zero leak-direction reversals. Residual disagreements
are conservative-direction (the GGUF gate answers a few borderline items the MLX
gate would look up) — the safe error direction. Do not run at scale 1 (the gate
does not fire) or above ~8 (over-scaling breaks known-answer behaviour).
The gate was trained and validated for one construct: parametric competence — do I know this from my own weights, or should I defer to a tool? An honest external-benchmark check shows this signal does not transfer to a different metacognitive construct, evidential grounding — is this answer supported by the passage in front of me? These look alike from outside ("knowing when to defer") but are separable signals, and the gate only carries the first. The evidence, reported straight:
Practical takeaway: use this for tool-call routing and privacy-aware retrieval routing, which it does measurably well. Do not rely on it as a "won't fabricate about your documents" guarantee — that is a different construct, it is largely a base-model property in normal use, and this gate does not improve it. A fuller writeup of this construct-specificity finding is on the project site.
# 1. clone + install
git clone https://huggingface.co/synthiumjp/competence-gate-qwen3.5-4b
cd competence-gate-qwen3.5-4b
pip install -r requirements.txt
# 2. configure (copy the example, edit if needed)
cp models.example.yaml models.yaml
# 3. put documents to retrieve from in ./docs (.txt .md .pdf .docx)
mkdir -p docs
# 4. run the substrate (the gate + firewalls + retriever + citations)
from registry import Registry
import orchestrator_qwen as O
from conversation import Conversation
reg = Registry.load("models.yaml")
models = {n: O.Model(s) for n, s in reg.specs.items()}
conv = Conversation(reg, models)
r = conv.ask("What did our Q3 report say was the top revenue region?")
# -> answer cited to the source passage, with a route/grounding band; declines
# when it can't verify. NOTE: the base model already declines well when a fact
# is plainly absent; the substrate does not add reliable grounded-abstention
# beyond that, and should not be relied on for adversarial unanswerable cases.
The base Qwen/Qwen3.5-4B (~8 GB) downloads on first load. For GGUF/Ollama
serving, see the Modelfile (serve at --lora-scaled qwen_gate.gguf:8).
from mlx_lm import load, generate
model, tok = load("Qwen/Qwen3.5-4B", adapter_path="adapters_qwen_gate")
# ...but use the orchestrator, not raw generate — the gate needs the firewalls:
from registry import Registry
import orchestrator_qwen as O
from conversation import Conversation
reg = Registry.load("models.yaml")
models = {n: O.Model(s) for n, s in reg.specs.items()}
conv = Conversation(reg, models)
r = conv.ask("What did our Q3 report say was the top revenue region?")
# -> answer cited to the source passage, with a route/grounding band; declines
# when it can't verify. NOTE: the base model already declines well when a fact
# is plainly absent; the substrate does not add reliable grounded-abstention
# beyond that, and should not be relied on for adversarial unanswerable cases.
ollama create competence-gate -f Modelfile # Modelfile sets --lora-scaled ...:8
This gate is a constructive application of a published research programme on LLM metacognition (measurement theory for language models). Each design decision traces to a specific result:
Full programme and code: synthiumjp.github.io · GitHub · ORCID 0009-0000-7054-2014.
adapters_qwen_gate/ — the validated competence gate (mlx)adapters_qwen_twosignal/ — the two-signal (privacy-routing) gate (mlx)qwen_gate.gguf — GGUF adapter (serve at scale 8)registry.py, orchestrator_qwen.py, retriever.py, conversation.py,
confidence.py — the orchestration substrateModelfile — Ollama config at the verified scale@software{competence_gate_qwen35_4b,
author = {Cacioli, Jon-Paul},
title = {A calibrated metacognitive tool-gate for Qwen3.5-4B},
note = {Open research release},
url = {https://synthiumjp.github.io/},
year = {2026}
}
Apache-2.0. Built on Qwen3.5-4B (Apache-2.0).