Cancer of Unknown Primary:
AI-powered origin analysis

GUT is a fine-tuned local model that grades cancer workups — predicting the primary tumour origin from molecular evidence, IHC markers, and clinical data. Trained on 1,750+ labeled cases. Runs entirely on your hardware.

research demo not a medical device synthetic data only

What this system does

▸Handles cancer report classification — a 24-class origin distribution from molecular evidence
▸Uses proper statistical analysis — Shapley feature attribution, calibrated probability distributions, reinforcement learning scored by proper scoring rules
▸Reports the jargon in plain terms — every output includes a summary of what the model found, what it means, and how confident it is
▸Trains on images for detection and confidence — a ViT vision head on 25,000+ dermoscopic images (macro AUC 0.93) feeds the decision model
▸Self-improving — every verdict becomes training data for the next model. The more it runs, the better it gets
▸Reporting functionality — exports gate tables, evaluation ledgers, and per-case decisions as structured JSON

What is Cancer of Unknown Primary?

CUP means cancer has spread (metastasised) but doctors haven't found where it started. It accounts for 3-5% of all cancer diagnoses. Knowing the origin is critical because it determines treatment — but finding it is one of the hardest challenges in oncology.

Doctors collect evidence: histology (what cells look like), IHC stains (which proteins they express), and gene mutations (molecular panel). From this, they infer the original site.

In plain terms: cancer showed up somewhere but nobody knows where it started. The doctor plays detective using lab results. GUT helps by grading that evidence locally — without sending patient data to the cloud.

Why is finding the primary useful?

When cancer spreads, treatment depends on where it started, not where it landed. A colon cancer that spreads to the liver is treated with colon cancer drugs, not liver cancer drugs. If the primary is never found, doctors have to guess — and CUP patients have worse survival partly because the treatment is less targeted.

An AI origin call helps by:

→ Narrowing the search (if the model says "likely lung," the doctor orders a bronchoscopy next, not a colonoscopy)

→ Suggesting targeted therapy paths (a BRCA-mutated ovarian pattern means PARP inhibitors are on the table)

→ Flagging when the evidence is too weak to decide (the model says "insufficient" and recommends a repeat biopsy rather than guessing)

What is the training data, exactly?

Where it comes from: The JOSH project (by SampleBias, an independent researcher on GitHub) created a set of 1,750 invented cancer patients. Each is a completely synthetic workup — no real patient data — designed to cover the full range of CUP presentations: lung patterns, intestinal patterns, insufficient evidence, breast, gynecologic, and more.

What each workup contains: A structured TSV file with 20-25 typed evidence rows: the patient's age and sex, what the biopsy looks like under a microscope, which of 7-8 protein markers are positive or negative, which of 10 genes have mutations (with tested scope, coverage depth, and detection limits), and what the imaging shows.

How it was labeled: Each workup was sent once to the Jev cloud teacher, which produced a probability distribution over 24 possible cancer origins plus two uncertainty checks. Those soft probability distributions are the training labels — they preserve the teacher's uncertainty rather than forcing a single hard answer.

Honest limitation: The data is synthetic. It tests whether the system can learn to grade evidence the way an expert does, but it has NOT been validated on real patient data. Clinical validation would require real (de-identified) CUP workups from a hospital partner. This is why the page says "research demo — not a medical device."

What is JOSH and why does it matter here?

JOSH (Jev Onco Statistical Hierarchy) is an independent, open-source research tool created by SampleBias on GitHub. It defined the methodology: the three questions we ask (origin, sufficiency, conflict), the validation rules, the conservative gate thresholds, and the fixture format. We followed their design exactly and credit them (MIT licence). Without JOSH, this page would not exist — it provided the blueprint.

How GUT actually works (the honest version)

GUT is not one model that does everything. It is a local serving architecture that hosts multiple specialist models behind one endpoint. Each specialist is a separate fine-tuned copy of the same base architecture, trained on its own domain's data. You select which specialist answers by setting a header (X-Laya-Domain: cup-origin).

The value is: one API, one gate system, one privacy guarantee — not one universal brain. The medical specialist knows cancer origin. The browser specialist knows website navigation. They share nothing except the serving infrastructure.

This is why the sell points say "self-improving" — each specialist independently gets better as its domain collects more data through use.

Why specialists instead of one generalist model?

This is a genuine design tradeoff, not a marketing choice. Here's the honest reasoning:

The case for one generalist (training on everything together):

→ Patterns from one domain might transfer to another — a model that learns "how to hedge when uncertain" from medical cases might apply that to browser decisions

→ One checkpoint to manage instead of twelve

→ Larger models (70B+) can hold many domains without interference

Why we chose specialists instead:

→ The model is small (421M). A large model has spare capacity to hold many skills; a small model stretched across 12 domains would be mediocre at all of them. Specialists let each domain use the full 421M capacity for its own patterns.

→ Our domains share almost nothing. Cancer origin analysis reads molecular panels. Browser navigation reads link text. RF classification reads signal patterns. There is no meaningful transfer between them — training them together would not make any of them better, just slower to train.

→ Calibration is domain-specific. The gate checks whether a model's stated confidence matches its actual accuracy. A model calibrated for 24-option medical questions might not be calibrated for 3-option browser decisions. Separate specialists let us calibrate and gate each one independently.

→ Data volumes are wildly asymmetric. One domain has 16,000 training examples, another has 241. Training together would mean the small domains are drowned out by the large ones. Separate training means each domain gets the attention its data deserves.

→ Privacy isolation. A medical specialist never touches browser data. A browser specialist never sees patient evidence. This matters for sensitive deployments.

The tradeoff we accept: we lose the possibility of cross-domain transfer (which is minimal for our domains), and we need slightly more storage (12 checkpoints instead of 1). In exchange, each domain gets the best possible specialist, calibrated independently, gated independently, and improvable independently without touching any other domain.

How it works

1

Evidence

Molecular panel, IHC, histology, demographics from a workup.

2

Inference

24-class origin probability distribution.

3

Gates

Agreement ≥ 0.85, ECE ≤ 0.10, no collapse.

4

Verdict

PASS → serve locally. FAIL → more data.

Real case analyses

Click through real synthetic workups from the JOSH fixture collection. Use arrow keys or click the dots. Each case shows the evidence, both models' origin distributions, and the gate verdict.

CASE 001 - Pulmonary pattern
67yo male, 30 pack-year smoker. Mediastinal + hilar nodes showing moderately differentiated adenocarcinoma. IHC: TTF-1+ (80%) Napsin A+ (60%) CK7+ CK20- CDX2- SATB2-. Molecular: KRAS 2 (G12C,G13D) TP53 1 STK11 1 EGFR 0. Imaging: bilateral pulmonary nodules, no dominant lung mass.

JEV CLOUD (teacher)

NSCLC
42%
COADREAD
11%
STAD
6%

GUT LOCAL

NSCLC
38%
COADREAD
24%
STAD
9%
TTF-1 is a protein found in lung cancers. When 80% of cells stain positive, it strongly points toward lung origin. KRAS G12C is essentially a smoking signature in DNA form.
REVIEW REQUIRED - lung pattern detected but unconfirmed

← → arrow keys · auto-advances every 6 seconds

What do these numbers mean?

The probability bars show the model's best guess at where the cancer started, expressed as percentages. A bar at 42% for "NSCLC" means the model thinks there's a 42% chance this cancer originated in the lungs (NSCLC = non-small cell lung cancer, the most common type).

"REVIEW REQUIRED" means the model isn't confident enough to make a definitive call. This is a feature, not a bug — an uncertain model that admits uncertainty is safer than an overconfident one that doesn't. In clinical practice, this would mean the doctor reviews the case with additional tests.

"ABSTAIN" means the model looked at the evidence and decided there simply isn't enough information to make any call. Case 003 is a good example — the biopsy sample was too damaged to test reliably. The model refuses to guess.

Jev vs GUT shows the cloud teacher's judgment (left) alongside the local model's judgment (right). When they agree, the local model has successfully learned from the teacher. When they differ, that's interesting — either the local model has found a pattern the teacher missed, or it's making an error. The calibration gate checks for this.

Interactive data analytics

Explore how the model reaches its decision — which features push the prediction, how the two models compare, and whether the model's confidence is trustworthy. Hover any bar for explanations.

Shapley reference (from JOSH)

The original Shapley attribution from JOSH, showing which evidence drove an NSCLC classification. Real output from JOSH — the interactive chart above is our interpretation of the same data.

JOSH Shapley attribution

Feature contributions — Case 001 (NSCLC pattern)

Click a row to expand its explanation. Green = supports the classification, red = opposes.

Calibration gate — CUP results

Every checkpoint faces three thresholds on held-out data. These are the cup-origin training runs. No model that fails is ever deployed.

≥ 0.85
teacher agreement
≤ 0.10
calibration error
< 20%
crash bucket limit
RunRowsAgreementECEGate
cup-origin r31,7500.9730.539FAIL
cup-origin r21,7500.9350.532FAIL
cup-origin r12500.8000.537FAIL

Agreement scales with volume (r1→r3: 0.80→0.973). Calibration is the remaining challenge. No model that fails is ever deployed.

1,750
labeled workups
24
origin classes
0.973
best agreement
~20ms
per decision (GPU)
$0
marginal cost

How the model is trained

GUT learns the same way a medical resident does: by watching an expert make thousands of calls, then practising under supervision until its judgments match. Here's exactly how that works.

Step 1: The expert makes a call

When a cancer workup comes in, it goes to the cloud teacher (Jev, by TypeSafe AI). The teacher reads the evidence — histology, protein markers, gene mutations, imaging — and produces a probability distribution over 24 possible cancer origins. Instead of saying "this is lung cancer," it says something like "42% chance lung, 11% chance colorectal, 6% chance stomach..."

Why this matters: the probabilities preserve the expert's uncertainty. A hard answer ("it's lung cancer") throws away the hedge. For medical decisions, the hedge is often the most important part.

Step 2: The student practises

The local model (Laya, an open 421M-parameter model) is shown the same evidence and asked to produce its own probability distribution. Then it's scored on how well its distribution matches the expert's. This scoring uses a proper scoring rule — a mathematical formula that rewards honest probabilities. If the model says "80% sure" but is only right 60% of the time, the scoring rule penalises it heavily.

The training loop in plain terms: the model tries an answer → gets a score → adjusts its internal weights to improve → tries again. This repeats thousands of times across all 1,750 workups. The technical name is "GRPO-style reinforcement learning from contrastive distillation" but the concept is simply: practice, get feedback, improve.

Step 3: The calibration check

After training, the model is tested on held-out data — workups it has never seen before. This is where we ask: "when the model says it's 70% confident, is it actually right 70% of the time?" If it says 70% but is only right 50% of the time, the model is overconfident — dangerous in medicine. We fix this by adjusting the model's "temperature" (a scaling factor that sharpens or softens its probability output) until its stated confidence matches its actual accuracy.

Analogy: imagine a weather forecaster who says "80% chance of rain" but it only rains 50% of the time when they say that. You'd want to recalibrate their predictions. That's exactly what the temperature fitting does.

Step 4: The gate

Before the model is deployed, three hard thresholds must pass on the held-out data:

≥ 0.85
the model picks the same answer as the expert at least 85% of the time
≤ 0.10
when the model says 70% confident, it's actually right between 60% and 80% of the time
0
the model doesn't dismiss any possible answer as impossible

If any threshold fails, the model never reaches production. This is why the page says "FAIL" next to the gate table — the current model doesn't meet the calibration bar yet, so it's not deployed for real use. It's a research demonstration showing what the system can do, not a clinical tool.

The training databases

Cup-origin (current): 1,750 synthetic workups from the JOSH fixture collection (SampleBias, MIT). Each workup is an invented cancer-of-unknown-primary patient with a full molecular panel, IHC panel, histology description, demographics, and imaging findings. Labeled by the Jev cloud teacher with soft probability distributions.

Skin cancer / dermatology (in progress): We are building a skin cancer triage model using the ISIC 2019 dataset — 25,331 dermatoscopic images across 8 disease classes, with biopsy-confirmed ground truth where available. The vision head (a ViT fine-tuned on these images, macro AUC 0.93) feeds structured findings into the same GUT decision framework. Additional datasets planned: HAM10000 (10,015 images, 7 classes), ISIC 2024/SLICE-3D (400,000+ slices), and PAD-UFES-20 (2,300 smartphone photos for real-world capture).

Other domains: Monitor alert triage (1,221 alerts), OSINT verification (1,851 hits), SEO page grading (1,200 pages), browser navigation (241 real website interactions), RF signal classification (1,600 transmissions), and more.

Total training data: 23,500+ labeled decisions across 12 domains.

The self-improving loop

Every verdict the system makes — right or wrong — is captured as a new training row. When a doctor confirms or corrects the model's call, that feedback becomes an even stronger training signal. Over time, the local model gets closer to the teacher's judgment, then starts to exceed it on domain-specific patterns it has seen more of. This is the "self-improving" claim: it's not a metaphor, it's the architecture.