Skip to content

Commit 716e021

Browse files
speedstorm1copybara-github
authored andcommitted
feat: support hyperparameters in distillation tuning
PiperOrigin-RevId: 890622141
1 parent 8f3373e commit 716e021

5 files changed

Lines changed: 47 additions & 2 deletions

File tree

api-report/genai-node.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,9 @@ export interface DistillationDataStats {
889889
// @public
890890
export interface DistillationHyperParameters {
891891
adapterSize?: AdapterSize;
892+
batchSize?: number;
892893
epochCount?: string;
894+
learningRate?: number;
893895
learningRateMultiplier?: number;
894896
}
895897

@@ -909,6 +911,7 @@ export interface DistillationSpec {
909911
studentModel?: string;
910912
trainingDatasetUri?: string;
911913
tunedTeacherModelSource?: string;
914+
tuningMode?: TuningMode;
912915
validationDatasetUri?: string;
913916
}
914917

api-report/genai-web.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,9 @@ export interface DistillationDataStats {
889889
// @public
890890
export interface DistillationHyperParameters {
891891
adapterSize?: AdapterSize;
892+
batchSize?: number;
892893
epochCount?: string;
894+
learningRate?: number;
893895
learningRateMultiplier?: number;
894896
}
895897

@@ -909,6 +911,7 @@ export interface DistillationSpec {
909911
studentModel?: string;
910912
trainingDatasetUri?: string;
911913
tunedTeacherModelSource?: string;
914+
tuningMode?: TuningMode;
912915
validationDatasetUri?: string;
913916
}
914917

api-report/genai.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,9 @@ export interface DistillationDataStats {
889889
// @public
890890
export interface DistillationHyperParameters {
891891
adapterSize?: AdapterSize;
892+
batchSize?: number;
892893
epochCount?: string;
894+
learningRate?: number;
893895
learningRateMultiplier?: number;
894896
}
895897

@@ -909,6 +911,7 @@ export interface DistillationSpec {
909911
studentModel?: string;
910912
trainingDatasetUri?: string;
911913
tunedTeacherModelSource?: string;
914+
tuningMode?: TuningMode;
912915
validationDatasetUri?: string;
913916
}
914917

src/converters/_tunings_converters.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ export function createTuningJobConfigToVertex(
450450
fromTuningMode,
451451
);
452452
}
453+
} else if (discriminatorTuningMode === 'DISTILLATION') {
454+
const fromTuningMode = common.getValueByPath(fromObject, ['tuningMode']);
455+
if (parentObject !== undefined && fromTuningMode != null) {
456+
common.setValueByPath(
457+
parentObject,
458+
['distillationSpec', 'tuningMode'],
459+
fromTuningMode,
460+
);
461+
}
453462
}
454463

455464
const fromCustomBaseModel = common.getValueByPath(fromObject, [
@@ -479,6 +488,15 @@ export function createTuningJobConfigToVertex(
479488
fromBatchSize,
480489
);
481490
}
491+
} else if (discriminatorBatchSize === 'DISTILLATION') {
492+
const fromBatchSize = common.getValueByPath(fromObject, ['batchSize']);
493+
if (parentObject !== undefined && fromBatchSize != null) {
494+
common.setValueByPath(
495+
parentObject,
496+
['distillationSpec', 'hyperParameters', 'batchSize'],
497+
fromBatchSize,
498+
);
499+
}
482500
}
483501

484502
let discriminatorLearningRate = common.getValueByPath(rootObject, [
@@ -499,6 +517,17 @@ export function createTuningJobConfigToVertex(
499517
fromLearningRate,
500518
);
501519
}
520+
} else if (discriminatorLearningRate === 'DISTILLATION') {
521+
const fromLearningRate = common.getValueByPath(fromObject, [
522+
'learningRate',
523+
]);
524+
if (parentObject !== undefined && fromLearningRate != null) {
525+
common.setValueByPath(
526+
parentObject,
527+
['distillationSpec', 'hyperParameters', 'learningRate'],
528+
fromLearningRate,
529+
);
530+
}
502531
}
503532

504533
const fromLabels = common.getValueByPath(fromObject, ['labels']);

src/types.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4609,14 +4609,19 @@ export declare interface PreferenceOptimizationSpec {
46094609
validationDatasetUri?: string;
46104610
}
46114611

4612-
/** Hyperparameters for Distillation. This data type is not supported in Gemini API. */
4612+
/** Hyperparameters for distillation. */
46134613
export declare interface DistillationHyperParameters {
46144614
/** Optional. Adapter size for distillation. */
46154615
adapterSize?: AdapterSize;
46164616
/** Optional. Number of complete passes the model makes over the entire training dataset during training. */
46174617
epochCount?: string;
46184618
/** Optional. Multiplier for adjusting the default learning rate. */
46194619
learningRateMultiplier?: number;
4620+
/** The batch size hyperparameter for tuning.
4621+
This is only supported for OSS models in Vertex. */
4622+
batchSize?: number;
4623+
/** The learning rate for tuning. OSS models only. */
4624+
learningRate?: number;
46204625
}
46214626

46224627
/** Distillation tuning spec for tuning. */
@@ -4637,6 +4642,8 @@ export declare interface DistillationSpec {
46374642
tunedTeacherModelSource?: string;
46384643
/** Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file. */
46394644
validationDatasetUri?: string;
4645+
/** Tuning mode for tuning. */
4646+
tuningMode?: TuningMode;
46404647
}
46414648

46424649
/** The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). This data type is not supported in Gemini API. */
@@ -5203,7 +5210,7 @@ export declare interface CreateTuningJobConfig {
52035210
preTunedModelCheckpointId?: string;
52045211
/** Adapter size for tuning. */
52055212
adapterSize?: AdapterSize;
5206-
/** Tuning mode for SFT tuning. */
5213+
/** Tuning mode for tuning. */
52075214
tuningMode?: TuningMode;
52085215
/** Custom base model for tuning. This is only supported for OSS models in Vertex. */
52095216
customBaseModel?: string;

0 commit comments

Comments
 (0)