Aphelion-Judge-3.8B
Aphelion-Judge-3.8B (3,821,079,552 parameters) is a specialized, first-principles RAG groundedness and hallucination verification model. Fine-tuned from microsoft/Phi-3.5-mini-instruct using Micro-Chain-of-Thought (Micro-CoT) supervision, it audits AI-generated responses strictly against retrieved Context documents and outputs a deterministic JSON verdict (reason + grounded).
- GitHub Repository (SDK & Training Scripts):
knsiuss/aphelion-judge - Live Browser Demo (WebAssembly /
wllama):knss12/Aphelion-Judge-3.8B-Demo - Frozen Evaluation Benchmark & Raw Audit Logs:
knss12/aphelion-judge-eval-v1 - Weights Included: Merged
FP16Safetensors (~7.64 GB) & quantizedQ4_K_MGGUF (~2.40 GB)
Architecture & First-Principles Design Rationale
1. Model Architecture Specifications
- Backbone: Dense Decoder-Only Causal Transformer (
microsoft/Phi-3.5-mini-instruct) - Total Parameters:
3,821,079,552(~3.82B, merged FP16 Safetensors +Q4_K_MGGUF) - Depth & Width:
32Transformer blocks, hidden dimensiond_model = 3072, SwiGLU MLP intermediate dimension8192 - Attention & Positional Encoding:
32attention heads with LongRoPE (max_position_embeddings = 131,072tokens) and RMSNorm pre-normalization - Adaptation & Merging: Trained via 4-bit NF4 QLoRA (
rank = 16,lora_alpha = 32,lora_dropout = 0.05, targetingqkv_proj,o_proj,gate_up_proj,down_proj) and mathematically merged (W_merged = W_0 + (alpha / r) * B @ A) into standalone FP16 weights.
2. Why This Architecture? (First-Principles Rationale)
- Why Dense 3.8B + LongRoPE over 7B–70B Judges?
RAG verification is a closed-book contextual entailment task, not an open-domain world-knowledge recall task. Massive 70B models waste compute storing encyclopedic facts that must actually be suppressed during RAG auditing. At
3.82Bparameters with native128KLongRoPE context, Aphelion-Judge fits comfortably on single edge/consumer GPUs (or CPU/browser via 4-bit GGUF) while handling long passages at~2slatency on GPU. - Why Causal Micro-CoT (
reasonbeforegrounded)? Predicting a boolean token immediately after a long context compresses multi-claim comparison into one forward pass, causing high false-negative rates (0.562OOD F1 in our Direct-JSON baseline). Generating a single-sentence atomic audit (reason) before emittinggroundedgives the model explicit working memory, boosting OOD F1 by +20.5 points (0.562 -> 0.767) while keeping output compact (~43 tokensvs130+ tokensin verbose judges). - Why Baked-In First-Principles System Prompt?
The tokenizer's
chat_templateembeds a strict default system prompt enforcing zero outside knowledge, atomic claim decomposition, and uncertainty-as-ungrounded (false), guaranteeing consistent behavior acrosstransformersandvLLM(and mirrored insidegguf/Modelfilefor Ollama).
Reproducible Out-of-Distribution Benchmark (test_ood_pure, n=468)
All release evaluations are frozen and publicly auditable at knss12/aphelion-judge-eval-v1.
- Upstream Provenance: Derived from
PatronusAI/HaluBench/ RAGTruth OOD split (filtered zero-leakagetest_ood_pure, SHA-256:40057dd26c37157f...) - Class Distribution:
218Supported (grounded: true) /250Unsupported (grounded: false) - Pinned Release Commit:
52715d8aa2b1bbc9ee728c78ec31815679796167 - Decoding Contract:
temperature=0.0,do_sample=False,max_new_tokens=96 - Metric Definition: Binary response-level classification where the positive class is
FAIL(grounded == false, i.e., hallucinated/ungrounded). Strict JSON compliance measures validjson.loads()outputs containing a booleangroundedkey.
1. Frozen Release Audit: FP16 Safetensors vs. Quantized GGUF (Q4_K_M)
| Release Artifact | Strict JSON | OOD F1 (FAIL) | Precision (FAIL) | Recall (FAIL) | Accuracy | Avg Output Tokens | Latency p50 | Latency p95 |
|---|---|---|---|---|---|---|---|---|
Aphelion-Judge-3.8B (FP16 Safetensors, GPU) | 100.0% | 0.7669 | 0.7398 | 0.7960 | 74.15% | 42.86 | 1,994.3 ms | 3,138.4 ms |
Aphelion-Judge-3.8B (Q4_K_M GGUF, CPU) | 99.57% | 0.7686 | 0.7538 | 0.7840 | 74.79% | 42.68 | 16,481.3 ms | 62,077.3 ms |
Quantization Fidelity (
FP16 -> Q4_K_M): Delta OOD F1 is+0.0017, confirming virtually zero accuracy degradation when compressing the7.64 GBFP16 model down to the2.40 GBQ4_K_MGGUF artifact. Confusion matrices (FAILpositive):
- FP16:
TP=199,FP=70,TN=148,FN=51- GGUF
Q4_K_M:TP=196,FP=64,TN=154,FN=54
2. Ablation & Baseline Comparison (test_ood_pure, n=468)
| Model / Experiment | Params | Strict JSON | OOD F1 (FAIL) | Precision | Recall | Avg Output Tokens | Latency p50 (GPU) |
|---|---|---|---|---|---|---|---|
Phi-3.5-mini-instruct (Zero-Shot) | 3.82B | 0.00% | 0.652 | — | — | — | 1,740.0 ms |
Flow-Judge-v0.1 | 3.82B | — | 0.752 | — | — | ~130+ | 5,858.0 ms |
| Exp-01: Direct-JSON Baseline (No CoT) | 3.82B | 96.37% | 0.562 | 0.872 | 0.415 | 7.33 | 645.6 ms |
| Aphelion-Judge-3.8B (Merged FP16 Release) | 3.82B | 100.0% | 0.7669 | 0.7398 | 0.7960 | 42.86 | 1,994.3 ms |
3. Cross-Model Comparison (3B–72B Baselines)
| Model | JSON % | Acc % | F1-Fail | Precision | Recall | Avg Tokens | Latency p50 | Latency p95 |
|---|---|---|---|---|---|---|---|---|
| Aphelion-Judge-3.8B | 99.0% | 80.8% | 0.8013 | 0.8399 | 0.766 | 42.1 | 2,003.9 ms | 2,640.0 ms |
Phi-3-mini-4k (Base 3.8B) | 99.1% | 78.5% | 0.7512 | 0.9091 | 0.640 | 51.6 | 2,354.7 ms | 3,770.1 ms |
Qwen2.5-3B-Instruct | 99.7% | 71.7% | 0.7579 | 0.6622 | 0.886 | 39.7 | 2,633.9 ms | 3,652.4 ms |
Qwen2.5-7B-Instruct (4-bit) | 82.3% | 67.9% | 0.8053 | 0.8169 | 0.794 | 38.9 | 3,172.7 ms | 4,896.3 ms |
Qwen2.5-72B (Cloud API) | 100.0% | 88.9% | 0.8880 | 0.8961 | 0.880 | 44.3 | 1,234.5 ms | 2,107.2 ms |
Raw predictions (preds_fp16.jsonl, preds_gguf_q4_k_m.jsonl) and full metrics (audit_report.json) are published in knss12/aphelion-judge-eval-v1 for independent verification.
Training Summary
- Training Data: In-domain QA subset of
wandb/RAGTruth-processed, strictly separated from OODHaluBench. Train/validation splits were partitioned by context hash (GroupShuffleSplit) to guarantee zero passage leakage. - Supervision Format: Assistant-only completion loss masking (prompt tokens masked with
-100), training exclusively on compact Micro-CoT JSON verdicts ({"reason": "...", "grounded": true/false}). - Hyperparameters: 4-bit NF4 QLoRA (
r=16,alpha=32,dropout=0.05, double quantization),2epochs, effective batch size16(2per GPU ×4gradient accumulation steps ×2NVIDIA T4 GPUs via DDP), learning rate2e-4with cosine schedule (warmup_steps=20,weight_decay=0.01),fp16=True,max_seq_len=1792(max_ctx_tokens=1250). Best checkpoint selected by lowesteval_loss.
Quickstart
1. Python (transformers)
import json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "knss12/Aphelion-Judge-3.8B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
)
prompt = (
"Context:\nApple reported $23,646 million in cash and cash equivalents as of September 2023.\n\n"
"Question:\nHow much cash did Apple report?\n\n"
"Response:\nApple reported $50 billion in cash reserves."
)
inputs = tokenizer.apply_chat_template(
[{"role": "user", "content": prompt}],
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
).to(model.device)
with torch.inference_mode():
output_ids = model.generate(
inputs,
max_new_tokens=96,
do_sample=False,
)
verdict_raw = tokenizer.decode(
output_ids[0][inputs.shape[-1]:], skip_special_tokens=True
).strip()
verdict = json.loads(verdict_raw)
print(verdict)
Example Output:
{
"reason": "The Context states Apple reported $23,646 million in cash and cash equivalents, contradicting the Response's claim of $50 billion.",
"grounded": false
}
2. Local Deployment (Ollama / llama.cpp Q4_K_M)
huggingface-cli download knss12/Aphelion-Judge-3.8B --include "gguf/*" --local-dir .
ollama create aphelion-judge -f gguf/Modelfile
Note for direct
llama.cppusers:gguf/Modelfileembeds the full First-Principles system prompt and deterministic parameters (temperature 0,num_predict 96). If you invokeaphelion-judge-3.8b-Q4_K_M.ggufdirectly withllama-cliorllama-serverwithout Ollama, pass the system prompt fromgguf/Modelfileexplicitly.
Intended Use & Limitations
- Intended Use: Automated groundedness / faithfulness verification gates in RAG pipelines (checking whether a generated answer is strictly supported by retrieved context chunks).
- Not Intended For: Open-domain fact-checking without retrieved context, general conversational chat, or creative generation.
- Language Coverage: Trained and evaluated primarily on English (
en) text; performance on non-English RAG contexts has not been formally benchmarked. - Context Window: While the Phi-3.5-mini backbone natively supports up to
128Ktokens via LongRoPE, Micro-CoT fine-tuning was conducted withmax_seq_len=1792(max_ctx_tokens=1250). Very long multi-document contexts beyond4Ktokens should be chunked or validated on your domain before production deployment.
Citation
If you use Aphelion-Judge-3.8B or its evaluation benchmark in your work, please cite:
@misc{bagaskara2026aphelionjudge,
title = {Aphelion-Judge-3.8B: First-Principles Micro-CoT Judge for RAG Groundedness Verification},
author = {Bagaskara, P. Kanisius},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/knss12/Aphelion-Judge-3.8B},
note = {Merged QLoRA fine-tune of microsoft/Phi-3.5-mini-instruct for RAG groundedness verification}
}