CASCADE·ANNOTE
Architecture

The cascade, layer by layer.

A precise breakdown of how a single sentence becomes a verifiable, attested label. Every layer is independently auditable and replaceable.

L1

Retrieval

Sparse vector index over the labeled corpus. Surfaces top-K closest exemplars by cosine similarity.

featuresuni+bi-grams
weightstf-idf
metriccosine
k5
L2

CoT prompt

Builds a 5-step chain-of-thought prompt around the exemplars. Provider-agnostic structure.

steps5
evidencek examples
formatFINAL_LABEL:
tokens~512
L3

SC vote

Samples N inference runs across diverse temperatures, then majority-votes the label.

runs5
temps0.3–0.7
scorevote+sim
outputlabel, c
L4

Fallback

If confidence < threshold, widens the window with cold temperatures and re-votes.

threshold0.60
temps0.15–0.5
runs+7
audittrace
Deep dive

Each layer is a contract.

L1

Retrieval

A custom TF-IDF retriever in pure TypeScript. We tokenize, drop stopwords, build uni+bi-gram features, weight by inverse document frequency, and rank by cosine similarity. Deterministic, fast, dependency-free.

Inputs → Outputs
const retriever = new Retriever(corpus);
const top = retriever.retrieve(text, 5);
// → [{ id, text, label, similarity }, ...]
Guarantees
  • · Deterministic per corpus
  • · ≤ 5 ms per query
  • · No network
  • · Stateless
Failure modes
  • · Tiny corpora (≤ 3)
  • · OOV jargon
  • · Cross-language queries
L2

CoT prompt

We compose a structured prompt that exposes the exemplars and an explicit five-step reasoning protocol. The structure is identical for the local classifier, OpenAI, and 0G Compute — providers are interchangeable.

Inputs → Outputs
const prompt = buildPrompt(text, examples, candidates);
// prompt.full -> "system\n\ntask\n\nexamples\n\nquery"
Guarantees
  • · Provider-agnostic
  • · Token-bounded
  • · Deterministic format
Failure modes
  • · Adversarial prompts
  • · Context overflow > 8k
L3

Self-consistency vote

We run the inference engine N times with diverse temperatures and majority-vote. Confidence blends the vote ratio with the cosine similarity of the exemplars supporting the winning label.

Inputs → Outputs
const { vote } = await selfConsistencyVote({
  query, examples, candidates, runs: 5,
});
// vote.confidence ∈ [0, 0.99]
Guarantees
  • · Calibrated confidence
  • · Reproducible per seed
  • · Concurrent execution
Failure modes
  • · Tied votes break to top-similarity
  • · Single-class corpora
L4

Adaptive fallback

When confidence falls below threshold, we widen the example window and add cold-temperature runs. The merged vote is returned with the higher of the two confidences and a status flag in the trace.

Inputs → Outputs
const fb = await adaptiveFallback({
  query, examples, candidates,
  threshold: 0.6, initialVote: vote,
});
// fb.used === true → re-voted at cooler T
Guarantees
  • · Strictly improves confidence
  • · Bounded latency
  • · Deterministic flag
Failure modes
  • · Truly ambiguous text
  • · Conflicting labels in corpus
Verification chain

From label to receipt.

Annotation produced

Layer-4 emits a label, confidence, and a structured trace.

Receipt content-addressed

Result is hashed (sha-256) and uploaded to 0G Storage.

On-chain attestation

Receipt root + agent DID anchored on 0G Chain (when configured).