-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathoptimizer_config.schema.json
More file actions
591 lines (591 loc) · 22.4 KB
/
optimizer_config.schema.json
File metadata and controls
591 lines (591 loc) · 22.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
{
"$defs": {
"CrossEncoderConfig": {
"additionalProperties": false,
"properties": {
"model_name": {
"default": "cross-encoder/ms-marco-MiniLM-L6-v2",
"description": "Name of the hugging face model.",
"title": "Model Name",
"type": "string"
},
"batch_size": {
"default": 32,
"description": "Batch size for model inference.",
"exclusiveMinimum": 0,
"title": "Batch Size",
"type": "integer"
},
"device": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Torch notation for CPU or CUDA.",
"title": "Device"
},
"bf16": {
"default": false,
"description": "Whether to use mixed precision training (not all devices support this).",
"title": "Bf16",
"type": "boolean"
},
"fp16": {
"default": false,
"description": "Whether to use mixed precision training (not all devices support this).",
"title": "Fp16",
"type": "boolean"
},
"tokenizer_config": {
"$ref": "#/$defs/TokenizerConfig"
},
"trust_remote_code": {
"default": false,
"description": "Whether to trust the remote code when loading the model.",
"title": "Trust Remote Code",
"type": "boolean"
},
"revision": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Revision from HF repo",
"title": "Revision"
},
"train_head": {
"default": false,
"description": "Whether to train the head of the model. If False, LogReg will be trained.",
"title": "Train Head",
"type": "boolean"
}
},
"title": "CrossEncoderConfig",
"type": "object"
},
"DataConfig": {
"additionalProperties": false,
"description": "Configuration for the data used in the optimization process.",
"properties": {
"scheme": {
"default": "ho",
"description": "Validation scheme to use.",
"enum": [
"ho",
"cv"
],
"title": "Scheme",
"type": "string"
},
"n_folds": {
"default": 3,
"description": "Number of folds in cross-validation.",
"exclusiveMinimum": 0,
"title": "N Folds",
"type": "integer"
},
"validation_size": {
"default": 0.2,
"description": "Fraction of train samples to allocate for validation (if input dataset doesn't contain validation split). If `is_few_shot_train` is True, this value will be ignored.",
"maximum": 1,
"minimum": 0,
"title": "Validation Size",
"type": "number"
},
"separation_ratio": {
"anyOf": [
{
"maximum": 1,
"minimum": 0,
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"description": "Set to float to prevent data leak between scoring and decision nodes.",
"title": "Separation Ratio"
},
"is_few_shot_train": {
"default": false,
"description": "Whether to use few-shot training.",
"title": "Is Few Shot Train",
"type": "boolean"
},
"examples_per_intent": {
"default": 8,
"description": "Number of examples per intent for few-shot validation. If None, all examples will be used.",
"exclusiveMinimum": 0,
"title": "Examples Per Intent",
"type": "integer"
}
},
"title": "DataConfig",
"type": "object"
},
"EmbedderConfig": {
"additionalProperties": false,
"description": "Base class for embedder configurations.",
"properties": {
"default_prompt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Default prompt for the model. This is used when no task specific prompt is not provided.",
"title": "Default Prompt"
},
"classification_prompt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Prompt for classifier.",
"title": "Classification Prompt"
},
"cluster_prompt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Prompt for clustering.",
"title": "Cluster Prompt"
},
"sts_prompt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Prompt for finding most similar sentences.",
"title": "Sts Prompt"
},
"query_prompt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Prompt for query.",
"title": "Query Prompt"
},
"passage_prompt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Prompt for passage.",
"title": "Passage Prompt"
},
"use_cache": {
"default": true,
"description": "Whether to use embeddings caching.",
"title": "Use Cache",
"type": "boolean"
}
},
"title": "EmbedderConfig",
"type": "object"
},
"HFModelConfig": {
"additionalProperties": false,
"properties": {
"model_name": {
"default": "prajjwal1/bert-tiny",
"description": "Name of the hugging face repository with transformer model.",
"title": "Model Name",
"type": "string"
},
"batch_size": {
"default": 32,
"description": "Batch size for model inference.",
"exclusiveMinimum": 0,
"title": "Batch Size",
"type": "integer"
},
"device": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Torch notation for CPU or CUDA.",
"title": "Device"
},
"bf16": {
"default": false,
"description": "Whether to use mixed precision training (not all devices support this).",
"title": "Bf16",
"type": "boolean"
},
"fp16": {
"default": false,
"description": "Whether to use mixed precision training (not all devices support this).",
"title": "Fp16",
"type": "boolean"
},
"tokenizer_config": {
"$ref": "#/$defs/TokenizerConfig"
},
"trust_remote_code": {
"default": false,
"description": "Whether to trust the remote code when loading the model.",
"title": "Trust Remote Code",
"type": "boolean"
},
"revision": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Revision from HF repo",
"title": "Revision"
}
},
"title": "HFModelConfig",
"type": "object"
},
"HPOConfig": {
"additionalProperties": false,
"description": "Configuration for hyperparameter optimization using Optuna.\n\nFor more detailed information about the TPE sampler and its parameters,\nrefer to Optuna's documentation of `TPESampler\n<https://optuna.readthedocs.io/en/stable/reference/samplers/generated/optuna.samplers.TPESampler.html>`_,\n`study.optimize\n<https://optuna.readthedocs.io/en/stable/reference/generated/optuna.study.Study.html#optuna.study.Study.optimize>`_,\n`RandomSampler <https://optuna.readthedocs.io/en/stable/reference/samplers/generated/optuna.samplers.RandomSampler.html>`_.",
"properties": {
"sampler": {
"default": "tpe",
"description": "Optuna sampler. One of 'tpe', 'random'.",
"enum": [
"tpe",
"random"
],
"title": "Sampler",
"type": "string"
},
"n_trials": {
"default": 15,
"description": "Number of trials to run in the optimization process. This is the total number of different hyperparameter combinations that will be evaluated.",
"title": "N Trials",
"type": "integer"
},
"timeout": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"description": "Time limit in seconds for the optimization process. If None, the optimization will run until n_trials is reached.",
"title": "Timeout"
},
"n_jobs": {
"default": 1,
"description": "Number of parallel jobs to run. Set to -1 to use all available CPU cores.",
"title": "N Jobs",
"type": "integer"
},
"n_startup_trials": {
"default": 10,
"description": "Number of initial trials to run using random sampling before switching to TPE algorithm. This helps in better initialization of the TPE algorithm.",
"title": "N Startup Trials",
"type": "integer"
},
"consider_prior": {
"default": true,
"description": "Whether to use Gaussian (normal) distribution as prior for integer and float parameter spaces. This helps in better initialization of the TPE algorithm's parameter distributions.",
"title": "Consider Prior",
"type": "boolean"
},
"prior_weight": {
"default": 1,
"description": "Weight of the prior distribution in the TPE algorithm. Higher values make the algorithm more conservative in exploring new regions.",
"title": "Prior Weight",
"type": "integer"
},
"n_ei_candidates": {
"default": 24,
"description": "Number of candidates to sample for expected improvement calculation in TPE algorithm. Higher values may lead to better exploration but slower optimization.",
"title": "N Ei Candidates",
"type": "integer"
},
"constant_liar": {
"default": false,
"description": "Whether to use constant liar strategy for parallel optimization. If True, the algorithm will penalize running trials to avoid suggesting parameter configurations that are too close to currently running trials.",
"title": "Constant Liar",
"type": "boolean"
}
},
"title": "HPOConfig",
"type": "object"
},
"LoggingConfig": {
"additionalProperties": false,
"description": "Configuration for the logging.",
"properties": {
"project_dir": {
"anyOf": [
{
"format": "path",
"type": "string"
},
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Path to the directory with different runs.",
"title": "Project Dir"
},
"run_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Name of the run. If None, a random name will be generated.",
"title": "Run Name"
},
"dump_modules": {
"default": false,
"description": "Whether to dump the modules or not",
"title": "Dump Modules",
"type": "boolean"
},
"clear_ram": {
"default": false,
"description": "Whether to clear the RAM after dumping the modules",
"title": "Clear Ram",
"type": "boolean"
},
"report_to": {
"anyOf": [
{
"items": {
"enum": [
"wandb",
"tensorboard",
"codecarbon",
"none"
],
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": [
"none"
],
"description": "List of callbacks to report to. If None, no callbacks will be used",
"title": "Report To"
},
"log_interval_time": {
"default": 0.1,
"description": "Sampling interval for the system monitor in seconds for Wandb logger.",
"title": "Log Interval Time",
"type": "number"
}
},
"title": "LoggingConfig",
"type": "object"
},
"TokenizerConfig": {
"additionalProperties": false,
"properties": {
"padding": {
"anyOf": [
{
"type": "boolean"
},
{
"enum": [
"longest",
"max_length",
"do_not_pad"
],
"type": "string"
}
],
"default": true,
"title": "Padding"
},
"truncation": {
"default": true,
"title": "Truncation",
"type": "boolean"
},
"max_length": {
"anyOf": [
{
"exclusiveMinimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Maximum length of input sequences.",
"title": "Max Length"
}
},
"title": "TokenizerConfig",
"type": "object"
}
},
"description": "Configuration for the optimization process.\n\nOne can use it to customize optimization beyond choosing different preset.\nInstantiate it and pass to :py:meth:`autointent.Pipeline.from_optimization_config`.",
"properties": {
"data_config": {
"$ref": "#/$defs/DataConfig",
"default": {
"scheme": "ho",
"n_folds": 3,
"validation_size": 0.2,
"separation_ratio": null,
"is_few_shot_train": false,
"examples_per_intent": 8
}
},
"search_space": {
"items": {
"additionalProperties": true,
"type": "object"
},
"title": "Search Space",
"type": "array"
},
"logging_config": {
"$ref": "#/$defs/LoggingConfig",
"default": {
"project_dir": null,
"run_name": null,
"dump_modules": false,
"clear_ram": false,
"report_to": [
"none"
],
"log_interval_time": 0.1
}
},
"embedder_config": {
"$ref": "#/$defs/EmbedderConfig"
},
"cross_encoder_config": {
"$ref": "#/$defs/CrossEncoderConfig",
"default": {
"model_name": "cross-encoder/ms-marco-MiniLM-L6-v2",
"batch_size": 32,
"device": null,
"bf16": false,
"fp16": false,
"tokenizer_config": {
"max_length": 512,
"padding": true,
"truncation": true
},
"trust_remote_code": false,
"revision": null,
"train_head": false
}
},
"transformer_config": {
"$ref": "#/$defs/HFModelConfig",
"default": {
"model_name": "prajjwal1/bert-tiny",
"batch_size": 32,
"device": null,
"bf16": false,
"fp16": false,
"tokenizer_config": {
"max_length": null,
"padding": true,
"truncation": true
},
"trust_remote_code": false,
"revision": "refs/pr/16"
}
},
"hpo_config": {
"$ref": "#/$defs/HPOConfig",
"default": {
"sampler": "tpe",
"n_trials": 15,
"timeout": null,
"n_jobs": 1,
"n_startup_trials": 10,
"consider_prior": true,
"prior_weight": 1,
"n_ei_candidates": 24,
"constant_liar": false
}
},
"seed": {
"default": 42,
"exclusiveMinimum": 0,
"title": "Seed",
"type": "integer"
}
},
"required": [
"search_space"
],
"title": "OptimizationConfig",
"type": "object"
}