Z
Zirnay Documentation v2.4.1
System One Intelligence • AI Infrastructure for Decisions
Launch Playground ↗ Interactive API Explorer Strands Decider ↗
DOCS / MODEL LIFECYCLE / Model Training & Calibration

Model Training & Calibration

Dataset JSONL schema, hyperparameter optimization, temperature Platt scaling, and training execution APIs.

⏱ 5 min read • Zirnay v2.4.1 • Updated October 2026

Dataset Formatting & Model Fine-Tuning

Training a Zirnay System 1 model involves fine-tuning encoder representations on historical decision records and calibrating prediction probabilities using Platt scaling.

1. Dataset JSONL Specification

Training datasets are prepared in line-delimited JSON format (.jsonl) where each record contains text, ground-truth label, and numeric feature attributes:

dataset-sample.jsonl
{"text": "International wire $15,000 to new beneficiary in high-risk jurisdiction", "label": "DECLINE", "features": {"amount": 15000, "is_new_recipient": true, "velocity_1h": 4}}
{"text": "Recurring monthly SaaS subscription renewal $29.00 from verified cardholder", "label": "APPROVE", "features": {"amount": 29, "is_new_recipient": false, "velocity_1h": 1}}
{"text": "Password change followed immediately by $4,000 crypto purchase attempt", "label": "CHALLENGE", "features": {"amount": 4000, "is_new_recipient": true, "velocity_1h": 3}}

2. Training Set Sizing & Class Balancing Strategy

When training fast-reflex models on massive tabular data (e.g. credit card transactions, audit logs, or triage queues), conventional 80/20 raw percentage splits often lead to poor models due to extreme class imbalance (e.g. 0.17% – 0.58% fraud rate).

⚠️ The Imbalance Trap: If you train a model on 1.29 million transactions where 99.4% are normal and only 0.58% are fraud, 99.4% of all gradient steps push the model to predict "normal". The loss from normal transactions swamps the fraud signal, causing the model to achieve 99.4% naive accuracy while catching 0% of actual fraud.

The Option 3 Standard: Balanced Training + Natural Validation

To maximize recall (fraud catch-rate) while measuring true real-world precision, Zirnay recommends Option 3:

Raw Tabular Dataset (e.g. 1.29M rows, ~0.58% fraud)
                          │
          ┌───────────────┴───────────────┐
          ▼                               ▼
[Natural Validation Set]        [Balanced Training Set]
• 100% natural real-world rate   • 100% of minority class (7,506 fraud)
• 555,719 rows (0.386% fraud)    • 1:10 downsampled normal (75,060 rows)
• True production precision &    • 82,566 rows total (9.09% fraud)
  false-positive rate audit      • Sharpened gradient decision boundary

Recommended Dataset Sizing by Model Architecture

Model Plugin Internal Mechanism Minimum Viable Optimal Sweet Spot Diminishing Returns
Laya Non-autoregressive ModernBERT head, standardized feature weights, empirical Bayes category smoothing 1,000 rows (≥50 positives) 50,000 – 100,000 rows (≥400 positives) > 200,000 rows
AnyJEV Calibrated probability model, position-bias permutation eradication, ECE minimization via Platt scaling 2,500 rows 20,000 – 50,000 rows > 100,000 rows
Strands-dc Qwen decider model adaptation for model routing, tool selection, guardrails, and policy classification 500 rows 10,000 – 30,000 rows > 50,000 rows
💡 Client Best Practice: When preparing your training corpus for highly imbalanced domains (e.g. fraud detection, chargeback prediction, or rare incident triage), downsample your negative records to a 1:10 to 1:20 ratio relative to positive target cases, while keeping your validation dataset at your natural production distribution. Upload your resulting .jsonl directly via the Web Console or the API below.

3. Register Data Format & Upload Datasets

Zirnay uses a decoupled schema architecture. Your raw .jsonl files contain pure data lines without metadata envelopes. You register the schema definition (format) describing feature names, datatypes, and target response variables through either:

  • Method A: Pre-register default schema on the model via the Model Update API (PATCH /v1/teams/:teamSlug/models/:modelSlug). All subsequent dataset uploads will automatically inherit this format.
  • Method B: Supply the schema during dataset upload via POST /v1/teams/:teamSlug/models/:modelSlug/datasets/upload (as a multi-part form field or JSON body).

Method A: Register Data Format via Model Update API (PATCH)

Configure your model's ground-truth schema contract ahead of time. Once registered, any team member or automated pipeline can upload training files without re-specifying schema definitions:

cURL • PATCH /v1/teams/:teamSlug/models/:modelSlug
curl -X PATCH http://localhost:8000/v1/teams/fraud-ops/models/laya-card-auth \
  -H "Authorization: Bearer $ZIRNAY_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Production micro-latency credit card transaction guard",
    "classes": ["APPROVE", "CHALLENGE", "DECLINE"],
    "format": {
      "dataset_name": "creditcard_fraud_v1",
      "target_field": "is_fraud",
      "fields": [
        { "name": "amt", "datatype": "number", "role": "feature", "nullable": false },
        { "name": "merchant", "datatype": "string", "role": "feature", "nullable": false },
        { "name": "category", "datatype": "category", "role": "feature", "nullable": false },
        { "name": "lat", "datatype": "number", "role": "feature", "nullable": false },
        { "name": "long", "datatype": "number", "role": "feature", "nullable": false },
        { "name": "city_pop", "datatype": "integer", "role": "feature", "nullable": true },
        { "name": "is_fraud", "datatype": "integer", "role": "target", "nullable": false }
      ]
    }
  }'

Method B: Upload Dataset with Validation & Schema Registration

Upload your training .jsonl corpus over HTTPS. Specify validation: "strict" to reject invalid rows with a detailed error report, or validation: "lenient" to automatically quarantine bad rows:

cURL • POST /v1/teams/:teamSlug/models/:modelSlug/datasets/upload (Multipart)
curl -X POST http://localhost:8000/v1/teams/fraud-ops/models/laya-card-auth/datasets/upload \
  -H "Authorization: Bearer $ZIRNAY_JWT_TOKEN" \
  -F "file=@creditcard_train.jsonl" \
  -F "dataset_name=creditcard_train.jsonl" \
  -F "validation=strict" \
  -F 'format={
    "target_field": "is_fraud",
    "fields": [
      { "name": "amt", "datatype": "number" },
      { "name": "merchant", "datatype": "string" },
      { "name": "category", "datatype": "category" },
      { "name": "lat", "datatype": "number" },
      { "name": "long", "datatype": "number" },
      { "name": "is_fraud", "datatype": "integer", "role": "target" }
    ]
  }'
HTTP 201 Created • Upload & Schema Acknowledgment
{
  "dataset_id": "ds_89f02c77",
  "filename": "creditcard_train.jsonl",
  "status": "READY",
  "validation_mode": "strict",
  "record_count": 82566,
  "size_bytes": 41512960,
  "sha256": "4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a",
  "format": {
    "target_field": "is_fraud",
    "fields": [
      { "name": "amt", "datatype": "number" },
      { "name": "is_fraud", "datatype": "integer", "role": "target" }
    ]
  },
  "created_at": "2026-11-01T07:00:00.000Z",
  "message": "Training dataset 'creditcard_train.jsonl' successfully uploaded and validated. You can now use dataset_id 'ds_89f02c77' to trigger model training."
}

4. Trigger Training via Control Plane API

Execute the training job via the REST API or Console workbench referencing the generated dataset_id. The job runs in a dedicated GPU/CPU sandbox, compiles weights, and serializes the resulting checkpoint:

cURL • POST /v1/teams/:teamSlug/models/:modelSlug/train
curl -X POST http://localhost:8000/v1/teams/fraud-ops/models/laya-card-auth/train \
  -H "Authorization: Bearer $ZIRNAY_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "dataset_id": "ds_71bc801f",
    "hyperparameters": {
      "epochs": 12,
      "learning_rate": 0.0005,
      "batch_size": 128,
      "warmup_ratio": 0.1,
      "calibration_temperature": 1.15
    }
  }'
⚡ Automated Checkpointing: When training successfully completes, a new immutable checkpoint record is created and verified with SHA-256 cryptographic digests, ready for immediate zero-downtime hot swap.

5. Continuous Human-in-the-Loop (HITL) Feedback Loop

When an agent or human reviewer overrides a model prediction (e.g. ticket triage: "Move to Queue 1" corrected to "Move to Queue 2"; or fraud flagging: "is_fraud: 1" cleared to "is_fraud: 0"), submit the ground-truth correction via the feedback API. Zirnay immediately evicts stale predictions from the fast-path Redis route cache and streams verified tuples into candidate retraining datasets:

cURL • POST /v1/teams/:teamSlug/models/:modelSlug/feedback
curl -X POST http://localhost:8000/v1/teams/fraud-ops/models/triage-router/feedback \
  -H "Authorization: Bearer $ZIRNAY_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "request_id": "req_8819d-29384",
    "actual_outcome": "Move to Queue 2",
    "feedback_type": "CORRECTION",
    "reviewer": {
      "reviewer_id": "usr_ops_lead_42",
      "reviewer_role": "SUPERVISOR",
      "notes": "Escalated to Tier-2 enterprise billing"
    }
  }'
🔄 Closed-Loop Active Learning: Accumulated feedback is combined with baseline golden datasets, validated against the decoupled format schema, and triggers micro-fine-tuning on isolated worker nodes with dual Golden Probe stability checks.