@seanhogg/builderforce-memory 2026.9.29 → 2026.9.31
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.
- package/dist/bridges/AnthropicBridge.d.ts.map +1 -1
- package/dist/bridges/AnthropicBridge.js +24 -65
- package/dist/bridges/AnthropicBridge.js.map +1 -1
- package/dist/bridges/FetchBridge.d.ts +12 -5
- package/dist/bridges/FetchBridge.d.ts.map +1 -1
- package/dist/bridges/FetchBridge.js +6 -4
- package/dist/bridges/FetchBridge.js.map +1 -1
- package/dist/bridges/OpenAIBridge.d.ts +17 -4
- package/dist/bridges/OpenAIBridge.d.ts.map +1 -1
- package/dist/bridges/OpenAIBridge.js +71 -94
- package/dist/bridges/OpenAIBridge.js.map +1 -1
- package/dist/bridges/TransformerBridge.d.ts +6 -0
- package/dist/bridges/TransformerBridge.d.ts.map +1 -1
- package/dist/bridges/VertexAIBridge.d.ts.map +1 -1
- package/dist/bridges/VertexAIBridge.js +3 -34
- package/dist/bridges/VertexAIBridge.js.map +1 -1
- package/dist/distillation/DistillationEngine.d.ts +71 -54
- package/dist/distillation/DistillationEngine.d.ts.map +1 -1
- package/dist/distillation/DistillationEngine.js +112 -95
- package/dist/distillation/DistillationEngine.js.map +1 -1
- package/dist/distillation/index.d.ts +7 -1
- package/dist/distillation/index.d.ts.map +1 -1
- package/dist/distillation/index.js +5 -0
- package/dist/distillation/index.js.map +1 -1
- package/dist/distillation/ports.d.ts +43 -0
- package/dist/distillation/ports.d.ts.map +1 -0
- package/dist/distillation/ports.js +29 -0
- package/dist/distillation/ports.js.map +1 -0
- package/dist/eval/EvalHarness.d.ts +2 -1
- package/dist/eval/EvalHarness.d.ts.map +1 -1
- package/dist/eval/EvalHarness.js +13 -1
- package/dist/eval/EvalHarness.js.map +1 -1
- package/dist/eval/baseline.d.ts +33 -0
- package/dist/eval/baseline.d.ts.map +1 -0
- package/dist/eval/baseline.js +41 -0
- package/dist/eval/baseline.js.map +1 -0
- package/dist/eval/index.d.ts +1 -0
- package/dist/eval/index.d.ts.map +1 -1
- package/dist/eval/index.js +1 -0
- package/dist/eval/index.js.map +1 -1
- package/dist/eval/types.d.ts +7 -0
- package/dist/eval/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rag/EnterpriseRetriever.d.ts.map +1 -1
- package/dist/rag/EnterpriseRetriever.js +2 -1
- package/dist/rag/EnterpriseRetriever.js.map +1 -1
- package/dist/retrieval/HybridRetriever.d.ts.map +1 -1
- package/dist/retrieval/HybridRetriever.js +2 -1
- package/dist/retrieval/HybridRetriever.js.map +1 -1
- package/dist/retrieval/decay.d.ts +24 -0
- package/dist/retrieval/decay.d.ts.map +1 -0
- package/dist/retrieval/decay.js +29 -0
- package/dist/retrieval/decay.js.map +1 -0
- package/dist/retrieval/fusion.d.ts +13 -19
- package/dist/retrieval/fusion.d.ts.map +1 -1
- package/dist/retrieval/fusion.js +17 -44
- package/dist/retrieval/fusion.js.map +1 -1
- package/dist/retrieval/index.d.ts +13 -6
- package/dist/retrieval/index.d.ts.map +1 -1
- package/dist/retrieval/index.js +10 -5
- package/dist/retrieval/index.js.map +1 -1
- package/dist/retrieval/mmr.d.ts +60 -0
- package/dist/retrieval/mmr.d.ts.map +1 -0
- package/dist/retrieval/mmr.js +94 -0
- package/dist/retrieval/mmr.js.map +1 -0
- package/dist/retrieval/weightedFusion.d.ts +64 -0
- package/dist/retrieval/weightedFusion.d.ts.map +1 -0
- package/dist/retrieval/weightedFusion.js +80 -0
- package/dist/retrieval/weightedFusion.js.map +1 -0
- package/dist/similarity/index.d.ts +6 -4
- package/dist/similarity/index.d.ts.map +1 -1
- package/dist/similarity/index.js +5 -3
- package/dist/similarity/index.js.map +1 -1
- package/dist/wire/chatClient.d.ts +100 -0
- package/dist/wire/chatClient.d.ts.map +1 -0
- package/dist/wire/chatClient.js +123 -0
- package/dist/wire/chatClient.js.map +1 -0
- package/dist/wire/index.d.ts +20 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +18 -0
- package/dist/wire/index.js.map +1 -0
- package/dist/wire/sse.d.ts +37 -0
- package/dist/wire/sse.d.ts.map +1 -0
- package/dist/wire/sse.js +104 -0
- package/dist/wire/sse.js.map +1 -0
- package/dist/wire/usage.d.ts +46 -0
- package/dist/wire/usage.d.ts.map +1 -0
- package/dist/wire/usage.js +78 -0
- package/dist/wire/usage.js.map +1 -0
- package/package.json +11 -3
- package/src/bridges/AnthropicBridge.ts +24 -68
- package/src/bridges/FetchBridge.ts +15 -6
- package/src/bridges/OpenAIBridge.ts +84 -113
- package/src/bridges/TransformerBridge.ts +6 -0
- package/src/bridges/VertexAIBridge.ts +3 -32
- package/src/distillation/DistillationEngine.ts +176 -141
- package/src/distillation/index.ts +15 -1
- package/src/distillation/ports.ts +55 -0
- package/src/eval/EvalHarness.ts +12 -1
- package/src/eval/baseline.ts +51 -0
- package/src/eval/index.ts +1 -0
- package/src/eval/types.ts +7 -0
- package/src/index.ts +5 -2
- package/src/rag/EnterpriseRetriever.ts +2 -1
- package/src/retrieval/HybridRetriever.ts +2 -1
- package/src/retrieval/decay.ts +29 -0
- package/src/retrieval/fusion.ts +19 -52
- package/src/retrieval/index.ts +24 -6
- package/src/retrieval/mmr.ts +126 -0
- package/src/retrieval/weightedFusion.ts +101 -0
- package/src/similarity/index.ts +6 -4
- package/src/wire/chatClient.ts +196 -0
- package/src/wire/index.ts +20 -0
- package/src/wire/sse.ts +96 -0
- package/src/wire/usage.ts +95 -0
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* that differ from the first-party API, so supply a matching `PriceBook`.
|
|
23
23
|
*/
|
|
24
24
|
import { SSMError } from '../errors/SSMError.js';
|
|
25
|
+
import { readSseDataFrames } from '../wire/index.js';
|
|
25
26
|
export class VertexAIBridge {
|
|
26
27
|
supportsStreaming = true;
|
|
27
28
|
_projectId;
|
|
@@ -64,7 +65,8 @@ export class VertexAIBridge {
|
|
|
64
65
|
throw new SSMError('BRIDGE_RESPONSE_INVALID', 'Vertex AI streaming response has no body.');
|
|
65
66
|
}
|
|
66
67
|
let usage;
|
|
67
|
-
for await (const
|
|
68
|
+
for await (const frame of readSseDataFrames(res.body)) {
|
|
69
|
+
const event = frame;
|
|
68
70
|
const text = readCandidateText(event);
|
|
69
71
|
if (text)
|
|
70
72
|
yield text;
|
|
@@ -188,37 +190,4 @@ function readVertexUsage(usage, model) {
|
|
|
188
190
|
cachedInputTokens: cached,
|
|
189
191
|
};
|
|
190
192
|
}
|
|
191
|
-
/** Parses an `alt=sse` stream into JSON events. */
|
|
192
|
-
async function* parseSseJson(body) {
|
|
193
|
-
const reader = body.getReader();
|
|
194
|
-
const decoder = new TextDecoder();
|
|
195
|
-
let buffer = '';
|
|
196
|
-
try {
|
|
197
|
-
while (true) {
|
|
198
|
-
const { done, value } = await reader.read();
|
|
199
|
-
if (done)
|
|
200
|
-
break;
|
|
201
|
-
buffer += decoder.decode(value, { stream: true });
|
|
202
|
-
const lines = buffer.split('\n');
|
|
203
|
-
buffer = lines.pop();
|
|
204
|
-
for (const line of lines) {
|
|
205
|
-
const trimmed = line.trim();
|
|
206
|
-
if (!trimmed.startsWith('data:'))
|
|
207
|
-
continue;
|
|
208
|
-
const payload = trimmed.slice(5).trim();
|
|
209
|
-
if (!payload || payload === '[DONE]')
|
|
210
|
-
continue;
|
|
211
|
-
try {
|
|
212
|
-
yield JSON.parse(payload);
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
// Skip malformed SSE frames rather than failing the stream.
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
finally {
|
|
221
|
-
reader.releaseLock();
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
193
|
//# sourceMappingURL=VertexAIBridge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VertexAIBridge.js","sourceRoot":"","sources":["../../src/bridges/VertexAIBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"VertexAIBridge.js","sourceRoot":"","sources":["../../src/bridges/VertexAIBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA0BrD,MAAM,OAAO,cAAc;IACd,iBAAiB,GAAG,IAAa,CAAC;IAE1B,UAAU,CAAS;IACnB,SAAS,CAAS;IAClB,MAAM,CAAS;IACf,UAAU,CAAS;IACnB,SAAS,CAAiC;IAC1C,aAAa,CAAS;IACtB,UAAU,CAAS;IACnB,QAAQ,CAAS;IACjB,MAAM,CAAe;IAE9B,SAAS,CAA6B;IAE9C,YAAY,IAA2B;QACnC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,IAAI,aAAa,CAAC;QAChD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,IAAI,kBAAkB,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,GAAG,IAAI,CA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KAAK,CAAC;IACnG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,kFAAkF;IAClF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,KAAa;IAClD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC1D,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC;IAClD,OAAO;QACH,KAAK;QACL,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACzC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC;QACpD,iBAAiB,EAAE,MAAM;KAC5B,CAAC;AACN,CAAC"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DistillationEngine –
|
|
2
|
+
* DistillationEngine – online knowledge distillation.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This runs entirely in the browser with no Python or full-retraining required.
|
|
4
|
+
* A *teacher* (a frontier model) writes the ideal response; the *student* is adapted
|
|
5
|
+
* on it. Runs with no Python and no full retraining.
|
|
7
6
|
*
|
|
8
7
|
* Distillation flow:
|
|
9
|
-
* 1.
|
|
10
|
-
* 2.
|
|
11
|
-
* 3.
|
|
8
|
+
* 1. teacher.generate(input) → exemplar
|
|
9
|
+
* 2. quality gate (length / already-learned) → skip, or fall back to the caller's text
|
|
10
|
+
* 3. student.adapt(input + exemplar, + rehearsed past exemplars)
|
|
11
|
+
* 4. log the outcome
|
|
12
|
+
*
|
|
13
|
+
* Teacher and student are ports ({@link ./ports}). Passing an `SSMRuntime` and a
|
|
14
|
+
* `TransformerBridge` — the original pairing — still works unchanged.
|
|
12
15
|
*/
|
|
13
16
|
import type { AdaptOptions, AdaptResult } from '../session/index.js';
|
|
14
17
|
import type { SSMRuntime } from '../runtime/SSMRuntime.js';
|
|
15
|
-
import type {
|
|
18
|
+
import type { BridgeGenerateOptions } from '../bridges/TransformerBridge.js';
|
|
19
|
+
import { type DistillationStudent, type DistillationTeacher } from './ports.js';
|
|
16
20
|
export interface QualityGate {
|
|
17
21
|
/**
|
|
18
22
|
* Minimum character length of the teacher output.
|
|
@@ -20,36 +24,40 @@ export interface QualityGate {
|
|
|
20
24
|
*/
|
|
21
25
|
minLength?: number;
|
|
22
26
|
/**
|
|
23
|
-
* Maximum
|
|
24
|
-
* When the
|
|
27
|
+
* Maximum student perplexity threshold (needs a student with `evaluate`).
|
|
28
|
+
* When the student already achieves perplexity below this value on the teacher
|
|
25
29
|
* output, the content is considered already learned and adaptation is skipped.
|
|
26
30
|
*/
|
|
27
31
|
maxPerplexity?: number;
|
|
28
32
|
}
|
|
29
|
-
export interface DistillOptions {
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* WSLA is preferred because it is fast and targets the selective
|
|
34
|
-
* projection rows — exactly the parameters that encode token routing.
|
|
35
|
-
*/
|
|
36
|
-
adapt?: AdaptOptions;
|
|
37
|
-
/**
|
|
38
|
-
* Options forwarded to `bridge.generate()`.
|
|
39
|
-
*/
|
|
33
|
+
export interface DistillOptions<O = AdaptOptions> {
|
|
34
|
+
/** Options forwarded to the student's `adapt()`. */
|
|
35
|
+
adapt?: O;
|
|
36
|
+
/** Options forwarded to the teacher's `generate()` (system prompt, max tokens, …). */
|
|
40
37
|
generate?: BridgeGenerateOptions;
|
|
41
38
|
/**
|
|
42
39
|
* Quality gate filters that can skip adaptation for low-quality or
|
|
43
40
|
* already-learned inputs.
|
|
44
41
|
*/
|
|
45
42
|
qualityGate?: QualityGate;
|
|
43
|
+
/**
|
|
44
|
+
* What to learn when the teacher yields nothing usable — it threw, or its output
|
|
45
|
+
* failed the `minLength` gate. Without it such an input is skipped (a teacher
|
|
46
|
+
* error is thrown); with it the student learns this text instead, so the
|
|
47
|
+
* contribution is never lost, and the result says it was not distilled.
|
|
48
|
+
*/
|
|
49
|
+
fallbackText?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Cap on the characters of `input` that prefix the exemplar in the training text,
|
|
52
|
+
* so a long input can never crowd the exemplar out of the student's window.
|
|
53
|
+
*/
|
|
54
|
+
contextChars?: number;
|
|
46
55
|
}
|
|
47
56
|
/**
|
|
48
|
-
* Catastrophic-forgetting guard (EVM-5). Online
|
|
49
|
-
* weights toward the newest exemplar, which can erode previously-learned
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* reinforced instead of overwritten.
|
|
57
|
+
* Catastrophic-forgetting guard (EVM-5). Online adaptation moves a narrow set of
|
|
58
|
+
* weights toward the newest exemplar, which can erode previously-learned knowledge.
|
|
59
|
+
* A rehearsal (experience-replay) buffer mitigates this: each adapt also trains on a
|
|
60
|
+
* sample of past exemplars, so old knowledge is continually reinforced.
|
|
53
61
|
*/
|
|
54
62
|
export interface RehearsalOptions {
|
|
55
63
|
/** Ring-buffer capacity of past exemplars. 0 disables rehearsal. Default 0. */
|
|
@@ -59,26 +67,31 @@ export interface RehearsalOptions {
|
|
|
59
67
|
/** Deterministic sampling seed. Default 1. */
|
|
60
68
|
seed?: number;
|
|
61
69
|
}
|
|
62
|
-
|
|
70
|
+
/** Why an input was not learned from a teacher exemplar. */
|
|
71
|
+
export type DistillSkipReason = 'low_quality' | 'already_learned' | 'teacher_failed';
|
|
72
|
+
export interface DistillResult<R = AdaptResult> {
|
|
63
73
|
/** The input prompt that was distilled. */
|
|
64
74
|
input: string;
|
|
65
|
-
/** The teacher's
|
|
75
|
+
/** The teacher's response to the input ('' when the teacher failed). */
|
|
66
76
|
teacherOutput: string;
|
|
67
|
-
/** The
|
|
68
|
-
adaptResult:
|
|
69
|
-
/**
|
|
77
|
+
/** The student's result — its skipped result when nothing was adapted. */
|
|
78
|
+
adaptResult: R;
|
|
79
|
+
/** True when nothing was adapted at all. */
|
|
70
80
|
skipped?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
|
|
81
|
+
/** True when the student learned the teacher's exemplar (not a fallback). */
|
|
82
|
+
distilled: boolean;
|
|
83
|
+
/** Why the exemplar was not learned, when it was not. */
|
|
84
|
+
skipReason?: DistillSkipReason;
|
|
85
|
+
/** What the teacher threw, when `skipReason` is `teacher_failed`. */
|
|
86
|
+
teacherError?: unknown;
|
|
73
87
|
/** Number of past exemplars rehearsed alongside this one (EVM-5). */
|
|
74
88
|
rehearsed?: number;
|
|
75
89
|
/** Student's pre-adapt perplexity on the teacher output, when the quality gate
|
|
76
|
-
* measured it — a "how novel was this exemplar" signal.
|
|
77
|
-
* exemplar was NOT skipped (previously discarded on the trained path). */
|
|
90
|
+
* measured it — a "how novel was this exemplar" signal. */
|
|
78
91
|
gatePerplexity?: number;
|
|
79
92
|
}
|
|
80
|
-
export interface DistillBatchResult {
|
|
81
|
-
results: DistillResult[];
|
|
93
|
+
export interface DistillBatchResult<R = AdaptResult> {
|
|
94
|
+
results: DistillResult<R>[];
|
|
82
95
|
/** Total number of adapt epochs run across all inputs. */
|
|
83
96
|
totalEpochs: number;
|
|
84
97
|
/** Wall-clock time for the entire batch in milliseconds. */
|
|
@@ -89,29 +102,29 @@ export interface DistillationLog {
|
|
|
89
102
|
input: string;
|
|
90
103
|
teacherOutputLength: number;
|
|
91
104
|
skipped: boolean;
|
|
92
|
-
|
|
105
|
+
/** True when the exemplar (not a fallback) was learned. */
|
|
106
|
+
distilled: boolean;
|
|
107
|
+
skipReason?: DistillSkipReason;
|
|
93
108
|
finalLoss?: number;
|
|
94
109
|
epochs: number;
|
|
95
110
|
/** Pre-adapt perplexity on the teacher output (when the quality gate measured it). */
|
|
96
111
|
gatePerplexity?: number;
|
|
97
112
|
}
|
|
98
|
-
export declare class DistillationEngine {
|
|
99
|
-
private readonly
|
|
100
|
-
private readonly
|
|
113
|
+
export declare class DistillationEngine<R = AdaptResult, O = AdaptOptions> {
|
|
114
|
+
private readonly _student;
|
|
115
|
+
private readonly _teacher;
|
|
101
116
|
private readonly _log;
|
|
102
117
|
private readonly _rehearsalSize;
|
|
103
118
|
private readonly _rehearsalK;
|
|
104
119
|
private readonly _rehearsal;
|
|
105
120
|
private _rehearsalState;
|
|
106
121
|
/**
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* `bufferSize > 0`, each adapt also trains on a sample of past
|
|
112
|
-
* exemplars to guard against catastrophic forgetting.
|
|
122
|
+
* @param student What learns: an `SSMRuntime`, or any {@link DistillationStudent}.
|
|
123
|
+
* @param teacher What teaches: any `TransformerBridge`, or any {@link DistillationTeacher}.
|
|
124
|
+
* @param rehearsal Optional experience-replay config (EVM-5). When `bufferSize > 0`,
|
|
125
|
+
* each adapt also trains on a sample of past exemplars.
|
|
113
126
|
*/
|
|
114
|
-
constructor(
|
|
127
|
+
constructor(student: SSMRuntime | DistillationStudent<R, O>, teacher: DistillationTeacher, rehearsal?: RehearsalOptions);
|
|
115
128
|
/** Current number of exemplars held in the rehearsal buffer (EVM-5). */
|
|
116
129
|
getRehearsalBufferSize(): number;
|
|
117
130
|
/** Deterministic [0,1) draw for reproducible rehearsal sampling. */
|
|
@@ -123,22 +136,26 @@ export declare class DistillationEngine {
|
|
|
123
136
|
* Runs a single distillation pass:
|
|
124
137
|
* 1. Teacher generates a response for `input`
|
|
125
138
|
* 2. Quality gate is evaluated (if configured)
|
|
126
|
-
* 3.
|
|
139
|
+
* 3. Student is adapted on `input` + the teacher's output
|
|
127
140
|
*
|
|
128
|
-
* The training signal is the teacher's full response — this teaches the
|
|
129
|
-
*
|
|
130
|
-
* labelled data or a loss function beyond the standard LM objective.
|
|
141
|
+
* The training signal is the teacher's full response — this teaches the student
|
|
142
|
+
* what a good response to that prompt looks like, without labelled data.
|
|
131
143
|
*/
|
|
132
|
-
distill(input: string, opts?: DistillOptions): Promise<DistillResult
|
|
144
|
+
distill(input: string, opts?: DistillOptions<O>): Promise<DistillResult<R>>;
|
|
133
145
|
/**
|
|
134
146
|
* Runs distillation for each input in sequence.
|
|
135
147
|
* Aggregate statistics are returned alongside individual results.
|
|
136
148
|
*/
|
|
137
|
-
distillBatch(inputs: string[], opts?: DistillOptions): Promise<DistillBatchResult
|
|
149
|
+
distillBatch(inputs: string[], opts?: DistillOptions<O>): Promise<DistillBatchResult<R>>;
|
|
138
150
|
/**
|
|
139
151
|
* Returns a copy of the in-memory distillation log (last 200 entries).
|
|
140
152
|
*/
|
|
141
153
|
getLog(): DistillationLog[];
|
|
154
|
+
private _adapt;
|
|
155
|
+
/** No exemplar worth learning: learn the caller's fallback text instead. */
|
|
156
|
+
private _learnFallback;
|
|
157
|
+
/** Nothing adapted. */
|
|
158
|
+
private _skip;
|
|
142
159
|
private _appendLog;
|
|
143
160
|
}
|
|
144
161
|
//# sourceMappingURL=DistillationEngine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DistillationEngine.d.ts","sourceRoot":"","sources":["../../src/distillation/DistillationEngine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"DistillationEngine.d.ts","sourceRoot":"","sources":["../../src/distillation/DistillationEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,M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IACpE,OAAO,CAAC,KAAK;IAKb,qFAAqF;IACrF,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,cAAc;IAMtB;;;;;;;;OAQG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,cAAc,CAAC,CAAC,CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAgErF;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,cAAc,CAAC,CAAC,CAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAkBlG;;OAEG;IACH,MAAM,IAAI,eAAe,EAAE;YAMb,MAAM;IAYpB,4EAA4E;YAC9D,cAAc;IA2B5B,uBAAuB;IACvB,OAAO,CAAC,KAAK;IAqBb,OAAO,CAAC,UAAU;CAMrB"}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DistillationEngine –
|
|
2
|
+
* DistillationEngine – online knowledge distillation.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This runs entirely in the browser with no Python or full-retraining required.
|
|
4
|
+
* A *teacher* (a frontier model) writes the ideal response; the *student* is adapted
|
|
5
|
+
* on it. Runs with no Python and no full retraining.
|
|
7
6
|
*
|
|
8
7
|
* Distillation flow:
|
|
9
|
-
* 1.
|
|
10
|
-
* 2.
|
|
11
|
-
* 3.
|
|
8
|
+
* 1. teacher.generate(input) → exemplar
|
|
9
|
+
* 2. quality gate (length / already-learned) → skip, or fall back to the caller's text
|
|
10
|
+
* 3. student.adapt(input + exemplar, + rehearsed past exemplars)
|
|
11
|
+
* 4. log the outcome
|
|
12
|
+
*
|
|
13
|
+
* Teacher and student are ports ({@link ./ports}). Passing an `SSMRuntime` and a
|
|
14
|
+
* `TransformerBridge` — the original pairing — still works unchanged.
|
|
12
15
|
*/
|
|
13
16
|
import { SSMError } from '../errors/SSMError.js';
|
|
17
|
+
import { isDistillationStudent, ssmRuntimeStudent } from './ports.js';
|
|
14
18
|
/** Maximum number of distillation log entries to retain in memory. */
|
|
15
19
|
const MAX_LOG_ENTRIES = 200;
|
|
16
20
|
// ── DistillationEngine ────────────────────────────────────────────────────────
|
|
17
21
|
export class DistillationEngine {
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
_student;
|
|
23
|
+
_teacher;
|
|
20
24
|
_log = [];
|
|
21
25
|
// ── Rehearsal buffer (EVM-5 catastrophic-forgetting guard) ─────────────────
|
|
22
26
|
_rehearsalSize;
|
|
@@ -24,16 +28,16 @@ export class DistillationEngine {
|
|
|
24
28
|
_rehearsal = [];
|
|
25
29
|
_rehearsalState;
|
|
26
30
|
/**
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* `bufferSize > 0`, each adapt also trains on a sample of past
|
|
32
|
-
* exemplars to guard against catastrophic forgetting.
|
|
31
|
+
* @param student What learns: an `SSMRuntime`, or any {@link DistillationStudent}.
|
|
32
|
+
* @param teacher What teaches: any `TransformerBridge`, or any {@link DistillationTeacher}.
|
|
33
|
+
* @param rehearsal Optional experience-replay config (EVM-5). When `bufferSize > 0`,
|
|
34
|
+
* each adapt also trains on a sample of past exemplars.
|
|
33
35
|
*/
|
|
34
|
-
constructor(
|
|
35
|
-
this.
|
|
36
|
-
|
|
36
|
+
constructor(student, teacher, rehearsal = {}) {
|
|
37
|
+
this._student = isDistillationStudent(student)
|
|
38
|
+
? student
|
|
39
|
+
: ssmRuntimeStudent(student);
|
|
40
|
+
this._teacher = teacher;
|
|
37
41
|
this._rehearsalSize = Math.max(0, rehearsal.bufferSize ?? 0);
|
|
38
42
|
this._rehearsalK = Math.max(0, rehearsal.sampleK ?? 2);
|
|
39
43
|
this._rehearsalState = (rehearsal.seed ?? 1) >>> 0 || 1;
|
|
@@ -73,102 +77,65 @@ export class DistillationEngine {
|
|
|
73
77
|
* Runs a single distillation pass:
|
|
74
78
|
* 1. Teacher generates a response for `input`
|
|
75
79
|
* 2. Quality gate is evaluated (if configured)
|
|
76
|
-
* 3.
|
|
80
|
+
* 3. Student is adapted on `input` + the teacher's output
|
|
77
81
|
*
|
|
78
|
-
* The training signal is the teacher's full response — this teaches the
|
|
79
|
-
*
|
|
80
|
-
* labelled data or a loss function beyond the standard LM objective.
|
|
82
|
+
* The training signal is the teacher's full response — this teaches the student
|
|
83
|
+
* what a good response to that prompt looks like, without labelled data.
|
|
81
84
|
*/
|
|
82
85
|
async distill(input, opts = {}) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
epochs: 3,
|
|
86
|
-
...opts.adapt,
|
|
87
|
-
};
|
|
88
|
-
let teacherOutput;
|
|
86
|
+
let teacherOutput = '';
|
|
87
|
+
let teacherError;
|
|
89
88
|
try {
|
|
90
|
-
teacherOutput = await this.
|
|
89
|
+
teacherOutput = await this._teacher.generate(input, opts.generate);
|
|
91
90
|
}
|
|
92
91
|
catch (err) {
|
|
93
|
-
|
|
92
|
+
if (opts.fallbackText === undefined) {
|
|
93
|
+
throw new SSMError('DISTILL_FAILED', `Teacher bridge failed to generate for distillation: ${err instanceof Error ? err.message : String(err)}`, err);
|
|
94
|
+
}
|
|
95
|
+
teacherError = err;
|
|
96
|
+
}
|
|
97
|
+
if (teacherError !== undefined) {
|
|
98
|
+
return this._learnFallback(input, '', 'teacher_failed', opts, teacherError);
|
|
94
99
|
}
|
|
95
100
|
// ── Quality gate ──────────────────────────────────────────────────────
|
|
96
|
-
// Pre-adapt novelty of this exemplar
|
|
97
|
-
// Measured by the gate below; hoisted so it survives to the TRAINED path instead
|
|
98
|
-
// of being dropped for exactly the exemplars we go on to learn from.
|
|
101
|
+
// Pre-adapt novelty of this exemplar, hoisted so it survives to the TRAINED path.
|
|
99
102
|
let gatePerplexity;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
this._appendLog({
|
|
111
|
-
input,
|
|
112
|
-
teacherOutputLength: teacherOutput.length,
|
|
113
|
-
skipped: true,
|
|
114
|
-
skipReason: 'low_quality',
|
|
115
|
-
epochs: 0,
|
|
116
|
-
});
|
|
117
|
-
return result;
|
|
103
|
+
const gate = opts.qualityGate;
|
|
104
|
+
if (gate?.minLength != null && teacherOutput.length < gate.minLength) {
|
|
105
|
+
if (opts.fallbackText !== undefined)
|
|
106
|
+
return this._learnFallback(input, teacherOutput, 'low_quality', opts);
|
|
107
|
+
return this._skip(input, teacherOutput, 'low_quality');
|
|
108
|
+
}
|
|
109
|
+
if (gate?.maxPerplexity != null && this._student.evaluate) {
|
|
110
|
+
try {
|
|
111
|
+
gatePerplexity = await this._student.evaluate(teacherOutput);
|
|
118
112
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// Evaluation failure is non-fatal — proceed with adaptation
|
|
125
|
-
}
|
|
126
|
-
if (gatePerplexity != null && gatePerplexity < gate.maxPerplexity) {
|
|
127
|
-
const result = {
|
|
128
|
-
input,
|
|
129
|
-
teacherOutput,
|
|
130
|
-
adaptResult: { losses: [], epochCount: 0, durationMs: 0 },
|
|
131
|
-
skipped: true,
|
|
132
|
-
skipReason: 'already_learned',
|
|
133
|
-
gatePerplexity,
|
|
134
|
-
};
|
|
135
|
-
this._appendLog({
|
|
136
|
-
input,
|
|
137
|
-
teacherOutputLength: teacherOutput.length,
|
|
138
|
-
skipped: true,
|
|
139
|
-
skipReason: 'already_learned',
|
|
140
|
-
epochs: 0,
|
|
141
|
-
gatePerplexity,
|
|
142
|
-
});
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
113
|
+
catch {
|
|
114
|
+
// Evaluation failure is non-fatal — proceed with adaptation
|
|
115
|
+
}
|
|
116
|
+
if (gatePerplexity != null && gatePerplexity < gate.maxPerplexity) {
|
|
117
|
+
return this._skip(input, teacherOutput, 'already_learned', gatePerplexity);
|
|
145
118
|
}
|
|
146
119
|
}
|
|
147
|
-
// Train the
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
// knowledge instead of overwriting it (catastrophic-forgetting guard).
|
|
120
|
+
// Train on the (prompt → response) mapping. EVM-5: interleave a sample of past
|
|
121
|
+
// exemplars (experience replay) so this adapt reinforces prior knowledge
|
|
122
|
+
// instead of overwriting it.
|
|
151
123
|
const rehearsed = this._sampleRehearsal();
|
|
152
|
-
const
|
|
153
|
-
const trainingText =
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
catch (err) {
|
|
159
|
-
throw new SSMError('DISTILL_FAILED', `SSM adaptation failed during distillation: ${err instanceof Error ? err.message : String(err)}`, err);
|
|
160
|
-
}
|
|
161
|
-
// Record the new exemplar for future rehearsal.
|
|
124
|
+
const context = (i) => (opts.contextChars != null ? i.trim().slice(0, opts.contextChars) : i);
|
|
125
|
+
const trainingText = [...rehearsed, { input, teacherOutput }]
|
|
126
|
+
.map((p) => `${context(p.input)}\n${p.teacherOutput}`)
|
|
127
|
+
.join('\n\n');
|
|
128
|
+
const adaptResult = await this._adapt(trainingText, opts);
|
|
162
129
|
this._pushRehearsal(input, teacherOutput);
|
|
163
130
|
this._appendLog({
|
|
164
131
|
input,
|
|
165
132
|
teacherOutputLength: teacherOutput.length,
|
|
166
133
|
skipped: false,
|
|
167
|
-
|
|
168
|
-
|
|
134
|
+
distilled: true,
|
|
135
|
+
...this._student.describe(adaptResult),
|
|
169
136
|
gatePerplexity,
|
|
170
137
|
});
|
|
171
|
-
return { input, teacherOutput, adaptResult, skipped: false, rehearsed: rehearsed.length, gatePerplexity };
|
|
138
|
+
return { input, teacherOutput, adaptResult, skipped: false, distilled: true, rehearsed: rehearsed.length, gatePerplexity };
|
|
172
139
|
}
|
|
173
140
|
/**
|
|
174
141
|
* Runs distillation for each input in sequence.
|
|
@@ -181,7 +148,7 @@ export class DistillationEngine {
|
|
|
181
148
|
for (const input of inputs) {
|
|
182
149
|
const result = await this.distill(input, opts);
|
|
183
150
|
results.push(result);
|
|
184
|
-
totalEpochs += result.adaptResult.
|
|
151
|
+
totalEpochs += this._student.describe(result.adaptResult).epochs;
|
|
185
152
|
}
|
|
186
153
|
return {
|
|
187
154
|
results,
|
|
@@ -196,6 +163,56 @@ export class DistillationEngine {
|
|
|
196
163
|
return this._log.slice();
|
|
197
164
|
}
|
|
198
165
|
// ── Private helpers ───────────────────────────────────────────────────────
|
|
166
|
+
async _adapt(trainingText, opts) {
|
|
167
|
+
try {
|
|
168
|
+
return await this._student.adapt(trainingText, opts.adapt);
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
throw new SSMError('DISTILL_FAILED', `SSM adaptation failed during distillation: ${err instanceof Error ? err.message : String(err)}`, err);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** No exemplar worth learning: learn the caller's fallback text instead. */
|
|
175
|
+
async _learnFallback(input, teacherOutput, skipReason, opts, teacherError) {
|
|
176
|
+
const adaptResult = await this._adapt(opts.fallbackText, opts);
|
|
177
|
+
this._appendLog({
|
|
178
|
+
input,
|
|
179
|
+
teacherOutputLength: teacherOutput.length,
|
|
180
|
+
skipped: false,
|
|
181
|
+
distilled: false,
|
|
182
|
+
skipReason,
|
|
183
|
+
...this._student.describe(adaptResult),
|
|
184
|
+
});
|
|
185
|
+
return {
|
|
186
|
+
input,
|
|
187
|
+
teacherOutput,
|
|
188
|
+
adaptResult,
|
|
189
|
+
skipped: false,
|
|
190
|
+
distilled: false,
|
|
191
|
+
skipReason,
|
|
192
|
+
...(teacherError !== undefined ? { teacherError } : {}),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/** Nothing adapted. */
|
|
196
|
+
_skip(input, teacherOutput, skipReason, gatePerplexity) {
|
|
197
|
+
this._appendLog({
|
|
198
|
+
input,
|
|
199
|
+
teacherOutputLength: teacherOutput.length,
|
|
200
|
+
skipped: true,
|
|
201
|
+
distilled: false,
|
|
202
|
+
skipReason,
|
|
203
|
+
epochs: 0,
|
|
204
|
+
gatePerplexity,
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
input,
|
|
208
|
+
teacherOutput,
|
|
209
|
+
adaptResult: this._student.skippedResult(),
|
|
210
|
+
skipped: true,
|
|
211
|
+
distilled: false,
|
|
212
|
+
skipReason,
|
|
213
|
+
...(gatePerplexity !== undefined ? { gatePerplexity } : {}),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
199
216
|
_appendLog(entry) {
|
|
200
217
|
this._log.push({ timestamp: Date.now(), ...entry });
|
|
201
218
|
if (this._log.length > MAX_LOG_ENTRIES) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DistillationEngine.js","sourceRoot":"","sources":["../../src/distillation/DistillationEngine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"DistillationEngine.js","sourceRoot":"","sources":["../../src/distillation/DistillationEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAsD,MAAM,YAAY,CAAC;AA4G1H,sEAAsE;AACtE,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,iFAAiF;AAEjF,MAAM,OAAO,kBAAkB;IACV,QAAQ,CAA8B;IACtC,QAAQ,CAAwB;IAChC,IAAI,GAA4B,EAAE,CAAC;IAEpD,8EAA8E;IAC7D,cAAc,CAAU;IACxB,WAAW,CAAa;IACxB,UAAU,GAAyD,EAAE,CAAC;IAC/E,eAAe,CAAkB;IAEzC;;;;;OAKG;IACH,YAAY,OAA+C,EAAE,OAA4B,EAAE,YAA8B,EAAE;QACvH,IAAI,CAAC,QAAQ,GAAG,qBAAqB,CAAO,OAAO,CAAC;YAChD,CAAC,CAAC,OAAO;YACT,CAAC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