On this page

Walkthrough: offline rewrite and policy training

Executed end to end against the release binary with two localhost fixtures: a Sapling-shaped detector endpoint and a Brama-compatible /v1/chat/completions endpoint. The fixture generator made deterministic lexical edits; the fixture judge returned a valid fixed evaluation. No paid or external API was called.

Guard rails

The same passage with invalid controls was refused before inference:

$ skryba rewrite --temperature 3
Error: temperature must be between 0 and 2

$ skryba rewrite --candidates 0
Error: candidate count must be positive

$ printf '  \n ' | skryba rewrite
Error: input text cannot be empty

Without a Brama token, even with a detector configured:

$ printf 'Sample text.\n' | skryba rewrite
Error: BRAMA_TOKEN is required for Brama inference

Rewrite

Input:

Additionally, the study found that participants who received the intervention reported higher satisfaction. Furthermore, retention improved by twelve percent over the six-month follow-up period, and no adverse events were recorded.

Command:

$ skryba rewrite --json --candidates 3 --seed 7

Exit status was 0. The selected portion of the real JSON was:

{
  "text": "Also, the study found that participants who received the intervention reported higher satisfaction. Meanwhile, retention improved by twelve percent over the six-month follow-up period, and no adverse events were recorded.",
  "chunks": [
    {
      "source": "Additionally, the study found that participants who received the intervention reported higher satisfaction. Furthermore, retention improved by twelve percent over the six-month follow-up period, and no adverse events were recorded.",
      "selected": {
        "strategy_index": 1,
        "strategy": "plainspoken",
        "text": "Also, the study found that participants who received the intervention reported higher satisfaction. Meanwhile, retention improved by twelve percent over the six-month follow-up period, and no adverse events were recorded.",
        "ai_probability": 0.644,
        "quality_score": 0.9601999999999999,
        "quality_passed": true,
        "quality": {
          "meaning_preservation": 0.97,
          "factual_consistency": 0.96,
          "grammar": 0.98,
          "coherence": 0.95,
          "naturalness": 0.93,
          "readability": 0.94,
          "critical_error": false,
          "issues": [],
          "rationale": "Meaning and facts preserved; phrasing is natural."
        },
        "detectors": [
          { "detector": "sapling", "ai_probability": 0.644, "cached": false }
        ]
      },
      "candidates": [
        { "strategy_index": 0, "strategy": "natural-editor", "ai_probability": 0.6575, "quality_passed": true },
        { "strategy_index": 1, "strategy": "plainspoken", "ai_probability": 0.644, "quality_passed": true },
        { "strategy_index": 0, "strategy": "natural-editor", "ai_probability": 0.6575, "quality_passed": true }
      ],
      "used_source_fallback": false
    }
  ]
}

The displayed candidate rows above omit repeated text, quality objects, and detector arrays only for readability; the executed stdout was 4,596 bytes and contained them for every candidate.

Text mode with --report report.json printed exactly the selected text and wrote a report with top-level keys text and chunks; the chunk held all three candidates.

Train a policy

A two-paragraph .txt file was trained with four generations:

$ skryba train train.txt --generations 4 --output-policy outputs/policy.json
{
  "examples": 2,
  "epochs": 1,
  "groups": 2,
  "final_mean_reward": 0.77528,
  "output_policy": "outputs/policy.json",
  "probabilities": [
    0.16666666666666666,
    0.16666666666666666,
    0.16666666666666666,
    0.16666666666666666,
    0.16666666666666666,
    0.16666666666666666
  ]
}

The fixture gave equal reward within each group, so normalized advantages were zero and the policy remained uniform. This is expected evidence that the update path does not invent a preference without a reward difference. The saved file reported version 1 and all six built-in strategy names.

Maintained as part of the website-owned Skryba documentation corpus.