model-train-protocol-schemas 1.0.0__py3-none-any.whl
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.
- model_train_protocol_schemas/__init__.py +0 -0
- model_train_protocol_schemas/constants.py +13 -0
- model_train_protocol_schemas/schema_version.py +1 -0
- model_train_protocol_schemas/schemas/__init__.py +37 -0
- model_train_protocol_schemas/schemas/bloom/v0/bloom_0_3_0.json +459 -0
- model_train_protocol_schemas/schemas/bloom/v0/bloom_0_3_1.json +460 -0
- model_train_protocol_schemas/schemas/bloom/v0/bloom_0_3_2.json +489 -0
- model_train_protocol_schemas/schemas/bloom/v0/bloom_0_3_3.json +489 -0
- model_train_protocol_schemas/schemas/bloom/v0/bloom_0_4_0.json +489 -0
- model_train_protocol_schemas/schemas/bloom/v1/bloom_1_0_0.json +487 -0
- model_train_protocol_schemas/schemas/bloom/v1/bloom_1_1_0.json +424 -0
- model_train_protocol_schemas/schemas/bloom/v1/bloom_1_2_0.json +429 -0
- model_train_protocol_schemas/schemas/template/v0/template_0_3_0.json +121 -0
- model_train_protocol_schemas/schemas/template/v0/template_0_3_1.json +122 -0
- model_train_protocol_schemas/schemas/template/v0/template_0_3_2.json +117 -0
- model_train_protocol_schemas/schemas/template/v0/template_0_3_3.json +122 -0
- model_train_protocol_schemas/schemas/template/v0/template_0_4_0.json +122 -0
- model_train_protocol_schemas/schemas/template/v1/template_1_0_0.json +122 -0
- model_train_protocol_schemas/schemas/template/v1/template_1_1_0.json +122 -0
- model_train_protocol_schemas/schemas/template/v1/template_1_2_0.json +136 -0
- model_train_protocol_schemas/scripts/__init__.py +0 -0
- model_train_protocol_schemas/scripts/generate_protocol_schema.py +37 -0
- model_train_protocol_schemas/scripts/generate_template_schema.py +40 -0
- model_train_protocol_schemas/structures/__init__.py +0 -0
- model_train_protocol_schemas/structures/protocol.py +121 -0
- model_train_protocol_schemas/structures/template.py +47 -0
- model_train_protocol_schemas/template_version.py +1 -0
- model_train_protocol_schemas/utils.py +72 -0
- model_train_protocol_schemas-1.0.0.dist-info/METADATA +19 -0
- model_train_protocol_schemas-1.0.0.dist-info/RECORD +31 -0
- model_train_protocol_schemas-1.0.0.dist-info/WHEEL +4 -0
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
MINIMUM_TOTAL_CONTEXT_LINES = 10
|
|
2
|
+
MAXIMUM_CHARACTERS_PER_MODEL_CONTEXT_LINE = 300
|
|
3
|
+
PER_FINAL_TOKEN_SAMPLE_MINIMUM = 3
|
|
4
|
+
|
|
5
|
+
MAXIMUM_CONTEXT_LINES_PER_INSTRUCTION: int = 100_000 # Arbitrary large number to allow as many context lines as needed
|
|
6
|
+
MAXIMUM_CHARACTERS_PER_INSTRUCTION_CONTEXT_LINE: int = 300
|
|
7
|
+
|
|
8
|
+
MAXIMUM_CHARACTERS_PER_SNIPPET: int = 300
|
|
9
|
+
|
|
10
|
+
GENERAL_MINIMUM_INSTRUCTION_SAMPLES: int = 3
|
|
11
|
+
STATE_MACHINE_MINIMUM_INSTRUCTION_SAMPLES: int = 10
|
|
12
|
+
|
|
13
|
+
MIN_SAMPLES_PER_GUARDRAIL: int = 3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
SCHEMA_VERSION: str = "1.2.0"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Packaged JSON schemas for Model Train Protocol."""
|
|
2
|
+
|
|
3
|
+
from importlib import resources
|
|
4
|
+
from importlib.resources.abc import Traversable
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
SCHEMA_PROTOCOL: str = "bloom_schema.json"
|
|
9
|
+
SCHEMA_TEMPLATE: str = "template_schema.json"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def list_schema_versions() -> list[str]:
|
|
13
|
+
"""Return available schema versions bundled with the package."""
|
|
14
|
+
base = resources.files(__package__)
|
|
15
|
+
return sorted([entry.name for entry in base.iterdir() if entry.is_dir() and not entry.name.startswith("_")])
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_schema_resource(version: str, name: str) -> Traversable:
|
|
19
|
+
"""Return a schema resource for the given version and filename."""
|
|
20
|
+
resource = resources.files(__package__) / version / name
|
|
21
|
+
if not resource.is_file():
|
|
22
|
+
raise FileNotFoundError(f"Schema not found: {version}/{name}")
|
|
23
|
+
return resource
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def read_schema_text(version: str, name: str) -> str:
|
|
27
|
+
"""Read a schema as raw JSON text."""
|
|
28
|
+
resource = get_schema_resource(version=version, name=name)
|
|
29
|
+
return resource.read_text(encoding="utf-8")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def load_schema(version: str, name: str) -> dict[str, Any]:
|
|
33
|
+
"""Load a schema as a JSON object."""
|
|
34
|
+
resource = get_schema_resource(version=version, name=name)
|
|
35
|
+
with resource.open("r", encoding="utf-8") as handle:
|
|
36
|
+
return json.load(handle)
|
|
37
|
+
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "ProtocolModel",
|
|
4
|
+
"description": "Main model for MTP Protocol JSON structure.",
|
|
5
|
+
"$defs": {
|
|
6
|
+
"BatchModel": {
|
|
7
|
+
"description": "Model for batches configuration.",
|
|
8
|
+
"properties": {
|
|
9
|
+
"pretrain": {
|
|
10
|
+
"items": {
|
|
11
|
+
"additionalProperties": true,
|
|
12
|
+
"type": "object"
|
|
13
|
+
},
|
|
14
|
+
"title": "Pretrain",
|
|
15
|
+
"type": "array"
|
|
16
|
+
},
|
|
17
|
+
"instruct": {
|
|
18
|
+
"items": {
|
|
19
|
+
"additionalProperties": true,
|
|
20
|
+
"type": "object"
|
|
21
|
+
},
|
|
22
|
+
"title": "Instruct",
|
|
23
|
+
"type": "array"
|
|
24
|
+
},
|
|
25
|
+
"judge": {
|
|
26
|
+
"items": {
|
|
27
|
+
"additionalProperties": true,
|
|
28
|
+
"type": "object"
|
|
29
|
+
},
|
|
30
|
+
"title": "Judge",
|
|
31
|
+
"type": "array"
|
|
32
|
+
},
|
|
33
|
+
"ppo": {
|
|
34
|
+
"items": {
|
|
35
|
+
"additionalProperties": true,
|
|
36
|
+
"type": "object"
|
|
37
|
+
},
|
|
38
|
+
"title": "Ppo",
|
|
39
|
+
"type": "array"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"required": [
|
|
43
|
+
"pretrain",
|
|
44
|
+
"instruct",
|
|
45
|
+
"judge",
|
|
46
|
+
"ppo"
|
|
47
|
+
],
|
|
48
|
+
"title": "BatchModel",
|
|
49
|
+
"type": "object"
|
|
50
|
+
},
|
|
51
|
+
"GuardrailModel": {
|
|
52
|
+
"description": "Model for guardrails configuration.",
|
|
53
|
+
"properties": {
|
|
54
|
+
"index": {
|
|
55
|
+
"title": "Index",
|
|
56
|
+
"type": "integer"
|
|
57
|
+
},
|
|
58
|
+
"good_prompt": {
|
|
59
|
+
"title": "Good Prompt",
|
|
60
|
+
"type": "string"
|
|
61
|
+
},
|
|
62
|
+
"bad_prompt": {
|
|
63
|
+
"title": "Bad Prompt",
|
|
64
|
+
"type": "string"
|
|
65
|
+
},
|
|
66
|
+
"bad_output": {
|
|
67
|
+
"title": "Bad Output",
|
|
68
|
+
"type": "string"
|
|
69
|
+
},
|
|
70
|
+
"bad_examples": {
|
|
71
|
+
"items": {
|
|
72
|
+
"type": "string"
|
|
73
|
+
},
|
|
74
|
+
"title": "Bad Examples",
|
|
75
|
+
"type": "array"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"required": [
|
|
79
|
+
"index",
|
|
80
|
+
"good_prompt",
|
|
81
|
+
"bad_prompt",
|
|
82
|
+
"bad_output",
|
|
83
|
+
"bad_examples"
|
|
84
|
+
],
|
|
85
|
+
"title": "GuardrailModel",
|
|
86
|
+
"type": "object"
|
|
87
|
+
},
|
|
88
|
+
"InstructionModel": {
|
|
89
|
+
"description": "Model for instruction configuration.",
|
|
90
|
+
"properties": {
|
|
91
|
+
"memory": {
|
|
92
|
+
"title": "Memory",
|
|
93
|
+
"type": "integer"
|
|
94
|
+
},
|
|
95
|
+
"sets": {
|
|
96
|
+
"items": {
|
|
97
|
+
"$ref": "#/$defs/InstructionSetModel"
|
|
98
|
+
},
|
|
99
|
+
"title": "Sets",
|
|
100
|
+
"type": "array"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"required": [
|
|
104
|
+
"memory",
|
|
105
|
+
"sets"
|
|
106
|
+
],
|
|
107
|
+
"title": "InstructionModel",
|
|
108
|
+
"type": "object"
|
|
109
|
+
},
|
|
110
|
+
"InstructionSetModel": {
|
|
111
|
+
"description": "Model for instruction sets.",
|
|
112
|
+
"properties": {
|
|
113
|
+
"guardrails": {
|
|
114
|
+
"items": {
|
|
115
|
+
"$ref": "#/$defs/GuardrailModel"
|
|
116
|
+
},
|
|
117
|
+
"title": "Guardrails",
|
|
118
|
+
"type": "array"
|
|
119
|
+
},
|
|
120
|
+
"context": {
|
|
121
|
+
"items": {
|
|
122
|
+
"type": "string"
|
|
123
|
+
},
|
|
124
|
+
"title": "Context",
|
|
125
|
+
"type": "array"
|
|
126
|
+
},
|
|
127
|
+
"set": {
|
|
128
|
+
"items": {
|
|
129
|
+
"items": {
|
|
130
|
+
"type": "string"
|
|
131
|
+
},
|
|
132
|
+
"type": "array"
|
|
133
|
+
},
|
|
134
|
+
"title": "Set",
|
|
135
|
+
"type": "array"
|
|
136
|
+
},
|
|
137
|
+
"samples": {
|
|
138
|
+
"items": {
|
|
139
|
+
"$ref": "#/$defs/SampleModel"
|
|
140
|
+
},
|
|
141
|
+
"title": "Samples",
|
|
142
|
+
"type": "array"
|
|
143
|
+
},
|
|
144
|
+
"ppo": {
|
|
145
|
+
"items": {
|
|
146
|
+
"additionalProperties": true,
|
|
147
|
+
"type": "object"
|
|
148
|
+
},
|
|
149
|
+
"title": "Ppo",
|
|
150
|
+
"type": "array"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"required": [
|
|
154
|
+
"guardrails",
|
|
155
|
+
"context",
|
|
156
|
+
"set",
|
|
157
|
+
"samples",
|
|
158
|
+
"ppo"
|
|
159
|
+
],
|
|
160
|
+
"title": "InstructionSetModel",
|
|
161
|
+
"type": "object"
|
|
162
|
+
},
|
|
163
|
+
"NumberModel": {
|
|
164
|
+
"additionalProperties": {
|
|
165
|
+
"description": "Number rule value (must be a string)",
|
|
166
|
+
"type": "string"
|
|
167
|
+
},
|
|
168
|
+
"description": "Model for numbers configuration.",
|
|
169
|
+
"properties": {},
|
|
170
|
+
"title": "NumberModel",
|
|
171
|
+
"type": "object"
|
|
172
|
+
},
|
|
173
|
+
"SampleModel": {
|
|
174
|
+
"description": "Model for instruction samples.",
|
|
175
|
+
"properties": {
|
|
176
|
+
"strings": {
|
|
177
|
+
"items": {
|
|
178
|
+
"type": "string"
|
|
179
|
+
},
|
|
180
|
+
"title": "Strings",
|
|
181
|
+
"type": "array"
|
|
182
|
+
},
|
|
183
|
+
"prompt": {
|
|
184
|
+
"anyOf": [
|
|
185
|
+
{
|
|
186
|
+
"type": "string"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"type": "null"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"title": "Prompt"
|
|
193
|
+
},
|
|
194
|
+
"numbers": {
|
|
195
|
+
"anyOf": [
|
|
196
|
+
{
|
|
197
|
+
"type": "integer"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"items": {
|
|
201
|
+
"type": "integer"
|
|
202
|
+
},
|
|
203
|
+
"type": "array"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"items": {
|
|
207
|
+
"items": {
|
|
208
|
+
"type": "integer"
|
|
209
|
+
},
|
|
210
|
+
"type": "array"
|
|
211
|
+
},
|
|
212
|
+
"type": "array"
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
"title": "Numbers"
|
|
216
|
+
},
|
|
217
|
+
"number_lists": {
|
|
218
|
+
"anyOf": [
|
|
219
|
+
{
|
|
220
|
+
"type": "integer"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"items": {
|
|
224
|
+
"type": "integer"
|
|
225
|
+
},
|
|
226
|
+
"type": "array"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"items": {
|
|
230
|
+
"items": {
|
|
231
|
+
"type": "integer"
|
|
232
|
+
},
|
|
233
|
+
"type": "array"
|
|
234
|
+
},
|
|
235
|
+
"type": "array"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"items": {
|
|
239
|
+
"items": {
|
|
240
|
+
"items": {
|
|
241
|
+
"type": "integer"
|
|
242
|
+
},
|
|
243
|
+
"type": "array"
|
|
244
|
+
},
|
|
245
|
+
"type": "array"
|
|
246
|
+
},
|
|
247
|
+
"type": "array"
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
"title": "Number Lists"
|
|
251
|
+
},
|
|
252
|
+
"result": {
|
|
253
|
+
"title": "Result",
|
|
254
|
+
"type": "string"
|
|
255
|
+
},
|
|
256
|
+
"value": {
|
|
257
|
+
"anyOf": [
|
|
258
|
+
{
|
|
259
|
+
"type": "string"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"type": "integer"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"type": "number"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"items": {
|
|
269
|
+
"type": "integer"
|
|
270
|
+
},
|
|
271
|
+
"type": "array"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"items": {
|
|
275
|
+
"type": "number"
|
|
276
|
+
},
|
|
277
|
+
"type": "array"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"type": "null"
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
"title": "Value"
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"required": [
|
|
287
|
+
"strings",
|
|
288
|
+
"prompt",
|
|
289
|
+
"numbers",
|
|
290
|
+
"number_lists",
|
|
291
|
+
"result",
|
|
292
|
+
"value"
|
|
293
|
+
],
|
|
294
|
+
"title": "SampleModel",
|
|
295
|
+
"type": "object"
|
|
296
|
+
},
|
|
297
|
+
"TokenInfoModel": {
|
|
298
|
+
"description": "Model for individual token information.",
|
|
299
|
+
"properties": {
|
|
300
|
+
"key": {
|
|
301
|
+
"title": "Key",
|
|
302
|
+
"type": "string"
|
|
303
|
+
},
|
|
304
|
+
"num": {
|
|
305
|
+
"title": "Num",
|
|
306
|
+
"type": "boolean"
|
|
307
|
+
},
|
|
308
|
+
"num_list": {
|
|
309
|
+
"title": "Num List",
|
|
310
|
+
"type": "integer"
|
|
311
|
+
},
|
|
312
|
+
"min_value": {
|
|
313
|
+
"anyOf": [
|
|
314
|
+
{
|
|
315
|
+
"type": "integer"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"type": "number"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"type": "null"
|
|
322
|
+
}
|
|
323
|
+
],
|
|
324
|
+
"title": "Min Value"
|
|
325
|
+
},
|
|
326
|
+
"max_value": {
|
|
327
|
+
"anyOf": [
|
|
328
|
+
{
|
|
329
|
+
"type": "integer"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"type": "number"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"type": "null"
|
|
336
|
+
}
|
|
337
|
+
],
|
|
338
|
+
"title": "Max Value"
|
|
339
|
+
},
|
|
340
|
+
"length": {
|
|
341
|
+
"anyOf": [
|
|
342
|
+
{
|
|
343
|
+
"type": "integer"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"type": "null"
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
"title": "Length"
|
|
350
|
+
},
|
|
351
|
+
"desc": {
|
|
352
|
+
"anyOf": [
|
|
353
|
+
{
|
|
354
|
+
"type": "string"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"type": "null"
|
|
358
|
+
}
|
|
359
|
+
],
|
|
360
|
+
"title": "Desc"
|
|
361
|
+
},
|
|
362
|
+
"special": {
|
|
363
|
+
"anyOf": [
|
|
364
|
+
{
|
|
365
|
+
"type": "string"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"type": "null"
|
|
369
|
+
}
|
|
370
|
+
],
|
|
371
|
+
"title": "Special"
|
|
372
|
+
},
|
|
373
|
+
"type": {
|
|
374
|
+
"title": "Type",
|
|
375
|
+
"type": "string"
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
"required": [
|
|
379
|
+
"key",
|
|
380
|
+
"num",
|
|
381
|
+
"num_list",
|
|
382
|
+
"min_value",
|
|
383
|
+
"max_value",
|
|
384
|
+
"length",
|
|
385
|
+
"desc",
|
|
386
|
+
"special",
|
|
387
|
+
"type"
|
|
388
|
+
],
|
|
389
|
+
"title": "TokenInfoModel",
|
|
390
|
+
"type": "object"
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
"properties": {
|
|
394
|
+
"version": {
|
|
395
|
+
"title": "Version",
|
|
396
|
+
"type": "string"
|
|
397
|
+
},
|
|
398
|
+
"name": {
|
|
399
|
+
"title": "Name",
|
|
400
|
+
"type": "string"
|
|
401
|
+
},
|
|
402
|
+
"inputs": {
|
|
403
|
+
"title": "Inputs",
|
|
404
|
+
"type": "integer"
|
|
405
|
+
},
|
|
406
|
+
"encrypted": {
|
|
407
|
+
"title": "Encrypted",
|
|
408
|
+
"type": "boolean"
|
|
409
|
+
},
|
|
410
|
+
"valid": {
|
|
411
|
+
"title": "Valid",
|
|
412
|
+
"type": "boolean"
|
|
413
|
+
},
|
|
414
|
+
"context": {
|
|
415
|
+
"items": {
|
|
416
|
+
"type": "string"
|
|
417
|
+
},
|
|
418
|
+
"title": "Context",
|
|
419
|
+
"type": "array"
|
|
420
|
+
},
|
|
421
|
+
"tokens": {
|
|
422
|
+
"additionalProperties": {
|
|
423
|
+
"$ref": "#/$defs/TokenInfoModel"
|
|
424
|
+
},
|
|
425
|
+
"title": "Tokens",
|
|
426
|
+
"type": "object"
|
|
427
|
+
},
|
|
428
|
+
"special_tokens": {
|
|
429
|
+
"items": {
|
|
430
|
+
"type": "string"
|
|
431
|
+
},
|
|
432
|
+
"title": "Special Tokens",
|
|
433
|
+
"type": "array"
|
|
434
|
+
},
|
|
435
|
+
"instruction": {
|
|
436
|
+
"$ref": "#/$defs/InstructionModel"
|
|
437
|
+
},
|
|
438
|
+
"numbers": {
|
|
439
|
+
"$ref": "#/$defs/NumberModel"
|
|
440
|
+
},
|
|
441
|
+
"batches": {
|
|
442
|
+
"$ref": "#/$defs/BatchModel"
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
"required": [
|
|
446
|
+
"version",
|
|
447
|
+
"name",
|
|
448
|
+
"inputs",
|
|
449
|
+
"encrypted",
|
|
450
|
+
"valid",
|
|
451
|
+
"context",
|
|
452
|
+
"tokens",
|
|
453
|
+
"special_tokens",
|
|
454
|
+
"instruction",
|
|
455
|
+
"numbers",
|
|
456
|
+
"batches"
|
|
457
|
+
],
|
|
458
|
+
"type": "object"
|
|
459
|
+
}
|