@tuned-tensor/local 0.1.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/CHANGELOG.md +23 -0
- package/LICENSE +161 -0
- package/README.md +242 -0
- package/dist/artifacts.d.ts +35 -0
- package/dist/artifacts.js +56 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/contracts.d.ts +471 -0
- package/dist/contracts.js +253 -0
- package/dist/contracts.js.map +1 -0
- package/dist/dataset.d.ts +12 -0
- package/dist/dataset.js +60 -0
- package/dist/dataset.js.map +1 -0
- package/dist/docker-training.d.ts +8 -0
- package/dist/docker-training.js +123 -0
- package/dist/docker-training.js.map +1 -0
- package/dist/doctor.d.ts +7 -0
- package/dist/doctor.js +74 -0
- package/dist/doctor.js.map +1 -0
- package/dist/evaluation.d.ts +23 -0
- package/dist/evaluation.js +318 -0
- package/dist/evaluation.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +316 -0
- package/dist/index.js.map +1 -0
- package/dist/local-project.d.ts +22 -0
- package/dist/local-project.js +74 -0
- package/dist/local-project.js.map +1 -0
- package/dist/model-registry.d.ts +18 -0
- package/dist/model-registry.js +151 -0
- package/dist/model-registry.js.map +1 -0
- package/dist/openrouter.d.ts +16 -0
- package/dist/openrouter.js +39 -0
- package/dist/openrouter.js.map +1 -0
- package/dist/orchestrator.d.ts +14 -0
- package/dist/orchestrator.js +151 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/process-training.d.ts +8 -0
- package/dist/process-training.js +135 -0
- package/dist/process-training.js.map +1 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.js +211 -0
- package/dist/server.js.map +1 -0
- package/dist/store.d.ts +98 -0
- package/dist/store.js +327 -0
- package/dist/store.js.map +1 -0
- package/docs/architecture.md +109 -0
- package/docs/spark.md +86 -0
- package/examples/local-runner.json +14 -0
- package/examples/smoke-run-request.json +34 -0
- package/package.json +40 -0
- package/training/sft-local/pyproject.toml +24 -0
- package/training/sft-local/src/evaluate.py +177 -0
- package/training/sft-local/src/train.py +233 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to Tuned Tensor Local will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 - 2026-06-30
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Initial npm package under `@tuned-tensor/local`.
|
|
10
|
+
- Native Transformers/PEFT evaluation for local runs.
|
|
11
|
+
- Baseline vs fine-tuned comparison using the original Hugging Face base model and the trained HF/PEFT artifact.
|
|
12
|
+
- OpenRouter LLM-judge scoring for locally generated outputs.
|
|
13
|
+
- Step-by-step README guide for install, DGX Spark setup, first dry run, real training, and run inspection.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Default OpenRouter judge model is now `openai/gpt-5.5`.
|
|
18
|
+
- npm package contents now include `docs`, `examples`, and `training`.
|
|
19
|
+
|
|
20
|
+
### Notes
|
|
21
|
+
|
|
22
|
+
- The default evaluation path does not convert models to GGUF.
|
|
23
|
+
- Dry runs still skip model loading and GPU training.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the
|
|
13
|
+
copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other
|
|
16
|
+
entities that control, are controlled by, or are under common control with
|
|
17
|
+
that entity. For the purposes of this definition, "control" means (i) the
|
|
18
|
+
power, direct or indirect, to cause the direction or management of such
|
|
19
|
+
entity, whether by contract or otherwise, or (ii) ownership of fifty percent
|
|
20
|
+
(50%) or more of the outstanding shares, or (iii) beneficial ownership of
|
|
21
|
+
such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
24
|
+
permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation source, and
|
|
28
|
+
configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
31
|
+
translation of a Source form, including but not limited to compiled object
|
|
32
|
+
code, generated documentation, and conversions to other media types.
|
|
33
|
+
|
|
34
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
35
|
+
made available under the License, as indicated by a copyright notice that is
|
|
36
|
+
included in or attached to the work.
|
|
37
|
+
|
|
38
|
+
"Derivative Works" shall mean any work, whether in Source or Object form,
|
|
39
|
+
that is based on (or derived from) the Work and for which the editorial
|
|
40
|
+
revisions, annotations, elaborations, or other modifications represent, as a
|
|
41
|
+
whole, an original work of authorship. For the purposes of this License,
|
|
42
|
+
Derivative Works shall not include works that remain separable from, or
|
|
43
|
+
merely link (or bind by name) to the interfaces of, the Work and Derivative
|
|
44
|
+
Works thereof.
|
|
45
|
+
|
|
46
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
47
|
+
version of the Work and any modifications or additions to that Work or
|
|
48
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
49
|
+
inclusion in the Work by the copyright owner or by an individual or Legal
|
|
50
|
+
Entity authorized to submit on behalf of the copyright owner. For the purposes
|
|
51
|
+
of this definition, "submitted" means any form of electronic, verbal, or
|
|
52
|
+
written communication sent to the Licensor or its representatives, including
|
|
53
|
+
but not limited to communication on electronic mailing lists, source code
|
|
54
|
+
control systems, and issue tracking systems that are managed by, or on behalf
|
|
55
|
+
of, the Licensor for the purpose of discussing and improving the Work, but
|
|
56
|
+
excluding communication that is conspicuously marked or otherwise designated
|
|
57
|
+
in writing by the copyright owner as "Not a Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on
|
|
60
|
+
behalf of whom a Contribution has been received by Licensor and subsequently
|
|
61
|
+
incorporated within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
64
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
65
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
66
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
67
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
68
|
+
Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
71
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
72
|
+
non-exclusive, no-charge, royalty-free, irrevocable patent license to make,
|
|
73
|
+
have made, use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
74
|
+
where such license applies only to those patent claims licensable by such
|
|
75
|
+
Contributor that are necessarily infringed by their Contribution alone or by
|
|
76
|
+
combination of their Contribution with the Work to which such Contribution
|
|
77
|
+
was submitted. If You institute patent litigation against any entity
|
|
78
|
+
(including a cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
79
|
+
or a Contribution incorporated within the Work constitutes direct or
|
|
80
|
+
contributory patent infringement, then any patent licenses granted to You
|
|
81
|
+
under this License for that Work shall terminate as of the date such
|
|
82
|
+
litigation is filed.
|
|
83
|
+
|
|
84
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
85
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
86
|
+
Source or Object form, provided that You meet the following conditions:
|
|
87
|
+
|
|
88
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy
|
|
89
|
+
of this License; and
|
|
90
|
+
|
|
91
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
92
|
+
You changed the files; and
|
|
93
|
+
|
|
94
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
95
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
96
|
+
Source form of the Work, excluding those notices that do not pertain to any
|
|
97
|
+
part of the Derivative Works; and
|
|
98
|
+
|
|
99
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
|
100
|
+
then any Derivative Works that You distribute must include a readable copy of
|
|
101
|
+
the attribution notices contained within such NOTICE file, excluding those
|
|
102
|
+
notices that do not pertain to any part of the Derivative Works, in at least
|
|
103
|
+
one of the following places: within a NOTICE text file distributed as part of
|
|
104
|
+
the Derivative Works; within the Source form or documentation, if provided
|
|
105
|
+
along with the Derivative Works; or, within a display generated by the
|
|
106
|
+
Derivative Works, if and wherever such third-party notices normally appear.
|
|
107
|
+
The contents of the NOTICE file are for informational purposes only and do
|
|
108
|
+
not modify the License. You may add Your own attribution notices within
|
|
109
|
+
Derivative Works that You distribute, alongside or as an addendum to the
|
|
110
|
+
NOTICE text from the Work, provided that such additional attribution notices
|
|
111
|
+
cannot be construed as modifying the License.
|
|
112
|
+
|
|
113
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
114
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
115
|
+
distribution of Your modifications, or for any such Derivative Works as a
|
|
116
|
+
whole, provided Your use, reproduction, and distribution of the Work otherwise
|
|
117
|
+
complies with the conditions stated in this License.
|
|
118
|
+
|
|
119
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
120
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
121
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
122
|
+
additional terms or conditions. Notwithstanding the above, nothing herein
|
|
123
|
+
shall supersede or modify the terms of any separate license agreement you may
|
|
124
|
+
have executed with Licensor regarding such Contributions.
|
|
125
|
+
|
|
126
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
127
|
+
trademarks, service marks, or product names of the Licensor, except as
|
|
128
|
+
required for reasonable and customary use in describing the origin of the Work
|
|
129
|
+
and reproducing the content of the NOTICE file.
|
|
130
|
+
|
|
131
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
132
|
+
writing, Licensor provides the Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
133
|
+
CONDITIONS OF ANY KIND, either express or implied, including, without
|
|
134
|
+
limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
|
|
135
|
+
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
|
|
136
|
+
responsible for determining the appropriateness of using or redistributing
|
|
137
|
+
the Work and assume any risks associated with Your exercise of permissions
|
|
138
|
+
under this License.
|
|
139
|
+
|
|
140
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
141
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
142
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
143
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
144
|
+
direct, indirect, special, incidental, or consequential damages of any
|
|
145
|
+
character arising as a result of this License or out of the use or inability
|
|
146
|
+
to use the Work, including but not limited to damages for loss of goodwill,
|
|
147
|
+
work stoppage, computer failure or malfunction, or any and all other
|
|
148
|
+
commercial damages or losses, even if such Contributor has been advised of
|
|
149
|
+
the possibility of such damages.
|
|
150
|
+
|
|
151
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work
|
|
152
|
+
or Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
153
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
154
|
+
and/or rights consistent with this License. However, in accepting such
|
|
155
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
156
|
+
responsibility, not on behalf of any other Contributor, and only if You agree
|
|
157
|
+
to indemnify, defend, and hold each Contributor harmless for any liability
|
|
158
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
159
|
+
accepting any such warranty or additional liability.
|
|
160
|
+
|
|
161
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Tuned Tensor Local
|
|
2
|
+
|
|
3
|
+
[](https://github.com/tunedtensor/tuned-tensor-local/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
Tuned Tensor Local is a standalone CLI for running Tuned Tensor-style fine-tuning
|
|
6
|
+
jobs on a machine you control. It stores specs, datasets, model artifacts,
|
|
7
|
+
progress, reports, and dashboard state on local disk.
|
|
8
|
+
|
|
9
|
+
It does not require the hosted Tuned Tensor CLI, cloud orchestration, Docker, or
|
|
10
|
+
a managed database.
|
|
11
|
+
|
|
12
|
+
## What It Does
|
|
13
|
+
|
|
14
|
+
`tt-local` runs this workflow locally:
|
|
15
|
+
|
|
16
|
+
1. Read a behavior spec from `tunedtensor.json`.
|
|
17
|
+
2. Compile examples into a training dataset.
|
|
18
|
+
3. Evaluate the original Hugging Face base model.
|
|
19
|
+
4. Fine-tune locally with uv, Transformers, and PEFT.
|
|
20
|
+
5. Evaluate the fine-tuned Hugging Face/PEFT artifact.
|
|
21
|
+
6. Compare baseline vs tuned outputs and write a local report.
|
|
22
|
+
|
|
23
|
+
OpenRouter can be used as an LLM judge for scoring generated outputs. It does
|
|
24
|
+
not generate the baseline or tuned responses.
|
|
25
|
+
|
|
26
|
+
## Install Locally
|
|
27
|
+
|
|
28
|
+
Recommended for development and Spark:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/tunedtensor/tuned-tensor-local.git
|
|
32
|
+
cd tuned-tensor-local
|
|
33
|
+
npm install
|
|
34
|
+
npm run build
|
|
35
|
+
npm link
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
After the package is published, you can install the CLI globally:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g @tuned-tensor/local
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Check the CLI:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
tt-local info
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Set Up DGX Spark
|
|
51
|
+
|
|
52
|
+
On the Spark host, confirm the GPU and uv are available:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
nvidia-smi
|
|
56
|
+
uv --version
|
|
57
|
+
uv run python --version
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If uv is missing:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Open a new shell, then rerun:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uv --version
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Clone this repo on the Spark, install the Node dependencies, and build:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/tunedtensor/tuned-tensor-local.git
|
|
76
|
+
cd tuned-tensor-local
|
|
77
|
+
npm install
|
|
78
|
+
npm run build
|
|
79
|
+
npm link
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Run the doctor:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
tt-local doctor --config examples/local-runner.json
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Run Your First Job
|
|
89
|
+
|
|
90
|
+
Create a local behavior spec:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
tt-local init --name "Support Bot" --model Qwen/Qwen3.5-2B
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Edit `tunedtensor.json` and replace the placeholder example with your task:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"input": "Classify sentiment: I love this product.",
|
|
101
|
+
"output": "positive"
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Validate the spec and config:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
tt-local validate --config examples/local-runner.json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Run the example dry workflow:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
tt-local run --config examples/local-runner.json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The example config has `dryRun: true`, so it checks orchestration and artifact
|
|
118
|
+
writing without loading models or starting GPU training.
|
|
119
|
+
|
|
120
|
+
Inspect the run:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
tt-local runs list --config examples/local-runner.json
|
|
124
|
+
tt-local runs report <run-id> --config examples/local-runner.json
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Start the local dashboard:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
tt-local serve --config examples/local-runner.json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Then open the printed local URL in your browser.
|
|
134
|
+
|
|
135
|
+
## Run Real Training On Spark
|
|
136
|
+
|
|
137
|
+
Create a Spark config, for example `spark-runner.json`:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"artifactRoot": "/home/eve/tt-local-artifacts",
|
|
142
|
+
"storeRoot": "/home/eve/tt-local-store",
|
|
143
|
+
"dryRun": false,
|
|
144
|
+
"training": {
|
|
145
|
+
"backend": "uv",
|
|
146
|
+
"project": "training/sft-local",
|
|
147
|
+
"script": "training/sft-local/src/train.py"
|
|
148
|
+
},
|
|
149
|
+
"evaluation": {
|
|
150
|
+
"inference": {
|
|
151
|
+
"provider": "transformers",
|
|
152
|
+
"project": "training/sft-local",
|
|
153
|
+
"script": "training/sft-local/src/evaluate.py",
|
|
154
|
+
"maxNewTokens": 256,
|
|
155
|
+
"temperature": 0,
|
|
156
|
+
"topP": 1
|
|
157
|
+
},
|
|
158
|
+
"scoring": {
|
|
159
|
+
"mode": "llm_judge",
|
|
160
|
+
"fallback": "exact_match"
|
|
161
|
+
},
|
|
162
|
+
"maxExamples": 10
|
|
163
|
+
},
|
|
164
|
+
"paths": {
|
|
165
|
+
"modelCache": "/home/eve/.cache/huggingface"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
If you want OpenRouter judging, set your key:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
export OPENROUTER_API_KEY="your_openrouter_key"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Run the job:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
tt-local run --config spark-runner.json
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Watch progress:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
tt-local runs watch <run-id> --config spark-runner.json
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
View the final report:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
tt-local runs report <run-id> --config spark-runner.json
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Where Files Go
|
|
195
|
+
|
|
196
|
+
The runner writes two local roots:
|
|
197
|
+
|
|
198
|
+
- `artifactRoot`: datasets, logs, model outputs, eval JSON, and `run-report.json`.
|
|
199
|
+
- `storeRoot`: run/spec/model metadata used by CLI listing and the dashboard.
|
|
200
|
+
|
|
201
|
+
If `storeRoot` is omitted, `tt-local` uses `TT_LOCAL_HOME` or
|
|
202
|
+
`~/.tuned-tensor-local`.
|
|
203
|
+
|
|
204
|
+
## Useful Commands
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
tt-local init --name "Support Bot" --model Qwen/Qwen3.5-2B
|
|
208
|
+
tt-local validate --config spark-runner.json
|
|
209
|
+
tt-local run --config spark-runner.json
|
|
210
|
+
tt-local runs list --config spark-runner.json
|
|
211
|
+
tt-local runs get <run-id> --config spark-runner.json
|
|
212
|
+
tt-local runs events <run-id> --config spark-runner.json
|
|
213
|
+
tt-local runs report <run-id> --config spark-runner.json
|
|
214
|
+
tt-local models list --config spark-runner.json
|
|
215
|
+
tt-local serve --config spark-runner.json
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Development
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
npm install
|
|
222
|
+
npm run typecheck
|
|
223
|
+
npm test
|
|
224
|
+
npm run build
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
CI runs those checks on pull requests and pushes to `main`. Publishing to npm
|
|
228
|
+
runs when a GitHub Release is published and requires an `NPM_TOKEN` repository
|
|
229
|
+
secret.
|
|
230
|
+
|
|
231
|
+
## Notes
|
|
232
|
+
|
|
233
|
+
- Real training uses the included SFT script in `training/sft-local/src/train.py`.
|
|
234
|
+
- Real evaluation uses `training/sft-local/src/evaluate.py`.
|
|
235
|
+
- The default evaluation path uses Hugging Face/PEFT artifacts directly; it does
|
|
236
|
+
not convert models to GGUF.
|
|
237
|
+
- Release notes are in [CHANGELOG.md](CHANGELOG.md).
|
|
238
|
+
- Spark-specific details live in [docs/spark.md](docs/spark.md).
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
Apache-2.0
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface RunArtifacts {
|
|
2
|
+
root: string;
|
|
3
|
+
prefix: string;
|
|
4
|
+
runDir: string;
|
|
5
|
+
trainingJsonl: string;
|
|
6
|
+
baselineEvalJson: string;
|
|
7
|
+
candidateEvalJson: string;
|
|
8
|
+
runReportJson: string;
|
|
9
|
+
progressJsonl: string;
|
|
10
|
+
trainingDir: string;
|
|
11
|
+
trainingInputDir: string;
|
|
12
|
+
trainingConfigDir: string;
|
|
13
|
+
trainingOutputDir: string;
|
|
14
|
+
trainingModelDir: string;
|
|
15
|
+
trainingLog: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function fileUri(path: string): string;
|
|
18
|
+
export declare function defaultArtifactPrefix(input: {
|
|
19
|
+
userId: string;
|
|
20
|
+
behaviorSpecId: string;
|
|
21
|
+
runId: string;
|
|
22
|
+
}): string;
|
|
23
|
+
export declare function resolveRunArtifacts(args: {
|
|
24
|
+
artifactRoot: string;
|
|
25
|
+
prefix: string;
|
|
26
|
+
}): RunArtifacts;
|
|
27
|
+
export declare function prepareRunDirectories(artifacts: RunArtifacts): Promise<void>;
|
|
28
|
+
export declare function writeJson(path: string, value: unknown): Promise<void>;
|
|
29
|
+
export declare function readJson<T>(path: string): Promise<T>;
|
|
30
|
+
export declare function appendProgress(artifacts: RunArtifacts, event: {
|
|
31
|
+
stage: string;
|
|
32
|
+
message: string;
|
|
33
|
+
details?: Record<string, unknown>;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
export declare function copyDatasetToTrainingChannel(artifacts: RunArtifacts): Promise<string>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
3
|
+
export function fileUri(path) {
|
|
4
|
+
return `file://${resolve(path)}`;
|
|
5
|
+
}
|
|
6
|
+
export function defaultArtifactPrefix(input) {
|
|
7
|
+
return join("users", input.userId, "specs", input.behaviorSpecId, "runs", input.runId);
|
|
8
|
+
}
|
|
9
|
+
export function resolveRunArtifacts(args) {
|
|
10
|
+
const root = resolve(args.artifactRoot);
|
|
11
|
+
const safePrefix = args.prefix.replace(/^[/\\]+/, "");
|
|
12
|
+
const runDir = isAbsolute(safePrefix) ? safePrefix : join(root, safePrefix);
|
|
13
|
+
const trainingDir = join(runDir, "training");
|
|
14
|
+
return {
|
|
15
|
+
root,
|
|
16
|
+
prefix: safePrefix,
|
|
17
|
+
runDir,
|
|
18
|
+
trainingJsonl: join(runDir, "training.jsonl"),
|
|
19
|
+
baselineEvalJson: join(runDir, "baseline-eval.json"),
|
|
20
|
+
candidateEvalJson: join(runDir, "candidate-eval.json"),
|
|
21
|
+
runReportJson: join(runDir, "run-report.json"),
|
|
22
|
+
progressJsonl: join(runDir, "progress.jsonl"),
|
|
23
|
+
trainingDir,
|
|
24
|
+
trainingInputDir: join(trainingDir, "input", "data", "training"),
|
|
25
|
+
trainingConfigDir: join(trainingDir, "input", "config"),
|
|
26
|
+
trainingOutputDir: join(trainingDir, "output"),
|
|
27
|
+
trainingModelDir: join(trainingDir, "model"),
|
|
28
|
+
trainingLog: join(trainingDir, "training.log"),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export async function prepareRunDirectories(artifacts) {
|
|
32
|
+
await Promise.all([
|
|
33
|
+
mkdir(artifacts.runDir, { recursive: true }),
|
|
34
|
+
mkdir(artifacts.trainingInputDir, { recursive: true }),
|
|
35
|
+
mkdir(artifacts.trainingConfigDir, { recursive: true }),
|
|
36
|
+
mkdir(artifacts.trainingOutputDir, { recursive: true }),
|
|
37
|
+
mkdir(artifacts.trainingModelDir, { recursive: true }),
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
export async function writeJson(path, value) {
|
|
41
|
+
await mkdir(dirname(path), { recursive: true });
|
|
42
|
+
await writeFile(path, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
43
|
+
}
|
|
44
|
+
export async function readJson(path) {
|
|
45
|
+
return JSON.parse(await readFile(path, "utf8"));
|
|
46
|
+
}
|
|
47
|
+
export async function appendProgress(artifacts, event) {
|
|
48
|
+
await mkdir(artifacts.runDir, { recursive: true });
|
|
49
|
+
await writeFile(artifacts.progressJsonl, `${JSON.stringify({ at: new Date().toISOString(), ...event })}\n`, { encoding: "utf8", flag: "a" });
|
|
50
|
+
}
|
|
51
|
+
export async function copyDatasetToTrainingChannel(artifacts) {
|
|
52
|
+
const destination = join(artifacts.trainingInputDir, "training.jsonl");
|
|
53
|
+
await copyFile(artifacts.trainingJsonl, destination);
|
|
54
|
+
return destination;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QA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