@@ -47,6 +47,12 @@ message Explanation {
4747 // the attributions are stored by [Attribution.output_index][google.cloud.aiplatform.v1beta1.Attribution.output_index] in the same
4848 // order as they appear in the output_indices.
4949 repeated Attribution attributions = 1 [(google.api.field_behavior ) = OUTPUT_ONLY ];
50+
51+ // Output only. List of the nearest neighbors for example-based explanations.
52+ //
53+ // For models deployed with the examples explanations feature enabled, the
54+ // attributions field is empty and instead the neighbors field is populated.
55+ repeated Neighbor neighbors = 2 [(google.api.field_behavior ) = OUTPUT_ONLY ];
5056}
5157
5258// Aggregated explanation metrics for a Model over a set of instances.
@@ -163,6 +169,15 @@ message Attribution {
163169 string output_name = 7 [(google.api.field_behavior ) = OUTPUT_ONLY ];
164170}
165171
172+ // Neighbors for example-based explanations.
173+ message Neighbor {
174+ // Output only. The neighbor id.
175+ string neighbor_id = 1 [(google.api.field_behavior ) = OUTPUT_ONLY ];
176+
177+ // Output only. The neighbor distance.
178+ double neighbor_distance = 2 [(google.api.field_behavior ) = OUTPUT_ONLY ];
179+ }
180+
166181// Specification of Model explanation.
167182message ExplanationSpec {
168183 // Required. Parameters that configure explaining of the Model's predictions.
@@ -373,17 +388,57 @@ message BlurBaselineConfig {
373388// Example-based explainability that returns the nearest neighbors from the
374389// provided dataset.
375390message Examples {
391+ oneof config {
392+ // The configuration for the generated index, the semantics are the same as
393+ // [metadata][google.cloud.aiplatform.v1beta1.Index.metadata] and should match NearestNeighborSearchConfig.
394+ google.protobuf.Value nearest_neighbor_search_config = 2 ;
395+
396+ // Preset config based on the desired query speed-precision trade-off
397+ // and modality
398+ Preset preset = 4 ;
399+ }
400+
376401 // The Cloud Storage location for the input instances.
377402 GcsSource gcs_source = 1 ;
378403
379- // The configuration for the generated index, the semantics are the same as
380- // [metadata][google.cloud.aiplatform.v1beta1.Index.metadata] and should match NearestNeighborSearchConfig.
381- google.protobuf.Value nearest_neighbor_search_config = 2 ;
382-
383404 // The number of neighbors to return.
384405 int32 neighbor_count = 3 ;
385406}
386407
408+ // Preset configuration for example-based explanations
409+ message Preset {
410+ // Preset option controlling parameters for query speed-precision trade-off
411+ enum Query {
412+ // More precise neighbors as a trade-off against slower response.
413+ // This is also the default value (field-number 0).
414+ PRECISE = 0 ;
415+
416+ // Faster response as a trade-off against less precise neighbors.
417+ FAST = 1 ;
418+ }
419+
420+ // Preset option controlling parameters for different modalities
421+ enum Modality {
422+ // Should not be set. Added as a recommended best practice for enums
423+ MODALITY_UNSPECIFIED = 0 ;
424+
425+ // IMAGE modality
426+ IMAGE = 1 ;
427+
428+ // TEXT modality
429+ TEXT = 2 ;
430+
431+ // TABULAR modality
432+ TABULAR = 3 ;
433+ }
434+
435+ // Preset option controlling parameters for query speed-precision trade-off
436+ optional Query query = 1 ;
437+
438+ // Preset option controlling parameters for different modalities
439+ Modality modality = 2 ;
440+ }
441+
387442// The [ExplanationSpec][google.cloud.aiplatform.v1beta1.ExplanationSpec] entries that can be overridden at
388443// [online explanation][google.cloud.aiplatform.v1beta1.PredictionService.Explain] time.
389444message ExplanationSpecOverride {
@@ -394,6 +449,9 @@ message ExplanationSpecOverride {
394449
395450 // The metadata to be overridden. If not specified, no metadata is overridden.
396451 ExplanationMetadataOverride metadata = 2 ;
452+
453+ // The example-based explanations parameter overrides.
454+ ExamplesOverride examples_override = 3 ;
397455}
398456
399457// The [ExplanationMetadata][google.cloud.aiplatform.v1beta1.ExplanationMetadata] entries that can be overridden at
@@ -418,3 +476,45 @@ message ExplanationMetadataOverride {
418476 // overridden.
419477 map <string , InputMetadataOverride > inputs = 1 [(google.api.field_behavior ) = REQUIRED ];
420478}
479+
480+ // Overrides for example-based explanations.
481+ message ExamplesOverride {
482+ // Data format enum.
483+ enum DataFormat {
484+ // Unspecified format. Must not be used.
485+ DATA_FORMAT_UNSPECIFIED = 0 ;
486+
487+ // Provided data is a set of model inputs.
488+ INSTANCES = 1 ;
489+
490+ // Provided data is a set of embeddings.
491+ EMBEDDINGS = 2 ;
492+ }
493+
494+ // The number of neighbors to return.
495+ int32 neighbor_count = 1 ;
496+
497+ // The number of neighbors to return that have the same crowding tag.
498+ int32 crowding_count = 2 ;
499+
500+ // Restrict the resulting nearest neighbors to respect these constraints.
501+ repeated ExamplesRestrictionsNamespace restrictions = 3 ;
502+
503+ // If true, return the embeddings instead of neighbors.
504+ bool return_embeddings = 4 ;
505+
506+ // The format of the data being provided with each call.
507+ DataFormat data_format = 5 ;
508+ }
509+
510+ // Restrictions namespace for example-based explanations overrides.
511+ message ExamplesRestrictionsNamespace {
512+ // The namespace name.
513+ string namespace_name = 1 ;
514+
515+ // The list of allowed tags.
516+ repeated string allow = 2 ;
517+
518+ // The list of deny tags.
519+ repeated string deny = 3 ;
520+ }
0 commit comments