1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.documentai.v1; 18 19import "google/api/resource.proto"; 20import "google/protobuf/timestamp.proto"; 21 22option csharp_namespace = "Google.Cloud.DocumentAI.V1"; 23option go_package = "cloud.google.com/go/documentai/apiv1/documentaipb;documentaipb"; 24option java_multiple_files = true; 25option java_outer_classname = "DocumentAiEvaluation"; 26option java_package = "com.google.cloud.documentai.v1"; 27option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; 28option ruby_package = "Google::Cloud::DocumentAI::V1"; 29 30// Gives a short summary of an evaluation, and links to the evaluation itself. 31message EvaluationReference { 32 // The resource name of the Long Running Operation for the evaluation. 33 string operation = 1; 34 35 // The resource name of the evaluation. 36 string evaluation = 2 [(google.api.resource_reference) = { 37 type: "documentai.googleapis.com/Evaluation" 38 }]; 39 40 // An aggregate of the statistics for the evaluation with fuzzy matching on. 41 Evaluation.Metrics aggregate_metrics = 4; 42 43 // An aggregate of the statistics for the evaluation with fuzzy matching off. 44 Evaluation.Metrics aggregate_metrics_exact = 5; 45} 46 47// An evaluation of a ProcessorVersion's performance. 48message Evaluation { 49 option (google.api.resource) = { 50 type: "documentai.googleapis.com/Evaluation" 51 pattern: "projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}" 52 }; 53 54 // Evaluation counters for the documents that were used. 55 message Counters { 56 // How many documents were sent for evaluation. 57 int32 input_documents_count = 1; 58 59 // How many documents were not included in the evaluation as they didn't 60 // pass validation. 61 int32 invalid_documents_count = 2; 62 63 // How many documents were not included in the evaluation as Document AI 64 // failed to process them. 65 int32 failed_documents_count = 3; 66 67 // How many documents were used in the evaluation. 68 int32 evaluated_documents_count = 4; 69 } 70 71 // Evaluation metrics, either in aggregate or about a specific entity. 72 message Metrics { 73 // The calculated precision. 74 float precision = 1; 75 76 // The calculated recall. 77 float recall = 2; 78 79 // The calculated f1 score. 80 float f1_score = 3; 81 82 // The amount of occurrences in predicted documents. 83 int32 predicted_occurrences_count = 4; 84 85 // The amount of occurrences in ground truth documents. 86 int32 ground_truth_occurrences_count = 5; 87 88 // The amount of documents with a predicted occurrence. 89 int32 predicted_document_count = 10; 90 91 // The amount of documents with a ground truth occurrence. 92 int32 ground_truth_document_count = 11; 93 94 // The amount of true positives. 95 int32 true_positives_count = 6; 96 97 // The amount of false positives. 98 int32 false_positives_count = 7; 99 100 // The amount of false negatives. 101 int32 false_negatives_count = 8; 102 103 // The amount of documents that had an occurrence of this label. 104 int32 total_documents_count = 9; 105 } 106 107 // Evaluations metrics, at a specific confidence level. 108 message ConfidenceLevelMetrics { 109 // The confidence level. 110 float confidence_level = 1; 111 112 // The metrics at the specific confidence level. 113 Metrics metrics = 2; 114 } 115 116 // Metrics across multiple confidence levels. 117 message MultiConfidenceMetrics { 118 // A type that determines how metrics should be interpreted. 119 enum MetricsType { 120 // The metrics type is unspecified. By default, metrics without a 121 // particular specification are for leaf entity types (i.e., top-level 122 // entity types without child types, or child types which are not 123 // parent types themselves). 124 METRICS_TYPE_UNSPECIFIED = 0; 125 126 // Indicates whether metrics for this particular label type represent an 127 // aggregate of metrics for other types instead of being based on actual 128 // TP/FP/FN values for the label type. Metrics for parent (i.e., non-leaf) 129 // entity types are an aggregate of metrics for their children. 130 AGGREGATE = 1; 131 } 132 133 // Metrics across confidence levels with fuzzy matching enabled. 134 repeated ConfidenceLevelMetrics confidence_level_metrics = 1; 135 136 // Metrics across confidence levels with only exact matching. 137 repeated ConfidenceLevelMetrics confidence_level_metrics_exact = 4; 138 139 // The calculated area under the precision recall curve (AUPRC), computed by 140 // integrating over all confidence thresholds. 141 float auprc = 2; 142 143 // The Estimated Calibration Error (ECE) of the confidence of the predicted 144 // entities. 145 float estimated_calibration_error = 3; 146 147 // The AUPRC for metrics with fuzzy matching disabled, i.e., exact matching 148 // only. 149 float auprc_exact = 5; 150 151 // The ECE for the predicted entities with fuzzy matching disabled, i.e., 152 // exact matching only. 153 float estimated_calibration_error_exact = 6; 154 155 // The metrics type for the label. 156 MetricsType metrics_type = 7; 157 } 158 159 // The resource name of the evaluation. 160 // Format: 161 // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}` 162 string name = 1; 163 164 // The time that the evaluation was created. 165 google.protobuf.Timestamp create_time = 2; 166 167 // Counters for the documents used in the evaluation. 168 Counters document_counters = 5; 169 170 // Metrics for all the entities in aggregate. 171 MultiConfidenceMetrics all_entities_metrics = 3; 172 173 // Metrics across confidence levels, for different entities. 174 map<string, MultiConfidenceMetrics> entity_metrics = 4; 175 176 // The KMS key name used for encryption. 177 string kms_key_name = 6; 178 179 // The KMS key version with which data is encrypted. 180 string kms_key_version_name = 7; 181} 182