Prism-T5Gemma2-4B

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)

Backbone Paradigm Vision Format License


Overview

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:

  1. Compressed Reranking & Multi-Hop Retrieval (Lychee / KaLM-R2 + INTRA): Score hundreds of cached text or image documents via hierarchical MEP compression (r=16 -> r=2) and Reverse-QWK memory compression (54x–870x smaller than FP16 cross-KV).
  2. Calibrated System-One Decisions (Bongard): Run typed probabilistic judgments β€” 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.

Prism-T5Gemma2-4B Complete Transformer Micro-Architecture & Token Journey

*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%).*


Why Non-Autoregressive?

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:

  • Zero token-by-token decoding loops β€” every query completes in a single forward pass with calibrated probabilities.
  • Drop-in companion for any external LLM β€” handle fast retrieval, compression, multimodal reranking, fact/null verification (noul), rubric grading (score), and routing (choice) locally in milliseconds.

Reranker vs. Decision Model: Overlap & Synergy

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

Pointwise Search Funnel vs. Listwise System-One Judge (Animated 2-Hop Flow)

Aren't They Both Just "Ranking"?

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:

  1. Closed-Door Audition (Pointwise) vs. Courtroom Debate (Listwise): A reranker evaluates each document in isolationβ€”when scoring Document A, it has no knowledge of Document B, and sorting happens externally in Python. A Bongard Decision Model places all candidates into a single decoder sequence ([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.
  2. Rank Order vs. Honest Probability (Calibration): If a reranker scores a relevant doc 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.
  3. The Librarian vs. Judge Analogy: Think of KaLM/Lychee as a high-speed librarian pulling the top-3 relevant files out of 1,000 compressed shelves, and Bongard as the judge who reads those 3 files on the desk, weighs all competing options simultaneously, and delivers a calibrated verdict (choice, noul, or score).

Flexibility and True Stacking (1 + 1 > 2)

Combining these three papers into one model delivers both deployment flexibility and genuine cross-paper capability stacking:

  • Modular Flexibility (1 Model, Pick Your Mode): Load a single ~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.
  • True Cross-Paper Stacking (1 + 1 > 2):
    1. INTRA RQWK Γ— Lychee MEP (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.
    2. KaLM MEP β†’ Bongard Compression Resilience: Pure 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).
    3. Bongard Multimodal β†’ Zero-Shot KaLM Image Reranking: 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.
    4. Zero Re-Encoding Funnel β†’ Judge + De-Anisotropy: Documents selected by KaLM flow directly as cached encoder tensors into Bongard with zero online encoder calls, while encoder anisotropy drops from 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.43 vs. +0.88 pure; Bongard logits require the rescaled merged temperatures provided in temperatures.json), while preserving 100% task accuracy across our evaluation suite. Choose Prism-T5Gemma2-4B when you want one unified, multimodal, memory-compressed Funnel + Judge engine; keep separate specialists only if you optimize exclusively for the final fraction of raw margin on a single task regardless of VRAM cost.


Parameter Orthogonality & INTRA Mathematical Compression

Direct audit across all 1,327 tensors of google/t5gemma-2-4b-4b confirms that Ξ”W_KaLM and Ξ”W_Bongard occupy almost perfectly orthogonal subspaces (cos = 0.0013 in encoder attention, 0.0007 in decoder attention, and 0% overlap across all 204 MLP tensors, 410 norms, o_proj, and output heads).

Because T5Gemma-2 applies RoPE only to decoder self-attention, INTRA's Reverse-QWK identity holds algebraically over our merged weights:

qlKl⊀=((qlβŠ™Ξ³K,l)WK,l)⏟q~lkΛ‰βŠ€,kΛ‰=RMSNorm(H)q_l K_l^\top = \underbrace{\big((q_l \odot \gamma_{K,l}) W_{K,l}\big)}_{\tilde{q}_l} \bar{k}^\top, \qquad \bar{k} = \text{RMSNorm}(H)

Combined with Lychee Hierarchical MEP and INT8 quantization, cross-memory shrinks up to 870.4x per 1K tokens while deriving coarser compression levels directly from a single r=2 cache:

kΛ‰(32)[j]=116βˆ‘t=015kΛ‰(2)[16j+t]\bar{k}^{(32)}[j] = \frac{1}{16}\sum_{t=0}^{15} \bar{k}^{(2)}[16j + t]

Parameter Orthogonality and Cross-Memory Compression

Merge Recipe (Split: K1 + B_mlp0.5)

WPrism=Wbase+1.0 ΔWKaLM+Ξ²role ΔWBongard,Ξ²role={1.0if encoder_mlp0.5otherwiseW_{\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} \\ 0.5 & \text{otherwise} \end{cases}


Context Window & Merged Attention Token Flow

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:

  • Independent RoPE Index Spaces (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.
  • Merged Self + Cross Attention Width (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).
  • Practical Context Budgets: Because encoder states are computed once offline and compressed via MEP (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.

Encoder-Decoder Context Window & Merged Attention Token Flow


Multimodal Image Support

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:

  • Multimodal System-One Decisions (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.
  • Zero-Shot Multimodal Image Reranking (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.
  • Compressed Visual Tokens (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.

Reproducible Benchmarks (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.486 -> +0.435, 35.9–37.5 ms)
Bongard choice bongard_eval.jsonl β€” 6 Decision Tasks (2–4 options, reversed order, rule induction, logic) 6/6 (100%) (mean confidence 0.714)
Bongard noul bongard_eval.jsonl β€” True / Contradicted / Missing-Null Verification 3/3 (100%) (p_true = 0.824 supported, p_false = 0.882 contradicted, p_false = 0.745 null)
Bongard score bongard_eval.jsonl β€” 0–4 Ordinal Rubric Grading (accurate vs. off-topic) 2.79 / 4.0 (level 3) vs. 0.34 / 4.0 (level 0, p=0.837)
Bongard judge_many benchmark_suite.py β€” 1 Encoder Pass -> 3 Mixed Questions (noul + choice + score) 100% (212.8 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.694), r=4 (0.653), r=8 (0.417)
Unified 2-Hop Pipeline multihop_eval.jsonl β€” Offline r=2 cache (78.4x comp.) -> Hop-1 + Bridged Hop-2 -> Judge Hop-1 3/3 | Hop-2 3/3 | Answer 3/3 (0.88–0.94 conf, ~310 ms, 0 online encoder calls)
INTRA & Hydragen Math benchmark_suite.py β€” Exact RQWK / k_bar cos / Hierarchical MEP / Hydragen LSE 1.22e-4 / 0.9971 / 5.96e-8 / 3.91e-3

4-Bit NF4 Variant (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.89 GB / 5.61 GB (fits 6 GB GPUs)
Reload Speed (from disk) β€” 2.29 s
Lychee / KaLM Rerank (r=2, 4, 8, 16) 100% (r=4 mrg +0.430) 100% (r=4 mrg +0.404)
Bongard noul (True / False / Null) 3/3 (100%) 3/3 (100%)
Bongard score (0–4 Rubric) 2.79 vs 0.34 2.68 vs 0.37
Bongard judge_many (1 pass -> 3 Qs) 100% (212.8 ms) 100% (330.3 ms)
Bongard choice (6 tasks) 6/6 (100%) 5/6 (rule_3opt borderline)
Bongard Long-Doc MEP (r=1, 4, 8) OK (r=1, 4, 8) OK (r=1, 4, 8)
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.91+ conf)

Full NF4 results are recorded in eval/benchmark_results_nf4.json.


Quickstart & Feature Recipes

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")

1. Compressed Reranking & Test-Time Cascade (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,
)

2. Bongard Typed Primitives (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"]},
    },
)

3. Multimodal Image Judgment & Zero-Shot Image Reranking

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)

4. End-to-End 2-Hop Unified Pipeline & Benchmark Suite

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

Repository Structure

.
β”œβ”€β”€ 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

License & Upstream Attribution

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.

  • T5Gemma 2: Zhang et al., T5Gemma 2: Seeing, Reading, and Understanding Longer, arXiv:2512.14856 (google/t5gemma-2-4b-4b).
  • Lychee / KaLM-Reranker-V1: HITsz-TMG, Lychee-Reranker: Fast but Not Late Interaction for Compressed Document Reranking, arXiv:2606.22807 (KaLM-Embedding/KaLM-Reranker-V1-Large-R2).
  • Bongard: AgentBull Pte Ltd, Bongard: Training Machine Intuition, arXiv:2609.39111 (AgentBull/bongard-mini).
  • INTRA: Hoffer et al. (NVIDIA & Technion), Retrieval from Within: An Intrinsic Capability of Attention-Based Models, arXiv:2605.05806.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for daruokta/prism-t5gemma2-4b

Finetuned
(1)
this model

Papers for daruokta/prism-t5gemma2-4b