@tuned-tensor/local 0.2.9 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +84 -210
  3. package/dist/artifacts.d.ts +3 -4
  4. package/dist/artifacts.js +55 -33
  5. package/dist/artifacts.js.map +1 -1
  6. package/dist/compare.d.ts +1 -8
  7. package/dist/compare.js +1 -23
  8. package/dist/compare.js.map +1 -1
  9. package/dist/contracts.d.ts +59 -366
  10. package/dist/contracts.js +73 -224
  11. package/dist/contracts.js.map +1 -1
  12. package/dist/dataset.d.ts +2 -4
  13. package/dist/dataset.js +31 -125
  14. package/dist/dataset.js.map +1 -1
  15. package/dist/doctor.d.ts +2 -3
  16. package/dist/doctor.js +23 -161
  17. package/dist/doctor.js.map +1 -1
  18. package/dist/evaluation.d.ts +11 -71
  19. package/dist/evaluation.js +212 -572
  20. package/dist/evaluation.js.map +1 -1
  21. package/dist/huggingface-cache.d.ts +8 -7
  22. package/dist/huggingface-cache.js +16 -8
  23. package/dist/huggingface-cache.js.map +1 -1
  24. package/dist/index.d.ts +0 -10
  25. package/dist/index.js +203 -626
  26. package/dist/index.js.map +1 -1
  27. package/dist/local-project.d.ts +1 -11
  28. package/dist/local-project.js +33 -61
  29. package/dist/local-project.js.map +1 -1
  30. package/dist/model-registry.d.ts +3 -16
  31. package/dist/model-registry.js +76 -292
  32. package/dist/model-registry.js.map +1 -1
  33. package/dist/model-server.d.ts +1 -2
  34. package/dist/model-server.js +9 -18
  35. package/dist/model-server.js.map +1 -1
  36. package/dist/orchestrator.d.ts +11 -25
  37. package/dist/orchestrator.js +246 -566
  38. package/dist/orchestrator.js.map +1 -1
  39. package/dist/prefetch.d.ts +1 -5
  40. package/dist/prefetch.js +14 -19
  41. package/dist/prefetch.js.map +1 -1
  42. package/dist/process-runner.d.ts +10 -29
  43. package/dist/process-runner.js +63 -169
  44. package/dist/process-runner.js.map +1 -1
  45. package/dist/process-training.d.ts +0 -1
  46. package/dist/process-training.js +10 -87
  47. package/dist/process-training.js.map +1 -1
  48. package/dist/store.d.ts +1 -3
  49. package/dist/store.js +92 -290
  50. package/dist/store.js.map +1 -1
  51. package/docs/architecture.md +87 -152
  52. package/docs/spark.md +66 -97
  53. package/examples/dry-runner.json +14 -0
  54. package/examples/local-runner.json +8 -6
  55. package/examples/smoke-spec.json +41 -0
  56. package/package.json +6 -6
  57. package/training/local-runner/pyproject.toml +0 -5
  58. package/training/local-runner/src/evaluate.py +89 -234
  59. package/training/local-runner/src/model_contract.py +47 -0
  60. package/training/local-runner/src/prefetch.py +18 -4
  61. package/training/local-runner/src/serve.py +54 -115
  62. package/training/local-runner/src/sft_data.py +97 -0
  63. package/training/local-runner/src/train.py +146 -346
  64. package/training/local-runner/uv.lock +0 -1197
  65. package/dist/labeling-sanitize.d.ts +0 -31
  66. package/dist/labeling-sanitize.js +0 -158
  67. package/dist/labeling-sanitize.js.map +0 -1
  68. package/dist/labeling.d.ts +0 -155
  69. package/dist/labeling.js +0 -496
  70. package/dist/labeling.js.map +0 -1
  71. package/dist/openrouter.d.ts +0 -29
  72. package/dist/openrouter.js +0 -66
  73. package/dist/openrouter.js.map +0 -1
  74. package/dist/server.d.ts +0 -9
  75. package/dist/server.js +0 -211
  76. package/dist/server.js.map +0 -1
  77. package/docs/local-workflow-remediation-2026-07-13.md +0 -130
  78. package/docs/local-workflow-ux-review-2026-07-13.md +0 -458
  79. package/examples/dpo-preferences.jsonl +0 -2
  80. package/examples/dpo-run-request.json +0 -34
  81. package/examples/smoke-run-request.json +0 -34
  82. package/training/local-runner/src/train_dpo.py +0 -286
@@ -1,83 +1,33 @@
1
1
  import { type BehaviorSpecExample, type EvalReport, type EvalSplit, type LocalRunnerConfig } from "./contracts.js";
2
2
  import type { LocalRunReporter } from "./run-reporter.js";
3
- /**
4
- * Token-overlap F1 between expected and actual output (bag-of-words, case and
5
- * whitespace insensitive). This is a cheap deterministic reference-similarity
6
- * signal for free-text tasks where exact match is always 0 and an LLM judge
7
- * can be noisy; both scoring paths keep working unchanged alongside it.
8
- */
3
+ /** Cheap deterministic free-text similarity reported beside exact match. */
9
4
  export declare function tokenF1(expected: string, actual: string): number;
10
- /** Derives a deterministic 32-bit seed from an arbitrary string (FNV-1a). */
5
+ /** Deterministic 32-bit FNV-1a seed. */
11
6
  export declare function deriveSampleSeed(value: string): number;
12
- /**
13
- * Selects `count` examples with a seeded shuffle so that truncated evaluation
14
- * is a deterministic random sample instead of a dataset-order prefix. The
15
- * selected examples keep their original relative order, so baseline and
16
- * candidate evaluations that use the same seed score identical examples.
17
- */
18
7
  export declare function sampleExamples<T>(examples: T[], count: number, seed: number): T[];
19
8
  /**
20
- * Deterministically splits spec examples into a training split and an eval
21
- * holdout so that default spec runs do not evaluate on their own training
22
- * data. The holdout is a seeded random sample of about `holdoutRatio` of the
23
- * examples, with at least 1 holdout and at least 1 training example. Both
24
- * splits preserve the original example order. With fewer than 2 examples the
25
- * holdout is empty and callers should fall back to training-set evaluation.
9
+ * Inline specs get a deterministic holdout. A real run with fewer than two
10
+ * examples is rejected by the shared validator before this function is used.
26
11
  */
27
12
  export declare function splitSpecExamples<T>(examples: T[], seed: number, holdoutRatio?: number): {
28
13
  train: T[];
29
14
  holdout: T[];
30
15
  };
16
+ export declare const INFERENCE_PROTOCOL_VERSION = 2;
31
17
  /**
32
- * Builds the judge messages. The spec's compiled system message (system
33
- * prompt, guidelines, and constraints) is forwarded as task_instructions so
34
- * the judge scores conformance to the task, not just similarity to the
35
- * reference. Without it, a judge treats `expected` as a fact checklist and
36
- * systematically penalizes outputs trained toward a different style (for
37
- * example concise summaries) even when they follow the spec.
38
- */
39
- export declare function buildJudgeMessages(args: {
40
- prompt: string;
41
- expected: string;
42
- actual: string;
43
- taskInstructions?: string;
44
- }): Array<{
45
- role: "system" | "user";
46
- content: string;
47
- }>;
48
- export interface EvaluationJudgeAvailability {
49
- available: boolean;
50
- reason?: string;
51
- }
52
- export declare function evaluationJudgeAvailability(config: LocalRunnerConfig): EvaluationJudgeAvailability;
53
- /**
54
- * Fail before model inference when judge scoring cannot run. Exact-match
55
- * fallback is allowed only when the user opted into it explicitly in config.
56
- */
57
- export declare function assertEvaluationScoringReady(config: LocalRunnerConfig, scoringMode?: "exact_match" | "llm_judge" | "json_fields"): EvaluationJudgeAvailability;
58
- export type RegressionCategory = "factual" | "omission" | "style" | "fallback" | "other";
59
- /**
60
- * Coarse category for a judge reasoning string so comparison reports can
61
- * answer "what kind of worse?" without re-reading every example. Factual
62
- * problems dominate omissions, which dominate style notes; fallback marks
63
- * examples that were never judge-scored (their score is not comparable to
64
- * judged ones).
65
- */
66
- export declare function classifyJudgeReasoning(reasoning: string | null, scoredBy?: string): RegressionCategory;
67
- /**
68
- * Cache key for a baseline evaluation. Baseline outputs are deterministic for
69
- * a given model, example set, and generation settings, and judge scores only
70
- * depend on those plus the scoring configuration, so re-running a spec with
71
- * an unchanged baseline can reuse the previous report instead of paying for
72
- * inference and judge calls again. The package version participates so rubric
73
- * or evaluator changes invalidate old entries.
18
+ * Deterministic local scoring needs no network credentials. This function is
19
+ * kept as the shared preflight hook used by validate, doctor, and run.
74
20
  */
21
+ export declare function assertEvaluationScoringReady(config: LocalRunnerConfig): void;
75
22
  export declare function baselineCacheKey(args: {
76
23
  modelId: string;
77
24
  baseModelRevision?: string;
78
25
  sourceFingerprint?: string;
79
26
  system: string;
80
27
  examples: BehaviorSpecExample[];
28
+ evalExamplesTotal: number;
29
+ evalSplit?: EvalSplit;
30
+ evalSampleSeed?: number | null;
81
31
  config: LocalRunnerConfig;
82
32
  packageVersion: string;
83
33
  }): string;
@@ -98,26 +48,16 @@ export declare function evaluateExamples(args: {
98
48
  sampleSeed?: number;
99
49
  shouldCancel?: () => boolean | Promise<boolean>;
100
50
  }): Promise<EvalReport>;
101
- export declare function rescoreEvalReport(args: {
102
- report: EvalReport;
103
- config: LocalRunnerConfig;
104
- outputPath: string;
105
- system?: string;
106
- reporter?: LocalRunReporter;
107
- }): Promise<EvalReport>;
108
51
  export declare function compareEvalReports(baseline: EvalReport, candidate: EvalReport): {
109
52
  avg_score_delta: number;
110
53
  pass_rate_delta: number;
111
54
  exact_match_rate_delta: number;
112
55
  token_f1_delta: number;
113
- judge_only_avg_score_delta: number | null;
114
56
  regressions: number;
115
57
  improvements: number;
116
- regression_taxonomy: Record<RegressionCategory, number> | undefined;
117
58
  regressed_examples: {
118
59
  prompt: string;
119
60
  old_score: number;
120
61
  new_score: number;
121
- category: RegressionCategory;
122
62
  }[];
123
63
  };