One Bidirectional Multimodal Encoder-Decoder Backbone. Three Non-Autoregressive Paradigms. Compressed Reranking (Lychee/KaLM-R2) · System-One Calibrated Judgment (Bongard) · Reverse-QWK Memory Mechanics (INTRA)
Prism-T5Gemma2-4B unifies the complementary, nearly orthogonal adaptations of Lychee / KaLM-Reranker-V1-Large-R2 and Bongard-Mini onto their shared google/t5gemma-2-4b-4b base weights, paired with the algebraic memory mechanics of INTRA (Reverse-QWK) and Hydragen (Partitioned LSE Attention).
Just as a prism refracts a single beam of light into distinct wavelengths, Prism-T5Gemma2-4B encodes text or image evidence once and refracts that single cached encoder state into:
r=16 -> r=2) and Reverse-QWK memory compression (54x–870x smaller than FP16 cross-KV).choice (2–255 options), noul (True / False / Null verification), score (2–10 ordinal rubric grading), multi-question single-state batching (judge_many), and JEPA scoped representations — directly over the same cached encoder states.*End-to-end single-pass token journey on a real multimodal example ([invoice_orion.png] + 1,024-token document): Phase 1 encodes 256 visual + 1,024 text tokens once through the 34-layer bidirectional 4-norm sandwich encoder (H_enc [1,280, 2560]); Phase 2 compresses them offline via hierarchical Lychee MEP (1,280 -> 320 -> 80 tokens) and RoPE-free INTRA INT8 k_bar (870.4x smaller); Phase 3 runs single-pass 34-layer decoder Merged Self+Cross Attention (concat(K_self, K_cross)); Phase 4 reads out both heads simultaneously — KaLM P(yes) = 0.964 (Rank #1) and Bongard choice = "2026-03-14" (94.2%) / noul = True (88.2%).*
google/t5gemma-2-4b-4b is a pretrained base checkpoint (no official instruction-tuned release), and neither KaLM-Reranker-V1-Large-R2 nor AgentBull/bongard-mini is trained with autoregressive chat objectives.
Rather than forcing noisy free-form text generation out of discriminative weights, Prism-T5Gemma2-4B is built strictly as a Non-Autoregressive Discriminative & Retrieval Engine:
noul), rubric grading (score), and routing (choice) locally in milliseconds.Both a Reranker (KaLM/Lychee) and a Decision Model (Bongard) score inputs without generating text—P(yes | query, doc) resembles a binary noul check, while choice/score can rank a small set of candidates. Yet they operate on opposite scaling axes and solve complementary problems:
| Dimension | KaLM / Lychee Reranker (lm_head yes/no) |
Bongard System-One (JudgmentHead bilinear) |
|---|---|---|
| Scaling Axis | 1 Query × Many Documents (100–10,000 cached chunks) | 1 Evidence State × Many Questions & Options |
| Comparison Geometry | Pointwise (Independent): Doc A never sees Doc B | Listwise (Comparative): Global vector g at <decision_end> interacts multiplicatively with every candidate h_i via (W_c h_i)^T (W_g g) / √256 |
| Extreme Compression | Trained for MEP r=2..128 & Cascade r=16->2 — 100% accuracy at 16x compression |
Sharpest at r=1..8 for fine-grained reading over narrowed evidence |
| Probability Semantics | Optimized for rank ordering (nDCG/MRR) | Trained with Proper Scoring + Temperature Scaling for true/false/null abstention, risk thresholds, and expected ordinal scores |
| Best Use Cases | Search & Triage Funnel: RAG top-100->top-5, multi-hop chaining, long-memory dialogue search, multimodal image search | Judge & Router: Fact/hallucination check (noul), multi-class routing (choice), rubric grading 0–4 (score), visual OCR QA, agent actions |
At first glance both models output numerical scores, so it is tempting to view a Decision Model as just a reranker run differently. Technically, they differ in three fundamental ways:
[opt_1 <cand>, ..., opt_K <cand>, <decision_end>]) so the global readout g can cross-compare and down-rank Option A specifically because Option B is stronger or contradicts it.0.91 and an irrelevant doc 0.85, ranking is 100% correct—yet 0.85 is a misleading probability for automated action. System-One models are trained with proper scoring rules so 80% truly means ~80% empirical accuracy, ambiguous evidence stays honest near 50/50 (enabling safe abstention/null detection), and ordinal expected scores (E[score] = Σ k · P(k)) are mathematically meaningful.choice, noul, or score).1 + 1 > 2)Combining these three papers into one model delivers both deployment flexibility and genuine cross-paper capability stacking:
~15 GB BF16 checkpoint instead of running 2–3 separate specialist servers. Call only what each request needs—text/image reranking, binary noul verification, multi-class choice, ordinal score, batched judge_many, or JEPA representations.1 + 1 > 2):870.4x Compression): INTRA compresses cross-KV 54.4x (FP16 KV → INT8 k_bar) and Lychee MEP compresses sequence length 4x–16x; stacked together they cut cross-memory from 142.61 MB to 0.16 MB per 1K tokens from a single r=2 cache.bongard-mini was never trained with MEP pooling and degrades under heavy compression (r=16); inheriting KaLM's MEP-trained encoder attention keeps Bongard accurate on compressed long documents (r=1..8) and 4x-compressed visual tokens (256 -> 64 tokens per image).KaLM-Reranker-V1-Large-R2 was trained strictly on text, yet stacking Bongard's adapted multi_modal_projector over the intact 417M SigLIP encoder unlocks zero-shot image reranking directly in the KaLM head—even at r=4 visual compression.0.833 (base) and 0.673 (Bongard) down to 0.459.Honest Trade-Off: Static weight merging without retraining slightly narrows raw logit margins compared to standalone specialists (e.g., KaLM raw margin
+0.44–0.49vs.+0.88pure; Bongard logits use the rescaledmergedtemperatures inweights/head/temperatures.json), while preserving100%task accuracy across both BF16 and 4-bit NF4 evaluation suites. Note also thatCorpusCacheholds both INT8k_bar(for compressed RQWK) and BF16 MEPhidden_states(for cross-attention), reported separately alongsidetotal_cache_mbinmemory_report().
Direct audit across all 1,327 tensors of google/t5gemma-2-4b-4b confirms that ΔW_KaLM and ΔW_Bongard occupy nearly orthogonal subspaces (cos = 0.0013 in encoder attention, 0.0007 in decoder attention, and 0% overlap across all 344 Bongard-only encoder/multimodal tensors — encoder.mlp, encoder.self_attn.o_proj, encoder.*norm, multi_modal_projector, and eoi_embedding).
Because T5Gemma-2 applies RoPE only to decoder self-attention queries/keys (q_l is rotated before dot-product while K_cross has no RoPE), exact INTRA Reverse-QWK holds over our merged weights using per-key RMS scaling s_K = rsqrt(mean((H W_K^T)^2) + eps), while a single layer-agnostic k_bar (normalize-then-pool with exact token-count weighting across hierarchical MEP levels) retains cos = 0.9615 on real anisotropic encoder states:
$$q_l K_l^\top = s_{K,l}(H) \odot \Big(\underbrace{\big((\text{RoPE}(q_l) \odot \gamma_{K,l}) W_{K,l}\big)}_{\tilde{q}_l} H^\top\Big), \qquad \bar{k}^{(r)} = \text{Norm}!\left(\text{MEP}_r\big(\text{RMSNorm}(H),, \text{counts}\big)\right)$$
Split: K1 + B_only1.0 + B_dec0.5, FP32 Accumulation)$$W_{\text{Prism}} = W_{\text{base}} + 1.0,\Delta W_{\text{KaLM}} + \beta_{\text{role}},\Delta W_{\text{Bongard}}, \quad \beta_{\text{role}} = \begin{cases} 1.0 & \text{if } \text{encoder_{mlp, o_proj, norm}} \cup {\text{mm_proj}, \text{eoi}} \ 0.5 & \text{otherwise (shared / decoder)} \end{cases}$$
In T5Gemma 2 / Prism-T5Gemma2-4B, encoder and decoder positional capacities are independent, while the decoder's merged softmax sums active KV columns from both sides:
0 .. N_enc - 1 & Reset 0 .. N_dec - 1): Both stacks declare their own max_position_embeddings = 131072. Because decoder cross-keys (K_cross = k_norm(W_K · H_mep)) apply no RoPE, even a 32K–131K encoder context consumes zero decoder RoPE positions — the decoder always starts fresh from position 0.concat(K_self, K_cross)): Every decoder layer attends jointly over [K_self ; K_cross] in one softmax. Crucially, the sliding_window = 1024 mask on the 5/6 local SWA decoder layers clips only K_self while keeping K_cross 100% unclipped (min(N_dec, 1024) + N_enc/r columns on SWA layers; N_dec + N_enc/r on every 6th global layer).r=2..16) + INTRA INT8 (k_bar), an asymmetric budget (long N_enc in static memory + short single-pass N_dec prompts/options) lets this 8B-total NF4 model handle long contexts comfortably inside 6 GB laptop VRAM.Because the 417M SigLIP vision tower from google/t5gemma-2-4b-4b remains 100% intact and AgentBull/bongard-mini adapts multi_modal_projector on multimodal data, Prism-T5Gemma2-4B natively accepts image + text inputs across both discriminative heads:
encode_image_state + judge_*): Encode one or more PIL images (256 SigLIP visual tokens per image) together with text instructions and evaluate choice, noul (visual verification / OCR checks), or score (rubric rating) directly over the visual encoder states.rerank_images): Score and rank collections of PIL images against natural-language queries (monolingual or cross-lingual) using the KaLM/Lychee head—without any image-reranking retraining.chunk_size=4): Apply Lychee MEP pooling directly over the 256 visual tokens per image (256 -> 64 tokens) to cut online decoder compute on both image reranking and visual judgment.eval/)Every number below is reproducible directly from the uploaded safetensors shards using python eval/benchmark_suite.py --model-path . --variant bf16 against the bundled datasets in eval/datasets/ (full output recorded in eval/benchmark_results_bf16.json):
| Capability | Bundled Evaluation Suite | Result |
|---|---|---|
| Lychee / KaLM Reranking | rerank_eval.jsonl — Pairwise Accuracy at r=2, 4, 8, 16 |
100% at all levels (margin: +0.494 -> +0.446, 25.9–27.6 ms at r>=4) |
Bongard choice |
bongard_eval.jsonl — 6 Decision Tasks (2–4 options, reversed order, rule induction, logic) |
6/6 (100%) (mean confidence 0.723) |
Bongard noul |
bongard_eval.jsonl — True / Contradicted / Missing-Null Verification |
3/3 (100%) (p_true = 0.800 supported, p_false = 0.882 contradicted, p_false = 0.746 null) |
Bongard score |
bongard_eval.jsonl — 0–4 Ordinal Rubric Grading (accurate vs. off-topic) |
2.82 / 4.0 (conf 0.496) vs. 0.31 / 4.0 (conf 0.847) |
Bongard judge_many |
benchmark_suite.py — 1 Encoder Pass -> 3 Mixed Questions (noul + choice + score) |
100% (210.2 ms total for all 3 isolated questions) |
| Bongard + Lychee MEP | bongard_eval.jsonl — Long-Document Retrieval Decision (608 tokens, 4-way cyclic rotation) |
Correct at r=1 (0.751), r=4 (0.726), r=8 (0.471) |
| Unified 2-Hop Pipeline | multihop_eval.jsonl — Offline r=2 cache (78.4x k_bar / 26.1x total) -> Hop-1 + Bridged Hop-2 -> Judge |
Hop-1 3/3 | Hop-2 3/3 | Answer 3/3 (0.886–0.933 conf, 237–248 ms, 0 online encoder calls) |
| INTRA, MEP & Hydragen | benchmark_suite.py — RoPE RQWK / Real-Enc k_bar cos / L=53 r=2->16 MEP / Bridged Trunc. Guard / Hydragen LSE |
8.39e-5 / 0.9615 / 4.77e-7 / True / 7.81e-3 |
weights/nf4/)This repository includes a pre-quantized, calibration-free BitsAndBytes NF4 + Double Quantization variant under weights/nf4/ (llm_int8_skip_modules=["multi_modal_projector", "lm_head"], compute_dtype=bfloat16). Both weights/bf16/ and weights/nf4/ share tokenizer/ and weights/head/ with zero file duplication, and the NF4 variant runs natively on Windows and Linux CUDA GPUs with 6 GB+ VRAM (pip install bitsandbytes accelerate).
Metric (eval/benchmark_suite.py) |
BF16 (weights/bf16/) |
4-Bit NF4 (weights/nf4/) |
|---|---|---|
| Weight Size on Disk | 15.05 GB |
4.89 GB (3.08x smaller) |
| VRAM (Load / Peak) | ~15.05 GB |
4.90 GB / 5.02 GB (fits 6 GB GPUs) |
| Reload Speed (from disk) | — | 4.45 s |
Lychee / KaLM Rerank (r=2, 4, 8, 16) |
100% (r=4 mrg +0.440) |
100% (r=4 mrg +0.425) |
Bongard noul (True / False / Null) |
3/3 (100%) |
3/3 (100%) |
Bongard score (0–4 Rubric) |
2.82 vs 0.31 |
2.76 vs 0.29 |
Bongard judge_many (1 pass -> 3 Qs) |
100% (210.2 ms) |
100% (310.9 ms) |
Bongard choice (6 tasks) |
6/6 (100%) |
6/6 (100%) (conf 0.715) |
Bongard Long-Doc MEP (r=1, 4, 8) |
OK (0.751 / 0.726 / 0.471) |
OK (0.747 / 0.711 / 0.573) |
| Unified 2-Hop Pipeline | Hop-1 3/3 | Hop-2 3/3 | Ans 3/3 |
Hop-1 3/3 | Hop-2 3/3 | Ans 3/3 (0.920–0.930 conf) |
Multimodal Image Choice & Rerank (r=4) |
Red circle (0.929), [0.740, 0.260] |
Red circle (0.948), [0.801, 0.311] |
Full NF4 results are recorded in eval/benchmark_results_nf4.json.
from prism_t5gemma2 import PrismT5Gemma2
# Option A: Full BF16 weights (~15 GB VRAM)
prism = PrismT5Gemma2.from_pretrained("<path-or-repo-id>", variant="bf16")
# Option B: Pre-quantized 4-Bit NF4 variant (~4.9 GB VRAM — fits 6 GB Windows/Linux GPUs)
# Requires: pip install bitsandbytes accelerate
prism = PrismT5Gemma2.from_pretrained("<path-or-repo-id>", variant="nf4")
r=16 -> r=2)docs = [
"Lychee-Reranker applies Multi-granularity Encoder Pooling (MEP) to compress encoder tokens.",
"Bongard trains a 1.31M bilinear head over T5Gemma-2 hidden states.",
"ColBERT stores per-token embeddings for late-interaction MaxSim.",
]
cache = prism.encode_corpus_cache(docs, base_chunk_size=2, quantize_kbar_int8=True)
print(cache.memory_report())
ranked = prism.rerank_cascade(
"How does Lychee-Reranker compress tokens?",
cache,
coarse_chunk_size=16,
fine_chunk_size=2,
top_k=2,
)
noul, score, choice, judge_many)# True / False / Missing-Null Guardrail
noul = prism.judge_noul(
state_text="Meeting notes: Discussed Q3 server migration schedule and backup policies.",
instructions="Does the text specify the exact budget in USD for the migration?",
)
# 0..4 Ordinal Rubric Grading
score = prism.judge_score(
state_text="Caching encoder outputs offline lets queries reuse pooled states without re-encoding.",
instructions="Rate the technical clarity and accuracy of this explanation.",
rubric=["Off-topic", "Mostly wrong", "Vague", "Accurate and clear", "Exceptional"],
)
# 1 Encoder Pass -> Multiple Isolated Questions
many = prism.judge_many(
state_text="Order #501: Express shipping to Tokyo. Payment verified ($180).",
questions={
"paid": {"type": "noul", "instructions": "Has payment been verified?"},
"dest": {"type": "choice", "instructions": "Destination city?", "options": ["Osaka", "Tokyo", "Seoul"]},
"clarity": {"type": "score", "instructions": "Completeness?", "rubric": ["Poor", "Fair", "Good", "Great"]},
},
)
from PIL import Image
img = Image.open("invoice.png").convert("RGB")
enc_hs, enc_mask = prism.encode_image_state(
[img],
state_text="Inspect the attached document image.",
question_instructions=["Has this invoice been paid?"],
chunk_size=4, # 4x MEP compression on 256 visual tokens!
)
paid = prism.judge_noul(None, "Has this invoice been paid?", encoder_hidden_states=enc_hs, encoder_attention_mask=enc_mask)
# Zero-shot image reranking across multiple PIL images
scores = prism.rerank_images("Find the document image showing a settled payment receipt.", [img1, img2, img3], chunk_size=4)
result = prism.unified_pipeline(
query="What river flows through the birthplace of the Analytical Engine designer?",
cache=cache,
documents=corpus,
options=["River Thames", "Nile River", "Amazon River", "Danube River"],
)
# Benchmark BF16 weights
python eval/benchmark_suite.py --model-path . --variant bf16
# Benchmark 4-Bit NF4 weights (6 GB+ GPU)
python eval/benchmark_suite.py --model-path . --variant nf4
.
├── README.md # Model card & documentation
├── prism_t5gemma2.py # Unified Python runtime (BF16 + NF4, Text + Images)
├── prism_merge_config.json # Reproducible merge recipe & orthogonality audit
├── weights/
│ ├── bf16/ # Full-precision BF16 backbone (15.05 GB)
│ │ ├── config.json
│ │ ├── model.safetensors.index.json
│ │ └── model-00001..00004.safetensors
│ ├── nf4/ # Pre-quantized 4-Bit BitsAndBytes NF4 backbone (4.89 GB)
│ │ ├── config.json
│ │ ├── model.safetensors.index.json
│ │ └── model-00001..00002.safetensors
│ └── head/ # Shared Bongard 1.31M bilinear head & calibration
│ ├── head.safetensors
│ └── temperatures.json
├── tokenizer/ # Shared tokenizer & multimodal SigLIP processor
│ ├── tokenizer.json
│ ├── tokenizer_config.json
│ └── processor_config.json
├── assets/ # Animated token-flow GIFs & benchmark chart
│ ├── prism_architecture_animated.gif
│ ├── token_window_flow_animated.gif
│ ├── funnel_vs_judge_animated.gif
│ └── compression_and_orthogonality.png
└── eval/ # Standalone evaluation suite, datasets & results
├── benchmark_suite.py
├── benchmark_results_bf16.json
├── benchmark_results_nf4.json
└── datasets/
├── rerank_eval.jsonl
├── bongard_eval.jsonl
└── multihop_eval.jsonl
Distributed under the Gemma Terms of Use (gemma), inherited from google/t5gemma-2-4b-4b and AgentBull/bongard-mini. KaLM-Embedding/KaLM-Reranker-V1-Large-R2 is licensed under Apache-2.0.
arXiv:2512.14856 (google/t5gemma-2-4b-4b).arXiv:2606.22807 (KaLM-Embedding/KaLM-Reranker-V1-Large-R2).arXiv:2609.39111 (AgentBull/bongard-mini).arXiv:2605.05806.weights/nf4/model-00001-of-00002.safetensors 3.7 GiBweights/bf16/model-00002-of-00004.safetensors 3.7 GiBweights/bf16/model-00003-of-00004.safetensors 3.7 GiBweights/bf16/model-00001-of-00004.safetensors 3.7 GiBweights/bf16/model-00004-of-00004.safetensors 2.9 GiBweights/nf4/model-00002-of-00002.safetensors 851 MiBweights/head/head.safetensors 3 MiBAgentBull/bongard-mini