@mlx-node/privacy 0.0.0 → 0.0.9
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/package.json +2 -2
- package/dist/train.d.ts +0 -84
- package/dist/train.d.ts.map +0 -1
- package/dist/train.js +0 -48
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlx-node/privacy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"homepage": "https://github.com/mlx-node/mlx-node",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/mlx-node/mlx-node/issues"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "vite test run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@mlx-node/core": "0.0.
|
|
31
|
+
"@mlx-node/core": "0.0.9"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^26.0.0"
|
package/dist/train.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for {@link PrivacyLoraTrainer.create}.
|
|
3
|
-
*
|
|
4
|
-
* All tunables are optional; omitting a field falls back to the
|
|
5
|
-
* documented defaults from the native trainer:
|
|
6
|
-
*
|
|
7
|
-
* - `rank` = 16, `alpha` = 32, `dropout` = 0.05
|
|
8
|
-
* - `loraLr` = 1e-4, `classifierLr` = 5e-5
|
|
9
|
-
* - `batchSize` = 2, `maxSeqLen` = 256, `numEpochs` = 3
|
|
10
|
-
* - `gradAccumSteps` = 4, `gradClip` = 1.0
|
|
11
|
-
* - `saveEvery` = 500 (set 0 to disable intermediate checkpoints)
|
|
12
|
-
* - `padTokenId` = 0
|
|
13
|
-
*
|
|
14
|
-
* `modelPath`, `dataPath`, and `outputDir` are required.
|
|
15
|
-
*
|
|
16
|
-
* The field names match the native NAPI casing
|
|
17
|
-
* ({@link import('@mlx-node/core').PrivacyLoraTrainConfigJs}) so the
|
|
18
|
-
* wrapper can pass values straight through without re-keying.
|
|
19
|
-
*/
|
|
20
|
-
export interface PrivacyLoraTrainConfig {
|
|
21
|
-
/** Filesystem path to the base privacy-filter checkpoint directory. */
|
|
22
|
-
modelPath: string;
|
|
23
|
-
/** Path to the training JSONL dataset (pre-tokenized). */
|
|
24
|
-
dataPath: string;
|
|
25
|
-
/**
|
|
26
|
-
* Optional evaluation JSONL dataset path. Currently ignored by the
|
|
27
|
-
* trainer — reserved for future eval-loop integration.
|
|
28
|
-
*/
|
|
29
|
-
evalPath?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Directory where `adapter.safetensors`, `adapter_config.json`,
|
|
32
|
-
* `optimizer_state.safetensors`, and `trainer_state.json` are written.
|
|
33
|
-
*/
|
|
34
|
-
outputDir: string;
|
|
35
|
-
rank?: number;
|
|
36
|
-
alpha?: number;
|
|
37
|
-
dropout?: number;
|
|
38
|
-
loraLr?: number;
|
|
39
|
-
classifierLr?: number;
|
|
40
|
-
batchSize?: number;
|
|
41
|
-
maxSeqLen?: number;
|
|
42
|
-
numEpochs?: number;
|
|
43
|
-
gradAccumSteps?: number;
|
|
44
|
-
gradClip?: number;
|
|
45
|
-
saveEvery?: number;
|
|
46
|
-
resumeFrom?: string;
|
|
47
|
-
padTokenId?: number;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* High-level wrapper around the native `PrivacyLoraTrainerJs` NAPI class.
|
|
51
|
-
*
|
|
52
|
-
* The native binding's `create` factory is synchronous (it loads the base
|
|
53
|
-
* checkpoint, attaches zero-B LoRA adapters, and parses the JSONL dataset
|
|
54
|
-
* inline), but the public API here is intentionally `async` so we can later
|
|
55
|
-
* move work to a worker thread without a breaking change to consumers.
|
|
56
|
-
*
|
|
57
|
-
* `train()` and `saveAdapter()` are already async on the native side — they
|
|
58
|
-
* funnel through `spawn_blocking` so the Node.js event loop stays responsive
|
|
59
|
-
* for the duration of the training run.
|
|
60
|
-
*/
|
|
61
|
-
export declare class PrivacyLoraTrainer {
|
|
62
|
-
private readonly inner;
|
|
63
|
-
private constructor();
|
|
64
|
-
/**
|
|
65
|
-
* Construct a new trainer.
|
|
66
|
-
*
|
|
67
|
-
* Loads the base privacy-filter model from `config.modelPath`, attaches
|
|
68
|
-
* zero-B LoRA adapters on every attention projection, and parses the
|
|
69
|
-
* pre-tokenized JSONL dataset at `config.dataPath`.
|
|
70
|
-
*/
|
|
71
|
-
static create(config: PrivacyLoraTrainConfig): Promise<PrivacyLoraTrainer>;
|
|
72
|
-
/**
|
|
73
|
-
* Run the full training loop. Resolves with the final optimizer step
|
|
74
|
-
* count once `numEpochs` epochs have completed.
|
|
75
|
-
*/
|
|
76
|
-
train(): Promise<number>;
|
|
77
|
-
/**
|
|
78
|
-
* Persist adapter weights, optimizer state, and trainer progress to the
|
|
79
|
-
* configured `outputDir`. Overwrites any previous checkpoint at that
|
|
80
|
-
* path.
|
|
81
|
-
*/
|
|
82
|
-
saveAdapter(): Promise<void>;
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=train.d.ts.map
|
package/dist/train.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"train.d.ts","sourceRoot":"","sources":["../src/train.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAkB;IACT,OAAO,CAAC,QAAQ,CAAC,KAAK;IAA1C,OAAO;IAEP;;;;;;OAMG;WACU,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQhF;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAGnC"}
|
package/dist/train.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { PrivacyLoraTrainerJs as NativePrivacyLoraTrainerJs, } from '@mlx-node/core';
|
|
2
|
-
/**
|
|
3
|
-
* High-level wrapper around the native `PrivacyLoraTrainerJs` NAPI class.
|
|
4
|
-
*
|
|
5
|
-
* The native binding's `create` factory is synchronous (it loads the base
|
|
6
|
-
* checkpoint, attaches zero-B LoRA adapters, and parses the JSONL dataset
|
|
7
|
-
* inline), but the public API here is intentionally `async` so we can later
|
|
8
|
-
* move work to a worker thread without a breaking change to consumers.
|
|
9
|
-
*
|
|
10
|
-
* `train()` and `saveAdapter()` are already async on the native side — they
|
|
11
|
-
* funnel through `spawn_blocking` so the Node.js event loop stays responsive
|
|
12
|
-
* for the duration of the training run.
|
|
13
|
-
*/
|
|
14
|
-
export class PrivacyLoraTrainer {
|
|
15
|
-
inner;
|
|
16
|
-
constructor(inner) {
|
|
17
|
-
this.inner = inner;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Construct a new trainer.
|
|
21
|
-
*
|
|
22
|
-
* Loads the base privacy-filter model from `config.modelPath`, attaches
|
|
23
|
-
* zero-B LoRA adapters on every attention projection, and parses the
|
|
24
|
-
* pre-tokenized JSONL dataset at `config.dataPath`.
|
|
25
|
-
*/
|
|
26
|
-
static async create(config) {
|
|
27
|
-
// NAPI requires the camelCase keys to exactly match the interface — pass
|
|
28
|
-
// the object through directly so any future field additions are picked
|
|
29
|
-
// up without an extra mapping table.
|
|
30
|
-
const native = NativePrivacyLoraTrainerJs.create(config);
|
|
31
|
-
return new PrivacyLoraTrainer(native);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Run the full training loop. Resolves with the final optimizer step
|
|
35
|
-
* count once `numEpochs` epochs have completed.
|
|
36
|
-
*/
|
|
37
|
-
async train() {
|
|
38
|
-
return this.inner.train();
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Persist adapter weights, optimizer state, and trainer progress to the
|
|
42
|
-
* configured `outputDir`. Overwrites any previous checkpoint at that
|
|
43
|
-
* path.
|
|
44
|
-
*/
|
|
45
|
-
async saveAdapter() {
|
|
46
|
-
return this.inner.saveAdapter();
|
|
47
|
-
}
|
|
48
|
-
}
|