From 22826260dba6638fb31f7aaabd3fe2421396d302 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Thu, 14 Mar 2024 06:48:51 +0000 Subject: [PATCH] Add prefix_string config option for ML models (#2451) * Add prefix_string config option for ML models (#2363) The prefix_strings option was added to support the E5 model in elastic/elasticsearch#102089 * Add prefix_strings option to PUT model request (#2449) Follow up to #2363 where prefix_strings option was added to TrainedModelConfig --- .../elasticsearch-serverless-openapi.json | 19 ++++ output/schema/schema.json | 104 ++++++++++++++---- output/typescript/types.ts | 7 ++ specification/ml/_types/TrainedModel.ts | 12 ++ .../MlPutTrainedModelRequest.ts | 7 ++ 5 files changed, 129 insertions(+), 20 deletions(-) diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index a9ad595f62..b506a96c21 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -9822,6 +9822,9 @@ "items": { "type": "string" } + }, + "prefix_strings": { + "$ref": "#/components/schemas/ml._types:TrainedModelPrefixStrings" } } } @@ -53240,6 +53243,9 @@ }, "location": { "$ref": "#/components/schemas/ml._types:TrainedModelLocation" + }, + "prefix_strings": { + "$ref": "#/components/schemas/ml._types:TrainedModelPrefixStrings" } }, "required": [ @@ -53712,6 +53718,19 @@ "name" ] }, + "ml._types:TrainedModelPrefixStrings": { + "type": "object", + "properties": { + "ingest": { + "description": "String prepended to input at ingest", + "type": "string" + }, + "search": { + "description": "String prepended to input at search", + "type": "string" + } + } + }, "ml._types:TrainedModelStats": { "type": "object", "properties": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 05147281c6..0431152de3 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -139579,7 +139579,7 @@ "name": "DeploymentAllocationState", "namespace": "ml._types" }, - "specLocation": "ml/_types/TrainedModel.ts#L288-L301" + "specLocation": "ml/_types/TrainedModel.ts#L289-L302" }, { "kind": "enum", @@ -139601,7 +139601,7 @@ "name": "DeploymentAssignmentState", "namespace": "ml._types" }, - "specLocation": "ml/_types/TrainedModel.ts#L303-L308" + "specLocation": "ml/_types/TrainedModel.ts#L304-L309" }, { "kind": "enum", @@ -139623,7 +139623,7 @@ "name": "DeploymentState", "namespace": "ml._types" }, - "specLocation": "ml/_types/TrainedModel.ts#L273-L286" + "specLocation": "ml/_types/TrainedModel.ts#L274-L287" }, { "kind": "interface", @@ -140388,7 +140388,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L216-L230" + "specLocation": "ml/_types/TrainedModel.ts#L217-L231" }, { "kind": "interface", @@ -143681,7 +143681,7 @@ "name": "RoutingState", "namespace": "ml._types" }, - "specLocation": "ml/_types/TrainedModel.ts#L350-L371" + "specLocation": "ml/_types/TrainedModel.ts#L351-L372" }, { "kind": "enum", @@ -144344,7 +144344,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L232-L239" + "specLocation": "ml/_types/TrainedModel.ts#L233-L240" }, { "kind": "interface", @@ -144381,7 +144381,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L241-L246" + "specLocation": "ml/_types/TrainedModel.ts#L242-L247" }, { "kind": "interface", @@ -144427,7 +144427,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L248-L255" + "specLocation": "ml/_types/TrainedModel.ts#L249-L256" }, { "kind": "interface", @@ -144506,7 +144506,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L402-L417" + "specLocation": "ml/_types/TrainedModel.ts#L403-L418" }, { "kind": "interface", @@ -144564,7 +144564,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L373-L391" + "specLocation": "ml/_types/TrainedModel.ts#L374-L392" }, { "kind": "interface", @@ -144676,7 +144676,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L315-L348" + "specLocation": "ml/_types/TrainedModel.ts#L316-L349" }, { "kind": "interface", @@ -144911,9 +144911,20 @@ "namespace": "ml._types" } } + }, + { + "name": "prefix_strings", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "TrainedModelPrefixStrings", + "namespace": "ml._types" + } + } } ], - "specLocation": "ml/_types/TrainedModel.ts#L165-L199" + "specLocation": "ml/_types/TrainedModel.ts#L165-L200" }, { "kind": "interface", @@ -144938,7 +144949,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L201-L204" + "specLocation": "ml/_types/TrainedModel.ts#L202-L205" }, { "kind": "interface", @@ -145015,7 +145026,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L206-L214" + "specLocation": "ml/_types/TrainedModel.ts#L207-L215" }, { "kind": "interface", @@ -145061,7 +145072,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L393-L400" + "specLocation": "ml/_types/TrainedModel.ts#L394-L401" }, { "kind": "interface", @@ -145670,7 +145681,7 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L419-L421" + "specLocation": "ml/_types/TrainedModel.ts#L420-L422" }, { "kind": "interface", @@ -145691,7 +145702,41 @@ } } ], - "specLocation": "ml/_types/TrainedModel.ts#L423-L425" + "specLocation": "ml/_types/TrainedModel.ts#L424-L426" + }, + { + "kind": "interface", + "name": { + "name": "TrainedModelPrefixStrings", + "namespace": "ml._types" + }, + "properties": [ + { + "description": "String prepended to input at ingest", + "name": "ingest", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, + { + "description": "String prepended to input at search", + "name": "search", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + } + ], + "specLocation": "ml/_types/TrainedModel.ts#L428-L437" }, { "kind": "interface", @@ -145838,7 +145883,7 @@ "name": "TrainedModelType", "namespace": "ml._types" }, - "specLocation": "ml/_types/TrainedModel.ts#L257-L271" + "specLocation": "ml/_types/TrainedModel.ts#L258-L272" }, { "kind": "enum", @@ -145854,7 +145899,7 @@ "name": "TrainingPriority", "namespace": "ml._types" }, - "specLocation": "ml/_types/TrainedModel.ts#L310-L313" + "specLocation": "ml/_types/TrainedModel.ts#L311-L314" }, { "kind": "interface", @@ -155119,6 +155164,25 @@ } } } + }, + { + "availability": { + "serverless": {}, + "stack": { + "since": "8.12.0" + } + }, + "description": "Optional prefix strings applied at inference", + "name": "prefix_strings", + "required": false, + "since": "8.12.0", + "type": { + "kind": "instance_of", + "type": { + "name": "TrainedModelPrefixStrings", + "namespace": "ml._types" + } + } } ] }, @@ -155169,7 +155233,7 @@ } } ], - "specLocation": "ml/put_trained_model/MlPutTrainedModelRequest.ts#L28-L106" + "specLocation": "ml/put_trained_model/MlPutTrainedModelRequest.ts#L29-L113" }, { "body": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 8b5311eb7b..885ae5ffa2 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -13243,6 +13243,7 @@ export interface MlTrainedModelConfig { metadata?: MlTrainedModelConfigMetadata model_size_bytes?: ByteSize location?: MlTrainedModelLocation + prefix_strings?: MlTrainedModelPrefixStrings } export interface MlTrainedModelConfigInput { @@ -13330,6 +13331,11 @@ export interface MlTrainedModelLocationIndex { name: IndexName } +export interface MlTrainedModelPrefixStrings { + ingest?: string + search?: string +} + export interface MlTrainedModelSizeStats { model_size_bytes: ByteSize required_native_memory_bytes: integer @@ -14350,6 +14356,7 @@ export interface MlPutTrainedModelRequest extends RequestBase { model_size_bytes?: long platform_architecture?: string tags?: string[] + prefix_strings?: MlTrainedModelPrefixStrings } } diff --git a/specification/ml/_types/TrainedModel.ts b/specification/ml/_types/TrainedModel.ts index d1f659d896..c55b106b5f 100644 --- a/specification/ml/_types/TrainedModel.ts +++ b/specification/ml/_types/TrainedModel.ts @@ -196,6 +196,7 @@ export class TrainedModelConfig { metadata?: TrainedModelConfigMetadata model_size_bytes?: ByteSize location?: TrainedModelLocation + prefix_strings?: TrainedModelPrefixStrings } export class TrainedModelConfigInput { @@ -423,3 +424,14 @@ export class TrainedModelLocation { export class TrainedModelLocationIndex { name: IndexName } + +export class TrainedModelPrefixStrings { + /** + * String prepended to input at ingest + */ + ingest?: string + /** + * String prepended to input at search + */ + search?: string +} diff --git a/specification/ml/put_trained_model/MlPutTrainedModelRequest.ts b/specification/ml/put_trained_model/MlPutTrainedModelRequest.ts index 4c5b5d0b7d..4cb40ca309 100644 --- a/specification/ml/put_trained_model/MlPutTrainedModelRequest.ts +++ b/specification/ml/put_trained_model/MlPutTrainedModelRequest.ts @@ -22,6 +22,7 @@ import { RequestBase } from '@_types/Base' import { Id } from '@_types/common' import { long } from '@_types/Numeric' import { Definition, Input } from './types' +import { TrainedModelPrefixStrings } from '../_types/TrainedModel' import { TrainedModelType } from '../_types/TrainedModel' import { InferenceConfigCreateContainer } from '@ml/_types/inference' @@ -102,5 +103,11 @@ export interface Request extends RequestBase { * An array of tags to organize the model. */ tags?: string[] + /** + * Optional prefix strings applied at inference + * @availability stack since=8.12.0 + * @availability serverless + */ + prefix_strings?: TrainedModelPrefixStrings } }