@toloka-platform/sdk 0.26.2 → 0.27.1
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 +2 -2
- package/dist/cli/toloka.js +180 -191
- package/dist/cli/toloka.js.jsc +0 -0
- package/dist/cli/toloka.js.jsc.sha256 +1 -1
- package/dist/cli/toloka.js.sha256 +1 -1
- package/examples/video-pair-rating/nodes/adjudicate/node.ts +1 -1
- package/examples/video-pair-rating/nodes/adjudicate_op/node.ts +1 -1
- package/examples/video-pair-rating/nodes/overall_preference_pick/node.ts +5 -1
- package/examples/video-pair-rating/nodes/rate_pair/node.ts +5 -1
- package/openapi/gen/api.schemas.ts +52 -756
- package/openapi/gen/api.ts +0 -860
- package/package.json +2 -2
- package/skills/catalog.json +6 -40
- package/skills/toloka-build/references/human-work.md +42 -7
- package/skills/toloka-build/references/local-setup.md +2 -2
- package/skills/toloka-build/references/workflow-and-cli.md +3 -22
- package/skills/toloka-get-started/SKILL.md +9 -13
- package/src/authoring/index.ts +34 -3
- package/src/cli/analytics.ts +0 -31
- package/src/cli/context.ts +0 -109
- package/src/cli/init.ts +1 -1
- package/src/cli/program.ts +0 -6
- package/src/cli/project.ts +9 -1
- package/src/client.ts +0 -259
- package/src/importer.ts +88 -6
- package/src/index.ts +2 -2
- package/src/pipeline-graph-v1.contract.json +130 -101
- package/skills/toloka-fine-tuning/SKILL.md +0 -177
- package/skills/toloka-gisting/SKILL.md +0 -186
- package/src/cli/batch-inference.ts +0 -267
- package/src/cli/commands/batch-inference.ts +0 -116
- package/src/cli/commands/models.ts +0 -121
- package/src/cli/commands/training.ts +0 -275
- package/src/cli/models.ts +0 -304
- package/src/cli/trainings.ts +0 -880
package/src/importer.ts
CHANGED
|
@@ -28,6 +28,12 @@ type NodeEmission = {
|
|
|
28
28
|
readonly source: string;
|
|
29
29
|
};
|
|
30
30
|
type FieldReference = (id: string) => SourceReference;
|
|
31
|
+
type ImplicitFieldSource = {
|
|
32
|
+
readonly node: string;
|
|
33
|
+
readonly binding: string;
|
|
34
|
+
readonly directory: string;
|
|
35
|
+
readonly property: "annotatorId" | "qaAnnotatorId" | "annotatorIds";
|
|
36
|
+
};
|
|
31
37
|
|
|
32
38
|
const SOURCE_REFERENCE = Symbol("sourceReference");
|
|
33
39
|
const BLOCKED_BINDINGS: Record<string, true> = {
|
|
@@ -311,7 +317,21 @@ const withoutEmptyChecks = (
|
|
|
311
317
|
return kept.length === 0 ? undefined : Object.fromEntries(kept);
|
|
312
318
|
};
|
|
313
319
|
|
|
314
|
-
function
|
|
320
|
+
function expertFieldsSetting(
|
|
321
|
+
settingName: "allowedExperts" | "excludedExperts",
|
|
322
|
+
fieldIds: ReadonlyArray<string> | undefined,
|
|
323
|
+
expertFieldReference: FieldReference,
|
|
324
|
+
): Record<string, unknown> {
|
|
325
|
+
return fieldIds === undefined || fieldIds.length === 0
|
|
326
|
+
? {}
|
|
327
|
+
: { [settingName]: fieldIds.map(expertFieldReference) };
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function authoringSettings(
|
|
331
|
+
node: GraphNode,
|
|
332
|
+
fieldReference: FieldReference,
|
|
333
|
+
expertFieldReference: FieldReference,
|
|
334
|
+
): unknown {
|
|
315
335
|
switch (node.type) {
|
|
316
336
|
case "root": {
|
|
317
337
|
const {
|
|
@@ -346,11 +366,23 @@ function authoringSettings(node: GraphNode, fieldReference: FieldReference): unk
|
|
|
346
366
|
};
|
|
347
367
|
}
|
|
348
368
|
case "generation": {
|
|
349
|
-
const {
|
|
369
|
+
const {
|
|
370
|
+
entities,
|
|
371
|
+
qualityCriteria,
|
|
372
|
+
exam,
|
|
373
|
+
checks,
|
|
374
|
+
allowedExperts,
|
|
375
|
+
excludedExperts,
|
|
376
|
+
reuseAudienceWithNodeId: _reuseAudienceWithNodeId,
|
|
377
|
+
smartSearch: _smartSearch,
|
|
378
|
+
...settings
|
|
379
|
+
} = node.settings;
|
|
350
380
|
const authoredChecks = withoutEmptyChecks(checks);
|
|
351
381
|
return {
|
|
352
382
|
...settings,
|
|
353
383
|
...(authoredChecks === undefined ? {} : { checks: authoredChecks }),
|
|
384
|
+
...expertFieldsSetting("allowedExperts", allowedExperts, expertFieldReference),
|
|
385
|
+
...expertFieldsSetting("excludedExperts", excludedExperts, expertFieldReference),
|
|
354
386
|
entities: {
|
|
355
387
|
input: entities.input.map((entity) => transformEntity(entity, fieldReference)),
|
|
356
388
|
output: entities.output.map((entity) => transformEntity(entity, fieldReference)),
|
|
@@ -378,11 +410,21 @@ function authoringSettings(node: GraphNode, fieldReference: FieldReference): unk
|
|
|
378
410
|
};
|
|
379
411
|
}
|
|
380
412
|
case "quorum": {
|
|
381
|
-
const {
|
|
413
|
+
const {
|
|
414
|
+
entities,
|
|
415
|
+
qualityCriteria,
|
|
416
|
+
exam,
|
|
417
|
+
checks,
|
|
418
|
+
excludedExperts,
|
|
419
|
+
reuseAudienceWithNodeId: _reuseAudienceWithNodeId,
|
|
420
|
+
smartSearch: _smartSearch,
|
|
421
|
+
...settings
|
|
422
|
+
} = node.settings;
|
|
382
423
|
const authoredChecks = withoutEmptyChecks(checks);
|
|
383
424
|
return {
|
|
384
425
|
...settings,
|
|
385
426
|
...(authoredChecks === undefined ? {} : { checks: authoredChecks }),
|
|
427
|
+
...expertFieldsSetting("excludedExperts", excludedExperts, expertFieldReference),
|
|
386
428
|
entities: {
|
|
387
429
|
input: entities.input.map((entity) => transformEntity(entity, fieldReference)),
|
|
388
430
|
output: entities.output.map((entity) => transformEntity(entity, fieldReference)),
|
|
@@ -401,6 +443,7 @@ function nodeSource(
|
|
|
401
443
|
binding: string,
|
|
402
444
|
path: string,
|
|
403
445
|
fieldBindings: ReadonlyMap<string, string>,
|
|
446
|
+
implicitFields: ReadonlyMap<string, ImplicitFieldSource>,
|
|
404
447
|
): NodeEmission {
|
|
405
448
|
const referencedFields = new Set<string>();
|
|
406
449
|
const fieldReference = (id: string): SourceReference => {
|
|
@@ -409,13 +452,30 @@ function nodeSource(
|
|
|
409
452
|
referencedFields.add(referencedBinding);
|
|
410
453
|
return { name: referencedBinding, [SOURCE_REFERENCE]: true };
|
|
411
454
|
};
|
|
412
|
-
const
|
|
455
|
+
const referencedNodes = new Map<string, string>();
|
|
456
|
+
const expertFieldReference = (id: string): SourceReference => {
|
|
457
|
+
if (fieldBindings.has(id)) return fieldReference(id);
|
|
458
|
+
const source = implicitFields.get(id);
|
|
459
|
+
assert(source, `Node "${node.id}" takes experts from unknown field "${id}"`);
|
|
460
|
+
assert(source.node !== node.id, `Node "${node.id}" takes experts from its own field "${id}"`);
|
|
461
|
+
referencedNodes.set(source.binding, source.directory);
|
|
462
|
+
return { name: `${source.binding}.${source.property}`, [SOURCE_REFERENCE]: true };
|
|
463
|
+
};
|
|
464
|
+
const settings = authoringSettings(node, fieldReference, expertFieldReference);
|
|
413
465
|
const fieldImport = [...referencedFields].toSorted(compareText);
|
|
466
|
+
const nodeImports = [...referencedNodes]
|
|
467
|
+
.toSorted(([left], [right]) => compareText(left, right))
|
|
468
|
+
.map(
|
|
469
|
+
([referencedBinding, referencedDirectory]) =>
|
|
470
|
+
`import { ${referencedBinding} } from '../${referencedDirectory}/node';`,
|
|
471
|
+
);
|
|
414
472
|
const imports = [
|
|
415
473
|
`import { ${node.type} } from '@toloka-platform/sdk';`,
|
|
474
|
+
...(fieldImport.length === 0 && nodeImports.length === 0 ? [] : [""]),
|
|
416
475
|
...(fieldImport.length === 0
|
|
417
476
|
? []
|
|
418
|
-
: [
|
|
477
|
+
: [`import { ${fieldImport.join(", ")} } from '../../fields';`]),
|
|
478
|
+
...nodeImports,
|
|
419
479
|
];
|
|
420
480
|
const argumentsSource =
|
|
421
481
|
node.type === "root"
|
|
@@ -656,11 +716,33 @@ export function generatePipelineSourceTree(
|
|
|
656
716
|
return [node.id, binding];
|
|
657
717
|
}),
|
|
658
718
|
);
|
|
719
|
+
const implicitFields = new Map(
|
|
720
|
+
graph.nodes.flatMap((node): Array<[string, ImplicitFieldSource]> => {
|
|
721
|
+
const binding = nodeBindings.get(node.id);
|
|
722
|
+
const directory = directories.get(`node:${node.id}`);
|
|
723
|
+
assert(binding && directory, `Node "${node.id}" has no allocated source name`);
|
|
724
|
+
const source = (property: ImplicitFieldSource["property"]) => ({
|
|
725
|
+
node: node.id,
|
|
726
|
+
binding,
|
|
727
|
+
directory,
|
|
728
|
+
property,
|
|
729
|
+
});
|
|
730
|
+
if (node.type === "generation") {
|
|
731
|
+
return [
|
|
732
|
+
[`generation_sft_${node.id}_annotator_id`, source("annotatorId")],
|
|
733
|
+
[`generation_sft_${node.id}_qa_annotator_id`, source("qaAnnotatorId")],
|
|
734
|
+
];
|
|
735
|
+
}
|
|
736
|
+
return node.type === "quorum"
|
|
737
|
+
? [[`quorum_sft_${node.id}_annotator_ids`, source("annotatorIds")]]
|
|
738
|
+
: [];
|
|
739
|
+
}),
|
|
740
|
+
);
|
|
659
741
|
const nodeEmissions = graph.nodes.map((node) => {
|
|
660
742
|
const binding = nodeBindings.get(node.id);
|
|
661
743
|
const directory = directories.get(`node:${node.id}`);
|
|
662
744
|
assert(binding && directory, `Node "${node.id}" has no allocated source name`);
|
|
663
|
-
return nodeSource(node, binding, `nodes/${directory}/node.ts`, fieldBindings);
|
|
745
|
+
return nodeSource(node, binding, `nodes/${directory}/node.ts`, fieldBindings, implicitFields);
|
|
664
746
|
});
|
|
665
747
|
const entries = [
|
|
666
748
|
{
|
package/src/index.ts
CHANGED
|
@@ -38,8 +38,6 @@ export type {
|
|
|
38
38
|
RunSummary,
|
|
39
39
|
TerminalJob,
|
|
40
40
|
UploadId,
|
|
41
|
-
Training,
|
|
42
|
-
TrainingId,
|
|
43
41
|
UploadJob,
|
|
44
42
|
WaitForTarget,
|
|
45
43
|
} from "./client";
|
|
@@ -102,12 +100,14 @@ export type {
|
|
|
102
100
|
CodeAuthoringSettings,
|
|
103
101
|
Connection,
|
|
104
102
|
Field,
|
|
103
|
+
FieldRef,
|
|
105
104
|
GenerationAuthoringSettings,
|
|
106
105
|
InvalidJsonSchemaSource,
|
|
107
106
|
InputPort,
|
|
108
107
|
MatchAuthoringSettings,
|
|
109
108
|
OutputPort,
|
|
110
109
|
OptionalFieldBinding,
|
|
110
|
+
ImplicitField,
|
|
111
111
|
PipelineDefinition,
|
|
112
112
|
PipelineDefinitionBindings,
|
|
113
113
|
PipelineDefinitionInput,
|
|
@@ -2390,7 +2390,76 @@
|
|
|
2390
2390
|
],
|
|
2391
2391
|
"additionalProperties": false
|
|
2392
2392
|
},
|
|
2393
|
+
"allowedExperts": {
|
|
2394
|
+
"default": [],
|
|
2395
|
+
"description": "Ids of up to 20 fields at the node's input, each holding an expert id (string) or a list of expert ids (array of strings). Before each upload of an item's task, only the experts these fields name for the item can take it, and only those in the node's expert-list audience. An expert id is 1 to 128 letters, digits, `_`, `.`, `:` or `-`; a value that is not one fails the item, as does an item whose fields name no such expert or more than 100 of them. Experts outside the node's expert lists are skipped with a warning in the item trace. Requires per-item expert settings and expert lists for the team and an expert-list audience. `[]` lets any expert of the audience take the task.",
|
|
2396
|
+
"maxItems": 20,
|
|
2397
|
+
"type": "array",
|
|
2398
|
+
"items": {
|
|
2399
|
+
"type": "string"
|
|
2400
|
+
}
|
|
2401
|
+
},
|
|
2402
|
+
"excludedExperts": {
|
|
2403
|
+
"default": [],
|
|
2404
|
+
"description": "Ids of up to 20 fields at the node's input, each holding an expert id or a list of expert ids: a dataset field, or an upstream node's `generation_sft_<nodeId>_annotator_id`, `generation_sft_<nodeId>_qa_annotator_id` or `quorum_sft_<nodeId>_annotator_ids`. The experts they name for an item can't take its task, on top of the experts the platform already excludes. An expert id is 1 to 128 letters, digits, `_`, `.`, `:` or `-`; other values are skipped with a warning in the item trace; more than 100 ids fail the item. Requires per-item expert settings for the team. `[]` adds no exclusions.",
|
|
2405
|
+
"maxItems": 20,
|
|
2406
|
+
"type": "array",
|
|
2407
|
+
"items": {
|
|
2408
|
+
"type": "string"
|
|
2409
|
+
}
|
|
2410
|
+
},
|
|
2411
|
+
"checks": {
|
|
2412
|
+
"type": "object",
|
|
2413
|
+
"propertyNames": {
|
|
2414
|
+
"type": "string",
|
|
2415
|
+
"enum": [
|
|
2416
|
+
"ui",
|
|
2417
|
+
"llmqa",
|
|
2418
|
+
"annotation_qa",
|
|
2419
|
+
"qc_lint",
|
|
2420
|
+
"ui_types_lint",
|
|
2421
|
+
"exam_dataset",
|
|
2422
|
+
"synthgen"
|
|
2423
|
+
]
|
|
2424
|
+
},
|
|
2425
|
+
"additionalProperties": {
|
|
2426
|
+
"type": "array",
|
|
2427
|
+
"items": {
|
|
2428
|
+
"type": "object",
|
|
2429
|
+
"properties": {
|
|
2430
|
+
"id": {
|
|
2431
|
+
"type": "string"
|
|
2432
|
+
},
|
|
2433
|
+
"name": {
|
|
2434
|
+
"type": "string"
|
|
2435
|
+
},
|
|
2436
|
+
"input": {
|
|
2437
|
+
"anyOf": [
|
|
2438
|
+
{
|
|
2439
|
+
"type": "string"
|
|
2440
|
+
},
|
|
2441
|
+
{
|
|
2442
|
+
"type": "object",
|
|
2443
|
+
"propertyNames": {
|
|
2444
|
+
"type": "string"
|
|
2445
|
+
},
|
|
2446
|
+
"additionalProperties": {
|
|
2447
|
+
"type": "string"
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
]
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
"required": [
|
|
2454
|
+
"id",
|
|
2455
|
+
"name",
|
|
2456
|
+
"input"
|
|
2457
|
+
]
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
},
|
|
2393
2461
|
"reuseAudienceWithNodeId": {
|
|
2462
|
+
"deprecated": true,
|
|
2394
2463
|
"anyOf": [
|
|
2395
2464
|
{
|
|
2396
2465
|
"type": "object",
|
|
@@ -2415,7 +2484,7 @@
|
|
|
2415
2484
|
]
|
|
2416
2485
|
},
|
|
2417
2486
|
"smartSearch": {
|
|
2418
|
-
"
|
|
2487
|
+
"deprecated": true,
|
|
2419
2488
|
"anyOf": [
|
|
2420
2489
|
{
|
|
2421
2490
|
"type": "object",
|
|
@@ -2475,56 +2544,6 @@
|
|
|
2475
2544
|
"type": "null"
|
|
2476
2545
|
}
|
|
2477
2546
|
]
|
|
2478
|
-
},
|
|
2479
|
-
"checks": {
|
|
2480
|
-
"type": "object",
|
|
2481
|
-
"propertyNames": {
|
|
2482
|
-
"type": "string",
|
|
2483
|
-
"enum": [
|
|
2484
|
-
"ui",
|
|
2485
|
-
"llmqa",
|
|
2486
|
-
"annotation_qa",
|
|
2487
|
-
"qc_lint",
|
|
2488
|
-
"ui_types_lint",
|
|
2489
|
-
"exam_dataset",
|
|
2490
|
-
"synthgen"
|
|
2491
|
-
]
|
|
2492
|
-
},
|
|
2493
|
-
"additionalProperties": {
|
|
2494
|
-
"type": "array",
|
|
2495
|
-
"items": {
|
|
2496
|
-
"type": "object",
|
|
2497
|
-
"properties": {
|
|
2498
|
-
"id": {
|
|
2499
|
-
"type": "string"
|
|
2500
|
-
},
|
|
2501
|
-
"name": {
|
|
2502
|
-
"type": "string"
|
|
2503
|
-
},
|
|
2504
|
-
"input": {
|
|
2505
|
-
"anyOf": [
|
|
2506
|
-
{
|
|
2507
|
-
"type": "string"
|
|
2508
|
-
},
|
|
2509
|
-
{
|
|
2510
|
-
"type": "object",
|
|
2511
|
-
"propertyNames": {
|
|
2512
|
-
"type": "string"
|
|
2513
|
-
},
|
|
2514
|
-
"additionalProperties": {
|
|
2515
|
-
"type": "string"
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
]
|
|
2519
|
-
}
|
|
2520
|
-
},
|
|
2521
|
-
"required": [
|
|
2522
|
-
"id",
|
|
2523
|
-
"name",
|
|
2524
|
-
"input"
|
|
2525
|
-
]
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
2547
|
}
|
|
2529
2548
|
},
|
|
2530
2549
|
"required": [
|
|
@@ -4216,7 +4235,66 @@
|
|
|
4216
4235
|
],
|
|
4217
4236
|
"additionalProperties": false
|
|
4218
4237
|
},
|
|
4238
|
+
"excludedExperts": {
|
|
4239
|
+
"default": [],
|
|
4240
|
+
"description": "Ids of up to 20 fields at the node's input, each holding an expert id or a list of expert ids: a dataset field, or an upstream node's `generation_sft_<nodeId>_annotator_id`, `generation_sft_<nodeId>_qa_annotator_id` or `quorum_sft_<nodeId>_annotator_ids`. The experts they name for an item can't take its quorum tasks, on top of the experts the platform already excludes. An expert id is 1 to 128 letters, digits, `_`, `.`, `:` or `-`; other values are skipped with a warning in the item trace; more than 100 ids fail the item. Requires per-item expert settings for the team. `[]` adds no exclusions.",
|
|
4241
|
+
"maxItems": 20,
|
|
4242
|
+
"type": "array",
|
|
4243
|
+
"items": {
|
|
4244
|
+
"type": "string"
|
|
4245
|
+
}
|
|
4246
|
+
},
|
|
4247
|
+
"checks": {
|
|
4248
|
+
"type": "object",
|
|
4249
|
+
"propertyNames": {
|
|
4250
|
+
"type": "string",
|
|
4251
|
+
"enum": [
|
|
4252
|
+
"ui",
|
|
4253
|
+
"llmqa",
|
|
4254
|
+
"annotation_qa",
|
|
4255
|
+
"qc_lint",
|
|
4256
|
+
"ui_types_lint",
|
|
4257
|
+
"exam_dataset"
|
|
4258
|
+
]
|
|
4259
|
+
},
|
|
4260
|
+
"additionalProperties": {
|
|
4261
|
+
"type": "array",
|
|
4262
|
+
"items": {
|
|
4263
|
+
"type": "object",
|
|
4264
|
+
"properties": {
|
|
4265
|
+
"id": {
|
|
4266
|
+
"type": "string"
|
|
4267
|
+
},
|
|
4268
|
+
"name": {
|
|
4269
|
+
"type": "string"
|
|
4270
|
+
},
|
|
4271
|
+
"input": {
|
|
4272
|
+
"anyOf": [
|
|
4273
|
+
{
|
|
4274
|
+
"type": "string"
|
|
4275
|
+
},
|
|
4276
|
+
{
|
|
4277
|
+
"type": "object",
|
|
4278
|
+
"propertyNames": {
|
|
4279
|
+
"type": "string"
|
|
4280
|
+
},
|
|
4281
|
+
"additionalProperties": {
|
|
4282
|
+
"type": "string"
|
|
4283
|
+
}
|
|
4284
|
+
}
|
|
4285
|
+
]
|
|
4286
|
+
}
|
|
4287
|
+
},
|
|
4288
|
+
"required": [
|
|
4289
|
+
"id",
|
|
4290
|
+
"name",
|
|
4291
|
+
"input"
|
|
4292
|
+
]
|
|
4293
|
+
}
|
|
4294
|
+
}
|
|
4295
|
+
},
|
|
4219
4296
|
"reuseAudienceWithNodeId": {
|
|
4297
|
+
"deprecated": true,
|
|
4220
4298
|
"anyOf": [
|
|
4221
4299
|
{
|
|
4222
4300
|
"type": "object",
|
|
@@ -4241,7 +4319,7 @@
|
|
|
4241
4319
|
]
|
|
4242
4320
|
},
|
|
4243
4321
|
"smartSearch": {
|
|
4244
|
-
"
|
|
4322
|
+
"deprecated": true,
|
|
4245
4323
|
"anyOf": [
|
|
4246
4324
|
{
|
|
4247
4325
|
"type": "object",
|
|
@@ -4301,55 +4379,6 @@
|
|
|
4301
4379
|
"type": "null"
|
|
4302
4380
|
}
|
|
4303
4381
|
]
|
|
4304
|
-
},
|
|
4305
|
-
"checks": {
|
|
4306
|
-
"type": "object",
|
|
4307
|
-
"propertyNames": {
|
|
4308
|
-
"type": "string",
|
|
4309
|
-
"enum": [
|
|
4310
|
-
"ui",
|
|
4311
|
-
"llmqa",
|
|
4312
|
-
"annotation_qa",
|
|
4313
|
-
"qc_lint",
|
|
4314
|
-
"ui_types_lint",
|
|
4315
|
-
"exam_dataset"
|
|
4316
|
-
]
|
|
4317
|
-
},
|
|
4318
|
-
"additionalProperties": {
|
|
4319
|
-
"type": "array",
|
|
4320
|
-
"items": {
|
|
4321
|
-
"type": "object",
|
|
4322
|
-
"properties": {
|
|
4323
|
-
"id": {
|
|
4324
|
-
"type": "string"
|
|
4325
|
-
},
|
|
4326
|
-
"name": {
|
|
4327
|
-
"type": "string"
|
|
4328
|
-
},
|
|
4329
|
-
"input": {
|
|
4330
|
-
"anyOf": [
|
|
4331
|
-
{
|
|
4332
|
-
"type": "string"
|
|
4333
|
-
},
|
|
4334
|
-
{
|
|
4335
|
-
"type": "object",
|
|
4336
|
-
"propertyNames": {
|
|
4337
|
-
"type": "string"
|
|
4338
|
-
},
|
|
4339
|
-
"additionalProperties": {
|
|
4340
|
-
"type": "string"
|
|
4341
|
-
}
|
|
4342
|
-
}
|
|
4343
|
-
]
|
|
4344
|
-
}
|
|
4345
|
-
},
|
|
4346
|
-
"required": [
|
|
4347
|
-
"id",
|
|
4348
|
-
"name",
|
|
4349
|
-
"input"
|
|
4350
|
-
]
|
|
4351
|
-
}
|
|
4352
|
-
}
|
|
4353
4382
|
}
|
|
4354
4383
|
},
|
|
4355
4384
|
"required": [
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: toloka-fine-tuning
|
|
3
|
-
description: Create, estimate, start, monitor, and verify a project-owned supervised fine-tuning (SFT with LoRA adapters) Training through the Toloka CLI. Use when the user wants to adapt a base model or an existing LoRA Model Version from labeled conversations.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Fine-tune a model with Toloka
|
|
7
|
-
|
|
8
|
-
## Mission
|
|
9
|
-
|
|
10
|
-
Help the user adapt a compatible model from labeled conversations while preserving their intended task, data, model, and budget constraints. Match the work to the requested outcome: inspect an existing Training or run, prepare a draft, calculate an estimate, start an approved run, monitor it, or retrieve its output. Do not create resources or start a run merely because they appear later in this reference.
|
|
11
|
-
|
|
12
|
-
For first-time setup details, read `https://platform.toloka.ai/agents/fine-tuning.md`.
|
|
13
|
-
|
|
14
|
-
## Domain model
|
|
15
|
-
|
|
16
|
-
- **SFT** adapts model weights from representative chat examples. Each training row must follow the platform chat contract and end with the assistant response the model should learn to produce. Rows with tool calls also need `tools` declaring every function they call. Each call's `arguments` must be a string holding a JSON object (it is not checked against the function's `parameters`), call ids must be unique within a turn, and the `tool` replies must answer every call before the next turn. Cost estimation rejects rows that break these rules and names the first few in its error.
|
|
17
|
-
- A **Training** is an editable project-owned draft. A **Training Run** is one immutable, billable execution of a frozen draft and the rows of its slice.
|
|
18
|
-
- A run can start from a catalog **Base Model** or an exact existing **Model Version**. An explicit Model Version is the source; do not also select a Base Model.
|
|
19
|
-
- A completed run publishes a durable Model Version. It does not prove deployment or inference readiness.
|
|
20
|
-
- Training and validation are data roles, not file-layout rules. A **split column** puts each Dataset row in a part such as `train`, `validate` or `test`, and a **slice** freezes rows together with their split columns. A Training learns on a slice's rows in the train parts of one split column and validates on its validate parts, which may include a part that also tests. Without validation rows, the provider reserves 10% of the training rows as a holdout.
|
|
21
|
-
- A Training needs `--dataset <dataset>` or `--slice <id>`. `--dataset` fills the empty cells of the Dataset's split column (a new `split` column, 80/10/10, when it has none) and freezes a slice named after the Training; `--slice` takes a slice frozen with `toloka dataset slice create`, which must freeze a split column. Rows without a part are never trained on. Rows that any split column puts in a test part never reach training, nor validation unless they sit in a validate + test part of the Training's own split column; the cost estimate reports any train rows they remove as `Left out as test`. `toloka dataset split <dataset>` places only rows without a part, so after adding rows, run it again and take a new slice: no test row moves into training. `toloka dataset columns <dataset>` shows the split columns and their roles.
|
|
22
|
-
|
|
23
|
-
## Working posture
|
|
24
|
-
|
|
25
|
-
- Inspect the user's request and current CLI, project, Training, Dataset, and run state before changing anything. The process below is a dependency map: skip satisfied or irrelevant work and stop when the requested outcome is complete.
|
|
26
|
-
- Honor explicit choices first. If a requested project, source, Dataset, or configuration is incompatible, explain the evidence and tradeoff before proposing a substitute.
|
|
27
|
-
- Make routine reversible choices and briefly explain them. Ask a focused question only for material ambiguity, missing authorization or inputs, conflicting constraints, or destructive or out-of-scope changes.
|
|
28
|
-
- If the goal is prompt compression or data labeling rather than SFT, explain the distinction and route to `toloka-gisting` or `toloka-build`; never silently change the method.
|
|
29
|
-
|
|
30
|
-
## Safety
|
|
31
|
-
|
|
32
|
-
- Never ask for an API key in chat; the user enters it through `toloka login`.
|
|
33
|
-
- Never invent project, Dataset, Base Model, Training, Model, Model Version, price, or run IDs. Read identity and source metadata from the CLI.
|
|
34
|
-
- Use only authorized project Datasets containing representative data. Keep credentials and production data out of source control and agent messages.
|
|
35
|
-
- Preserve train/validation separation and avoid duplicate or near-duplicate examples across roles.
|
|
36
|
-
- Never start a Training Run before the user approves the ready estimate's exact `maximumCharge`.
|
|
37
|
-
- Keep polling bounded. Report terminal state only when the CLI shows it, and report timeouts as still running.
|
|
38
|
-
|
|
39
|
-
## Process
|
|
40
|
-
|
|
41
|
-
### 1. Establish only the context the goal needs
|
|
42
|
-
|
|
43
|
-
When the CLI, authentication, or binding is unknown, inspect it. The runtime-inclusive standalone CLI is sufficient for Training-only work; no separate Bun or Node.js installation, SDK, TypeScript, or test packages are needed:
|
|
44
|
-
|
|
45
|
-
```sh
|
|
46
|
-
toloka --version
|
|
47
|
-
toloka whoami
|
|
48
|
-
toloka project current
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Reuse an authenticated, compatible workspace. For an inspection request, inspect existing resources rather than creating a project, Dataset, Training, or run.
|
|
52
|
-
|
|
53
|
-
Use the project the user explicitly requested. Otherwise keep the current binding when it is consistent with the task. If no suitable project is bound and the requested work needs one, inspect `toloka project list --limit 20`, then create a task-named project or register the exact existing project the user identified. Do not silently select an unrelated project or rebind an existing checkout; use an explicit `--project-id` or a separate source root when working against another project without changing the binding.
|
|
54
|
-
|
|
55
|
-
### 2. Inspect and assign data roles
|
|
56
|
-
|
|
57
|
-
```sh
|
|
58
|
-
toloka dataset list
|
|
59
|
-
toloka dataset fields <dataset-name-or-id>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Use the user's authorized data and existing role assignments. If local JSONL files must be uploaded, put them in one Dataset for the task; `dataset upload` appends, and a split column records each row's role:
|
|
63
|
-
|
|
64
|
-
```sh
|
|
65
|
-
toloka dataset create <dataset-name>
|
|
66
|
-
toloka dataset upload <dataset-name> <absolute-jsonl-path>
|
|
67
|
-
toloka dataset fields <dataset-name>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
When the user supplied separate training and validation files, give each file its role before uploading the next one: `toloka dataset split <dataset-name> --parts train:100 --json` after the training file, then `toloka dataset split <dataset-name> --parts validate:100 --json` after the validation file. Each fill places only rows without a part, so a supplied validation set never mixes into training; pass `--parts` on every such fill, because a fill without it repeats the column's last shares. For one undivided file, let the split sample it: `toloka dataset split <dataset-name> --ratios 80/10/10 [--balance-by <label-field>] --json`, or leave it to `training create --dataset`, which splits 80/10/10.
|
|
71
|
-
|
|
72
|
-
CLI uploads to an otherwise undeclared Dataset store each row whole in its `uploaded` field, so the rows' own fields are not dataset fields yet. `toloka dataset fields add <dataset> <field>…` adds top-level fields of the uploaded rows as dataset fields, for filters and `--balance-by`, and copies their values from every upload. When the rows carry their own role, such as a Hugging Face `split` field, add it, then adopt it: `toloka dataset fields add <dataset> split`, then `toloka dataset split <dataset> --column split`. Roles follow the values `train`, `validation`/`validate`/`val`/`dev` and `test`, and `--parts train,dev=validate,test` maps other names. `dataset split` and `training create --dataset` refuse a split column name that is a field of the uploaded rows but not a dataset field, and print the `fields add` command.
|
|
73
|
-
|
|
74
|
-
To train on a subset or reuse rows across Trainings, freeze a slice once every upload and split has finished; `--filter <field>=<value>` keeps only matching rows, and split columns are always frozen:
|
|
75
|
-
|
|
76
|
-
```sh
|
|
77
|
-
toloka dataset slice create <dataset-name> --name "<slice-name>" --json
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### 3. Choose and verify the source
|
|
81
|
-
|
|
82
|
-
Explicit source choices take precedence. An existing Model Version bypasses Base Model selection.
|
|
83
|
-
|
|
84
|
-
```sh
|
|
85
|
-
toloka base-model list --json
|
|
86
|
-
toloka base-model get <base-model-id> --json
|
|
87
|
-
toloka model list --json
|
|
88
|
-
toloka model get <model-id> --json
|
|
89
|
-
toloka model versions <model-id> --json
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
For a Base Model, compare upstream documentation, user-provided benchmarks, and prior results for task and language fit, data volume, quality, training budget, and serving latency or deployment constraints. Model size alone is not a quality decision; a smaller model is a useful cost and latency baseline when the task permits it, not a mandatory default. Use `base-model get` only to verify the selected catalog ID, upstream model, and pinned revision; it does not establish those broader capabilities.
|
|
93
|
-
|
|
94
|
-
For a Model Version, verify the exact ID and revision under its project-owned Model, and record the owning Model's Base Model and the Version's runtime base from JSON. If those identities conflict, report the conflict rather than guessing or substituting. Use `--model-version` only for that existing version, and only for a LoRA adapter Model Version (one produced by fine-tuning) — a full-weights version is rejected with "Training from a Model Version requires a LoRA adapter source". The ready cost estimate is the concrete final check that the source type, underlying Base Model, method, and data are supported together.
|
|
95
|
-
|
|
96
|
-
### 4. Reuse or create the draft
|
|
97
|
-
|
|
98
|
-
Inspect before creating another Training:
|
|
99
|
-
|
|
100
|
-
```sh
|
|
101
|
-
toloka training list --json
|
|
102
|
-
toloka training get <training-id> --json
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
When a new draft is needed, use a descriptive name and create normalized SFT configuration:
|
|
106
|
-
|
|
107
|
-
```sh
|
|
108
|
-
toloka training create "<training-name>" \
|
|
109
|
-
--base-model <base-model-id> \
|
|
110
|
-
--dataset <dataset-name-or-id> \
|
|
111
|
-
--json
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
`--dataset` fills the empty cells of the Dataset's split column, freezes a slice named after the Training, and prints a line for each step; pass `--split-column <name>` when the Dataset has several split columns. To train on a slice frozen earlier, pass `--slice <slice-id>` instead. The Training learns on the column's train parts, or the ones `--parts <names>` lists, and validates on its validate parts; without validate rows, the platform holds out 10% of training rows for evaluation.
|
|
115
|
-
|
|
116
|
-
To continue from a Model Version, replace `--base-model` with `--model-version <model-version-id>`.
|
|
117
|
-
|
|
118
|
-
Preserve requested hyperparameters. The current CLI uses `--lora-rank 8|16|32` (default 16), `--epochs 1..5` (default 3), `--learning-rate` within 0.00001–0.001 (default 0.00015), `--batch-size 8|16|32|64` (default 8), and `--max-sequence-length 64..16384` (default 12288), rather than `regime`. Use defaults when suitable; rank 8 can fit narrow tasks or small data, while 32 may help when 16 underfits and the data supports more capacity. Choose sequence length from actual examples within the supported limit. `--gist-tokens` is rejected for SFT. `training update <name-or-id>` takes the same flags except `--method`; omitted flags retain current values. A new `--slice` or `--dataset` resets `--split-column` and `--parts` unless you pass them again.
|
|
119
|
-
|
|
120
|
-
Verify the saved method, exact source, slice, split column, train parts, and configuration with `toloka training get <training-id> --json`.
|
|
121
|
-
|
|
122
|
-
### 5. Validate and estimate
|
|
123
|
-
|
|
124
|
-
```sh
|
|
125
|
-
toloka training cost <training-id> --json > <absolute-estimate-file>
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
A blocked estimate exits 1, leaves the redirected file empty, and prints `Training cannot run with these inputs:` followed by one `- <message>` line per issue on stderr. Report every issue, correct the cause, and calculate a new estimate.
|
|
129
|
-
|
|
130
|
-
For a duration issue, use the reported rows, tokens, epochs, GPU count, and wall time to compare supported options. `qwen3-32b` and `qwen3-235b` use 8 GPUs and can reduce wall time, but changing the model also changes quality, serving constraints, and cost; reducing rows can weaken coverage; reducing epochs can weaken adaptation. Do not change the requested model, silently discard data, or alter epochs merely to make the estimate pass. Present the tradeoff, obtain direction when it is material, then update the draft, re-estimate, and obtain approval for the new quote.
|
|
131
|
-
|
|
132
|
-
For a ready estimate, report the source, slice and split column, training and validation row counts, any rows left out as test, token totals, maximum GPU seconds, `maximumCharge`, currency, and fingerprint. If the user asked only for an estimate, stop here.
|
|
133
|
-
|
|
134
|
-
### 6. Run only after explicit cost approval
|
|
135
|
-
|
|
136
|
-
Ask the user to approve the exact ready `maximumCharge`. After approval, start only the requested run and pass the approved file so a new unseen quote cannot replace it:
|
|
137
|
-
|
|
138
|
-
```sh
|
|
139
|
-
toloka training run <training-id> \
|
|
140
|
-
--estimate-file <absolute-estimate-file> \
|
|
141
|
-
--version-name <unique-version-name> \
|
|
142
|
-
--json
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Both flags are optional at the CLI level. Without `--estimate-file`, `training run` calculates a fresh ready estimate; do not use that path when the user approved a saved quote. Without `--version-name`, the Model Version takes the Training name.
|
|
146
|
-
|
|
147
|
-
Monitor only as far as the user requested, with bounded commands:
|
|
148
|
-
|
|
149
|
-
```sh
|
|
150
|
-
toloka training status <training-run-id> --json
|
|
151
|
-
toloka training logs <training-run-id>
|
|
152
|
-
toloka training metrics <training-run-id> --json
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Metrics can appear while the run is `running` and stop updating when training ends, before the run reaches `completed`. When `available: false`, check `unavailableReason`:
|
|
156
|
-
|
|
157
|
-
- `unresolved`: metrics are not available yet. Check again while the run is `running`.
|
|
158
|
-
- `not_configured`: this run will not report metrics. Stop polling for them.
|
|
159
|
-
|
|
160
|
-
Control and billing rules:
|
|
161
|
-
|
|
162
|
-
- Resume only after the user confirms a billing block is resolved.
|
|
163
|
-
- `payment_window_expired` is final: the run is `failed`, cannot resume, and was not charged, even though `billingStatus` remains `payment_required`. A replacement run needs funds and new cost approval.
|
|
164
|
-
- Cancel only on explicit request, before output checks begin. Before training starts, cancellation is free. During training, it stops the GPU job and charges for GPU seconds used, with no Model Version. A startup cancellation may remain `stopping` until the job stops; wait rather than retrying cancel.
|
|
165
|
-
- `provider_failed` and `provider_timeout` are platform failures: no charge, full hold returned. Reported GPU usage remains visible.
|
|
166
|
-
- A `failed` or `canceled` run frees its estimate: the same estimate file can start one new run at the same `maximumCharge` until the estimate expires. Retry only an error with `retryable: true` (network, storage, or GPU capacity), and only after the user agrees.
|
|
167
|
-
|
|
168
|
-
Do not duplicate a slow run. Progress `queued` or `pending` means it is waiting for GPUs; training starts automatically. Training may also exceed the estimated duration. The charge stays capped at the approved `maximumCharge`; successful runs still publish a Model Version.
|
|
169
|
-
|
|
170
|
-
For a completed run, verify the observed output and download only when requested:
|
|
171
|
-
|
|
172
|
-
```sh
|
|
173
|
-
toloka training get <training-id> --json
|
|
174
|
-
toloka model get <model-id> --json
|
|
175
|
-
toloka model versions <model-id> --json
|
|
176
|
-
toloka model version download <model-version-id> --out <absolute-output-directory>
|
|
177
|
-
```
|