webslm 0.10.0 → 0.11.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.
- package/README.md +32 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.js +3 -0
- package/dist/engine.js +57 -0
- package/dist/index.d.ts +1 -0
- package/dist/models.d.ts +27 -0
- package/dist/models.js +57 -0
- package/dist/native.d.ts +14 -0
- package/dist/protocol.d.ts +14 -0
- package/dist/train.d.ts +201 -0
- package/dist/train.js +99 -0
- package/native-manifest.json +29 -29
- package/package.json +1 -1
- package/wasm/relaxed/webslm_wasm.d.ts +58 -3
- package/wasm/relaxed/webslm_wasm.js +162 -15
- package/wasm/relaxed/webslm_wasm_bg.wasm +0 -0
- package/wasm/relaxed/webslm_wasm_bg.wasm.d.ts +11 -3
- package/wasm/simd/webslm_wasm.d.ts +58 -3
- package/wasm/simd/webslm_wasm.js +162 -15
- package/wasm/simd/webslm_wasm_bg.wasm +0 -0
- package/wasm/simd/webslm_wasm_bg.wasm.d.ts +11 -3
- package/wasm/threads/webslm_wasm.d.ts +59 -4
- package/wasm/threads/webslm_wasm.js +174 -27
- package/wasm/threads/webslm_wasm_bg.wasm +0 -0
- package/wasm/threads/webslm_wasm_bg.wasm.d.ts +12 -4
package/wasm/simd/webslm_wasm.js
CHANGED
|
@@ -778,6 +778,135 @@ export class WasmSession {
|
|
|
778
778
|
}
|
|
779
779
|
if (Symbol.dispose) WasmSession.prototype[Symbol.dispose] = WasmSession.prototype.free;
|
|
780
780
|
|
|
781
|
+
/**
|
|
782
|
+
* A model being trained.
|
|
783
|
+
*/
|
|
784
|
+
export class WasmTrainer {
|
|
785
|
+
static __wrap(ptr) {
|
|
786
|
+
const obj = Object.create(WasmTrainer.prototype);
|
|
787
|
+
obj.__wbg_ptr = ptr;
|
|
788
|
+
WasmTrainerFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
789
|
+
return obj;
|
|
790
|
+
}
|
|
791
|
+
__destroy_into_raw() {
|
|
792
|
+
const ptr = this.__wbg_ptr;
|
|
793
|
+
this.__wbg_ptr = 0;
|
|
794
|
+
WasmTrainerFinalization.unregister(this);
|
|
795
|
+
return ptr;
|
|
796
|
+
}
|
|
797
|
+
free() {
|
|
798
|
+
const ptr = this.__destroy_into_raw();
|
|
799
|
+
wasm.__wbg_wasmtrainer_free(ptr, 0);
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Adds a sequence to group `group`: `teacher` is `"none"`, `"base"`,
|
|
803
|
+
* `"topk"` (`k` ids and probabilities per prediction) or `"logits"`.
|
|
804
|
+
* @param {number} group
|
|
805
|
+
* @param {Uint32Array} ids
|
|
806
|
+
* @param {Float32Array | null | undefined} weights
|
|
807
|
+
* @param {string} teacher
|
|
808
|
+
* @param {number} k
|
|
809
|
+
* @param {Uint32Array | null} [teacher_ids]
|
|
810
|
+
* @param {Float32Array | null} [teacher_values]
|
|
811
|
+
*/
|
|
812
|
+
addExample(group, ids, weights, teacher, k, teacher_ids, teacher_values) {
|
|
813
|
+
const ptr0 = passArray32ToWasm0(ids, wasm.__wbindgen_malloc);
|
|
814
|
+
const len0 = WASM_VECTOR_LEN;
|
|
815
|
+
var ptr1 = isLikeNone(weights) ? 0 : passArrayF32ToWasm0(weights, wasm.__wbindgen_malloc);
|
|
816
|
+
var len1 = WASM_VECTOR_LEN;
|
|
817
|
+
const ptr2 = passStringToWasm0(teacher, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
818
|
+
const len2 = WASM_VECTOR_LEN;
|
|
819
|
+
var ptr3 = isLikeNone(teacher_ids) ? 0 : passArray32ToWasm0(teacher_ids, wasm.__wbindgen_malloc);
|
|
820
|
+
var len3 = WASM_VECTOR_LEN;
|
|
821
|
+
var ptr4 = isLikeNone(teacher_values) ? 0 : passArrayF32ToWasm0(teacher_values, wasm.__wbindgen_malloc);
|
|
822
|
+
var len4 = WASM_VECTOR_LEN;
|
|
823
|
+
const ret = wasm.wasmtrainer_addExample(this.__wbg_ptr, group, ptr0, len0, ptr1, len1, ptr2, len2, k, ptr3, len3, ptr4, len4);
|
|
824
|
+
if (ret[1]) {
|
|
825
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Adds a data group (`TrainGroupJs`: `{ batchSize?, weight?, ce?,
|
|
830
|
+
* kl?, reduction?, sampling?, sampleWeights? }`); returns its index.
|
|
831
|
+
* Groups take effect at [`WasmTrainer::commit`].
|
|
832
|
+
* @param {string} group_json
|
|
833
|
+
* @returns {number}
|
|
834
|
+
*/
|
|
835
|
+
addGroup(group_json) {
|
|
836
|
+
const ptr0 = passStringToWasm0(group_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
837
|
+
const len0 = WASM_VECTOR_LEN;
|
|
838
|
+
const ret = wasm.wasmtrainer_addGroup(this.__wbg_ptr, ptr0, len0);
|
|
839
|
+
if (ret[2]) {
|
|
840
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
841
|
+
}
|
|
842
|
+
return ret[0] >>> 0;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Sets the groups added so far as the data steps draw from (replacing
|
|
846
|
+
* earlier ones).
|
|
847
|
+
*/
|
|
848
|
+
commit() {
|
|
849
|
+
const ret = wasm.wasmtrainer_commit(this.__wbg_ptr);
|
|
850
|
+
if (ret[1]) {
|
|
851
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* The trained delta as files, `{ [name]: Uint8Array }`: `format`
|
|
856
|
+
* `"peft"` (default: `adapter_config.json` and
|
|
857
|
+
* `adapter_model.safetensors`) or `"dense"` (`delta.safetensors`).
|
|
858
|
+
* `base_model` fills `base_model_name_or_path`.
|
|
859
|
+
* @param {string | null} [format]
|
|
860
|
+
* @param {string | null} [base_model]
|
|
861
|
+
* @returns {Promise<any>}
|
|
862
|
+
*/
|
|
863
|
+
files(format, base_model) {
|
|
864
|
+
var ptr0 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
865
|
+
var len0 = WASM_VECTOR_LEN;
|
|
866
|
+
var ptr1 = isLikeNone(base_model) ? 0 : passStringToWasm0(base_model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
867
|
+
var len1 = WASM_VECTOR_LEN;
|
|
868
|
+
const ret = wasm.wasmtrainer_files(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
869
|
+
return ret;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Describes the trainer (see `TrainerInfo`).
|
|
873
|
+
* @returns {any}
|
|
874
|
+
*/
|
|
875
|
+
info() {
|
|
876
|
+
const ret = wasm.wasmtrainer_info(this.__wbg_ptr);
|
|
877
|
+
if (ret[2]) {
|
|
878
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
879
|
+
}
|
|
880
|
+
return takeFromExternrefTable0(ret[0]);
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Loads the model of `source` for training. `options_json`: see
|
|
884
|
+
* `TrainOptionsJs` (`{ steps, method?, rank?, alpha?, targets?,
|
|
885
|
+
* layers?, lr?, ..., device? }`).
|
|
886
|
+
* @param {JsSource} source
|
|
887
|
+
* @param {string} options_json
|
|
888
|
+
* @returns {Promise<WasmTrainer>}
|
|
889
|
+
*/
|
|
890
|
+
static load(source, options_json) {
|
|
891
|
+
_assertClass(source, JsSource);
|
|
892
|
+
var ptr0 = source.__destroy_into_raw();
|
|
893
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
894
|
+
const len1 = WASM_VECTOR_LEN;
|
|
895
|
+
const ret = wasm.wasmtrainer_load(ptr0, ptr1, len1);
|
|
896
|
+
return ret;
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Runs one optimizer step; resolves to `{ step, lr, loss,
|
|
900
|
+
* groupLosses, tokens, clamped, timeMs }`.
|
|
901
|
+
* @returns {Promise<any>}
|
|
902
|
+
*/
|
|
903
|
+
step() {
|
|
904
|
+
const ret = wasm.wasmtrainer_step(this.__wbg_ptr);
|
|
905
|
+
return ret;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
if (Symbol.dispose) WasmTrainer.prototype[Symbol.dispose] = WasmTrainer.prototype.free;
|
|
909
|
+
|
|
781
910
|
/**
|
|
782
911
|
* How this module was built: `{ flavour, kernels, threads }`. `flavour`
|
|
783
912
|
* is `"simd"`, `"relaxed"` (SIMD128 and relaxed SIMD) or `"threads"`
|
|
@@ -1365,6 +1494,10 @@ function __wbg_get_imports() {
|
|
|
1365
1494
|
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
1366
1495
|
return ret;
|
|
1367
1496
|
},
|
|
1497
|
+
__wbg_now_d1fb6650485d7f3e: function() {
|
|
1498
|
+
const ret = Date.now();
|
|
1499
|
+
return ret;
|
|
1500
|
+
},
|
|
1368
1501
|
__wbg_onSubmittedWorkDone_f62945abb48d8a84: function(arg0) {
|
|
1369
1502
|
const ret = arg0.onSubmittedWorkDone();
|
|
1370
1503
|
return ret;
|
|
@@ -1682,37 +1815,41 @@ function __wbg_get_imports() {
|
|
|
1682
1815
|
const ret = WasmModel.__wrap(arg0);
|
|
1683
1816
|
return ret;
|
|
1684
1817
|
},
|
|
1818
|
+
__wbg_wasmtrainer_new: function(arg0) {
|
|
1819
|
+
const ret = WasmTrainer.__wrap(arg0);
|
|
1820
|
+
return ret;
|
|
1821
|
+
},
|
|
1685
1822
|
__wbg_writeBuffer_badef58fae6c9543: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
|
|
1686
1823
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
1687
1824
|
}, arguments); },
|
|
1688
1825
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1689
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1826
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 380, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1690
1827
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1691
1828
|
return ret;
|
|
1692
1829
|
},
|
|
1693
1830
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1694
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx:
|
|
1831
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 306, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1695
1832
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1696
1833
|
return ret;
|
|
1697
1834
|
},
|
|
1698
1835
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1699
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx:
|
|
1836
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 310, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1700
1837
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_);
|
|
1701
1838
|
return ret;
|
|
1702
1839
|
},
|
|
1703
1840
|
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
1704
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
1705
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1841
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 310, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1842
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__55);
|
|
1706
1843
|
return ret;
|
|
1707
1844
|
},
|
|
1708
1845
|
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
|
1709
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx:
|
|
1710
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1846
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 306, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1847
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__56);
|
|
1711
1848
|
return ret;
|
|
1712
1849
|
},
|
|
1713
1850
|
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
|
1714
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx:
|
|
1715
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1851
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 306, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1852
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__57);
|
|
1716
1853
|
return ret;
|
|
1717
1854
|
},
|
|
1718
1855
|
__wbindgen_generic_0000000000000007: function(arg0) {
|
|
@@ -1755,8 +1892,8 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_549
|
|
|
1755
1892
|
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_(arg0, arg1, arg2);
|
|
1756
1893
|
}
|
|
1757
1894
|
|
|
1758
|
-
function
|
|
1759
|
-
wasm.
|
|
1895
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__55(arg0, arg1, arg2) {
|
|
1896
|
+
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__55(arg0, arg1, arg2);
|
|
1760
1897
|
}
|
|
1761
1898
|
|
|
1762
1899
|
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_(arg0, arg1, arg2) {
|
|
@@ -1773,15 +1910,15 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bin
|
|
|
1773
1910
|
}
|
|
1774
1911
|
}
|
|
1775
1912
|
|
|
1776
|
-
function
|
|
1777
|
-
const ret = wasm.
|
|
1913
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__56(arg0, arg1, arg2) {
|
|
1914
|
+
const ret = wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__56(arg0, arg1, arg2);
|
|
1778
1915
|
if (ret[1]) {
|
|
1779
1916
|
throw takeFromExternrefTable0(ret[0]);
|
|
1780
1917
|
}
|
|
1781
1918
|
}
|
|
1782
1919
|
|
|
1783
|
-
function
|
|
1784
|
-
const ret = wasm.
|
|
1920
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__57(arg0, arg1, arg2) {
|
|
1921
|
+
const ret = wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__57(arg0, arg1, arg2);
|
|
1785
1922
|
if (ret[1]) {
|
|
1786
1923
|
throw takeFromExternrefTable0(ret[0]);
|
|
1787
1924
|
}
|
|
@@ -1838,6 +1975,9 @@ const WasmModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
1838
1975
|
const WasmSessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1839
1976
|
? { register: () => {}, unregister: () => {} }
|
|
1840
1977
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsession_free(ptr, 1));
|
|
1978
|
+
const WasmTrainerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1979
|
+
? { register: () => {}, unregister: () => {} }
|
|
1980
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtrainer_free(ptr, 1));
|
|
1841
1981
|
|
|
1842
1982
|
function addToExternrefTable0(obj) {
|
|
1843
1983
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -2047,6 +2187,13 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
2047
2187
|
return ptr;
|
|
2048
2188
|
}
|
|
2049
2189
|
|
|
2190
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
2191
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
2192
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
2193
|
+
WASM_VECTOR_LEN = arg.length;
|
|
2194
|
+
return ptr;
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2050
2197
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
2051
2198
|
if (realloc === undefined) {
|
|
2052
2199
|
const buf = cachedTextEncoder.encode(arg);
|
|
Binary file
|
|
@@ -7,6 +7,7 @@ export const __wbg_sha256hasher_free: (a: number, b: number) => void;
|
|
|
7
7
|
export const __wbg_wasmimagemodel_free: (a: number, b: number) => void;
|
|
8
8
|
export const __wbg_wasmmodel_free: (a: number, b: number) => void;
|
|
9
9
|
export const __wbg_wasmsession_free: (a: number, b: number) => void;
|
|
10
|
+
export const __wbg_wasmtrainer_free: (a: number, b: number) => void;
|
|
10
11
|
export const buildInfo: () => [number, number, number];
|
|
11
12
|
export const jssource_new: (a: any, b: number) => number;
|
|
12
13
|
export const jsweightcache_new: (a: number, b: number, c: number, d: any, e: any) => number;
|
|
@@ -51,13 +52,20 @@ export const wasmsession_shiftContext: (a: number, b: number, c: number) => any;
|
|
|
51
52
|
export const wasmsession_step: (a: number, b: number, c: number, d: number) => any;
|
|
52
53
|
export const wasmsession_tokens: (a: number) => [number, number, number, number];
|
|
53
54
|
export const wasmsession_truncate: (a: number, b: number) => [number, number];
|
|
55
|
+
export const wasmtrainer_addExample: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number];
|
|
56
|
+
export const wasmtrainer_addGroup: (a: number, b: number, c: number) => [number, number, number];
|
|
57
|
+
export const wasmtrainer_commit: (a: number) => [number, number];
|
|
58
|
+
export const wasmtrainer_files: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
59
|
+
export const wasmtrainer_info: (a: number) => [number, number, number];
|
|
60
|
+
export const wasmtrainer_load: (a: number, b: number, c: number) => any;
|
|
61
|
+
export const wasmtrainer_step: (a: number) => any;
|
|
54
62
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
55
63
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
56
64
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
57
|
-
export const
|
|
58
|
-
export const
|
|
65
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__56: (a: number, b: number, c: any) => [number, number];
|
|
66
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__57: (a: number, b: number, c: any) => [number, number];
|
|
59
67
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_: (a: number, b: number, c: any) => void;
|
|
60
|
-
export const
|
|
68
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__55: (a: number, b: number, c: any) => void;
|
|
61
69
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
62
70
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
63
71
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
@@ -330,6 +330,53 @@ export class WasmSession {
|
|
|
330
330
|
readonly length: number;
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
+
/**
|
|
334
|
+
* A model being trained.
|
|
335
|
+
*/
|
|
336
|
+
export class WasmTrainer {
|
|
337
|
+
private constructor();
|
|
338
|
+
free(): void;
|
|
339
|
+
[Symbol.dispose](): void;
|
|
340
|
+
/**
|
|
341
|
+
* Adds a sequence to group `group`: `teacher` is `"none"`, `"base"`,
|
|
342
|
+
* `"topk"` (`k` ids and probabilities per prediction) or `"logits"`.
|
|
343
|
+
*/
|
|
344
|
+
addExample(group: number, ids: Uint32Array, weights: Float32Array | null | undefined, teacher: string, k: number, teacher_ids?: Uint32Array | null, teacher_values?: Float32Array | null): void;
|
|
345
|
+
/**
|
|
346
|
+
* Adds a data group (`TrainGroupJs`: `{ batchSize?, weight?, ce?,
|
|
347
|
+
* kl?, reduction?, sampling?, sampleWeights? }`); returns its index.
|
|
348
|
+
* Groups take effect at [`WasmTrainer::commit`].
|
|
349
|
+
*/
|
|
350
|
+
addGroup(group_json: string): number;
|
|
351
|
+
/**
|
|
352
|
+
* Sets the groups added so far as the data steps draw from (replacing
|
|
353
|
+
* earlier ones).
|
|
354
|
+
*/
|
|
355
|
+
commit(): void;
|
|
356
|
+
/**
|
|
357
|
+
* The trained delta as files, `{ [name]: Uint8Array }`: `format`
|
|
358
|
+
* `"peft"` (default: `adapter_config.json` and
|
|
359
|
+
* `adapter_model.safetensors`) or `"dense"` (`delta.safetensors`).
|
|
360
|
+
* `base_model` fills `base_model_name_or_path`.
|
|
361
|
+
*/
|
|
362
|
+
files(format?: string | null, base_model?: string | null): Promise<any>;
|
|
363
|
+
/**
|
|
364
|
+
* Describes the trainer (see `TrainerInfo`).
|
|
365
|
+
*/
|
|
366
|
+
info(): any;
|
|
367
|
+
/**
|
|
368
|
+
* Loads the model of `source` for training. `options_json`: see
|
|
369
|
+
* `TrainOptionsJs` (`{ steps, method?, rank?, alpha?, targets?,
|
|
370
|
+
* layers?, lr?, ..., device? }`).
|
|
371
|
+
*/
|
|
372
|
+
static load(source: JsSource, options_json: string): Promise<WasmTrainer>;
|
|
373
|
+
/**
|
|
374
|
+
* Runs one optimizer step; resolves to `{ step, lr, loss,
|
|
375
|
+
* groupLosses, tokens, clamped, timeMs }`.
|
|
376
|
+
*/
|
|
377
|
+
step(): Promise<any>;
|
|
378
|
+
}
|
|
379
|
+
|
|
333
380
|
/**
|
|
334
381
|
* How this module was built: `{ flavour, kernels, threads }`. `flavour`
|
|
335
382
|
* is `"simd"`, `"relaxed"` (SIMD128 and relaxed SIMD) or `"threads"`
|
|
@@ -400,6 +447,7 @@ export interface InitOutput {
|
|
|
400
447
|
readonly __wbg_wasmimagemodel_free: (a: number, b: number) => void;
|
|
401
448
|
readonly __wbg_wasmmodel_free: (a: number, b: number) => void;
|
|
402
449
|
readonly __wbg_wasmsession_free: (a: number, b: number) => void;
|
|
450
|
+
readonly __wbg_wasmtrainer_free: (a: number, b: number) => void;
|
|
403
451
|
readonly __wbg_wbg_rayon_poolbuilder_free: (a: number, b: number) => void;
|
|
404
452
|
readonly buildInfo: () => [number, number, number];
|
|
405
453
|
readonly initThreadPool: (a: number) => any;
|
|
@@ -447,6 +495,13 @@ export interface InitOutput {
|
|
|
447
495
|
readonly wasmsession_step: (a: number, b: number, c: number, d: number) => any;
|
|
448
496
|
readonly wasmsession_tokens: (a: number) => [number, number, number, number];
|
|
449
497
|
readonly wasmsession_truncate: (a: number, b: number) => [number, number];
|
|
498
|
+
readonly wasmtrainer_addExample: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number];
|
|
499
|
+
readonly wasmtrainer_addGroup: (a: number, b: number, c: number) => [number, number, number];
|
|
500
|
+
readonly wasmtrainer_commit: (a: number) => [number, number];
|
|
501
|
+
readonly wasmtrainer_files: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
502
|
+
readonly wasmtrainer_info: (a: number) => [number, number, number];
|
|
503
|
+
readonly wasmtrainer_load: (a: number, b: number, c: number) => any;
|
|
504
|
+
readonly wasmtrainer_step: (a: number) => any;
|
|
450
505
|
readonly wbg_rayon_poolbuilder_build: (a: number) => void;
|
|
451
506
|
readonly wbg_rayon_poolbuilder_numThreads: (a: number) => number;
|
|
452
507
|
readonly wbg_rayon_poolbuilder_receiver: (a: number) => number;
|
|
@@ -454,12 +509,12 @@ export interface InitOutput {
|
|
|
454
509
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b608be85a12bc1d0___Function_fn_wasm_bindgen_3c612a990bfab728___JsValue_____wasm_bindgen_3c612a990bfab728___sys__Undefined___js_sys_b608be85a12bc1d0___Function_fn_wasm_bindgen_3c612a990bfab728___JsValue_____wasm_bindgen_3c612a990bfab728___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
455
510
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue__core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
456
511
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
457
|
-
readonly
|
|
458
|
-
readonly
|
|
512
|
+
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__64: (a: number, b: number, c: any) => [number, number];
|
|
513
|
+
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__65: (a: number, b: number, c: any) => [number, number];
|
|
459
514
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b608be85a12bc1d0___futures__task__wait_async_polyfill__MessageEvent______true_: (a: number, b: number, c: any) => void;
|
|
460
515
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true_: (a: number, b: number, c: any) => void;
|
|
461
|
-
readonly
|
|
462
|
-
readonly
|
|
516
|
+
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__62: (a: number, b: number, c: any) => void;
|
|
517
|
+
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__63: (a: number, b: number, c: any) => void;
|
|
463
518
|
readonly memory: WebAssembly.Memory;
|
|
464
519
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
465
520
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|