@@ -425,7 +425,7 @@ enum RecommendStrategy {
425425 // examples, its score is then chosen from the `max(max_pos_score, max_neg_score)`.
426426 // If the `max_neg_score` is chosen then it is squared and negated.
427427 BestScore = 1 ;
428-
428+
429429 // Uses custom search objective. Compares against all inputs, sums all the scores.
430430 // Scores against positive vectors are added, against negatives are subtracted.
431431 SumScores = 2 ;
@@ -631,13 +631,40 @@ message PowExpression {
631631
632632message DecayParamsExpression {
633633 // The variable to decay
634- Expression x = 1 ;
634+ Expression x = 1 ;
635635 // The target value to start decaying from. Defaults to 0.
636- optional Expression target = 2 ;
636+ optional Expression target = 2 ;
637637 // The scale factor of the decay, in terms of `x`. Defaults to 1.0. Must be a non-zero positive number.
638- optional float scale = 3 ;
638+ optional float scale = 3 ;
639639 // The midpoint of the decay. Defaults to 0.5. Output will be this value when `|x - target| == scale`.
640- optional float midpoint = 4 ;
640+ optional float midpoint = 4 ;
641+ }
642+
643+ message NearestInputWithMmr {
644+ // The vector to search for nearest neighbors.
645+ VectorInput nearest = 1 ;
646+
647+ // Perform MMR (Maximal Marginal Relevance) reranking after search,
648+ // using the same vector in this query to calculate relevance.
649+ Mmr mmr = 2 ;
650+ }
651+
652+ // Maximal Marginal Relevance (MMR) algorithm for re-ranking the points.
653+ message Mmr {
654+ // Tunable parameter for the MMR algorithm.
655+ // Determines the balance between diversity and relevance.
656+ //
657+ // A higher value favors diversity (dissimilarity to selected results),
658+ // while a lower value favors relevance (similarity to the query vector).
659+ //
660+ // Must be in the range [0, 1].
661+ // Default value is 0.5.
662+ optional float diversity = 2 ;
663+
664+ // The maximum number of candidates to consider for re-ranking.
665+ //
666+ // If not specified, the `limit` value is used.
667+ optional uint32 candidates_limit = 3 ;
641668}
642669
643670message Query {
@@ -650,6 +677,7 @@ message Query {
650677 Fusion fusion = 6 ; // Fuse the results of multiple prefetches.
651678 Sample sample = 7 ; // Sample points from the collection.
652679 Formula formula = 8 ; // Score boosting via an arbitrary formula
680+ NearestInputWithMmr nearest_with_mmr = 9 ; // Search nearest neighbors, but re-rank based on the Maximal Marginal Relevance algorithm.
653681 }
654682}
655683
@@ -830,7 +858,7 @@ message UpdateBatchPoints {
830858message PointsOperationResponse {
831859 UpdateResult result = 1 ;
832860 double time = 2 ; // Time spent to process
833- optional HardwareUsage usage = 3 ;
861+ optional Usage usage = 3 ;
834862}
835863
836864message UpdateResult {
@@ -887,25 +915,25 @@ message GroupsResult {
887915message SearchResponse {
888916 repeated ScoredPoint result = 1 ;
889917 double time = 2 ; // Time spent to process
890- optional HardwareUsage usage = 3 ;
918+ optional Usage usage = 3 ;
891919}
892920
893921message QueryResponse {
894922 repeated ScoredPoint result = 1 ;
895923 double time = 2 ; // Time spent to process
896- optional HardwareUsage usage = 3 ;
924+ optional Usage usage = 3 ;
897925}
898926
899927message QueryBatchResponse {
900928 repeated BatchResult result = 1 ;
901929 double time = 2 ; // Time spent to process
902- optional HardwareUsage usage = 3 ;
930+ optional Usage usage = 3 ;
903931}
904932
905933message QueryGroupsResponse {
906934 GroupsResult result = 1 ;
907935 double time = 2 ; // Time spent to process
908- optional HardwareUsage usage = 3 ;
936+ optional Usage usage = 3 ;
909937}
910938
911939message BatchResult {
@@ -915,26 +943,26 @@ message BatchResult {
915943message SearchBatchResponse {
916944 repeated BatchResult result = 1 ;
917945 double time = 2 ; // Time spent to process
918- optional HardwareUsage usage = 3 ;
946+ optional Usage usage = 3 ;
919947}
920948
921949message SearchGroupsResponse {
922950 GroupsResult result = 1 ;
923951 double time = 2 ; // Time spent to process
924- optional HardwareUsage usage = 3 ;
952+ optional Usage usage = 3 ;
925953}
926954
927955message CountResponse {
928956 CountResult result = 1 ;
929957 double time = 2 ; // Time spent to process
930- optional HardwareUsage usage = 3 ;
958+ optional Usage usage = 3 ;
931959}
932960
933961message ScrollResponse {
934962 optional PointId next_page_offset = 1 ; // Use this offset for the next query
935963 repeated RetrievedPoint result = 2 ;
936964 double time = 3 ; // Time spent to process
937- optional HardwareUsage usage = 4 ;
965+ optional Usage usage = 4 ;
938966}
939967
940968message CountResult {
@@ -953,42 +981,43 @@ message RetrievedPoint {
953981message GetResponse {
954982 repeated RetrievedPoint result = 1 ;
955983 double time = 2 ; // Time spent to process
956- optional HardwareUsage usage = 3 ;
984+ optional Usage usage = 3 ;
957985}
958986
959987message RecommendResponse {
960988 repeated ScoredPoint result = 1 ;
961989 double time = 2 ; // Time spent to process
962- optional HardwareUsage usage = 3 ;
990+ optional Usage usage = 3 ;
963991}
964992
965993message RecommendBatchResponse {
966994 repeated BatchResult result = 1 ;
967995 double time = 2 ; // Time spent to process
968- optional HardwareUsage usage = 3 ;
996+ optional Usage usage = 3 ;
969997}
970998
971999message DiscoverResponse {
9721000 repeated ScoredPoint result = 1 ;
9731001 double time = 2 ; // Time spent to process
974- optional HardwareUsage usage = 3 ;
1002+ optional Usage usage = 3 ;
9751003}
9761004
9771005message DiscoverBatchResponse {
9781006 repeated BatchResult result = 1 ;
9791007 double time = 2 ; // Time spent to process
980- optional HardwareUsage usage = 3 ;
1008+ optional Usage usage = 3 ;
9811009}
9821010
9831011message RecommendGroupsResponse {
9841012 GroupsResult result = 1 ;
9851013 double time = 2 ; // Time spent to process
986- optional HardwareUsage usage = 3 ;
1014+ optional Usage usage = 3 ;
9871015}
9881016
9891017message UpdateBatchResponse {
9901018 repeated UpdateResult result = 1 ;
9911019 double time = 2 ; // Time spent to process
1020+ optional Usage usage = 3 ;
9921021}
9931022
9941023message FacetResponse {
@@ -999,13 +1028,13 @@ message FacetResponse {
9991028message SearchMatrixPairsResponse {
10001029 SearchMatrixPairs result = 1 ;
10011030 double time = 2 ; // Time spent to process
1002- optional HardwareUsage usage = 3 ;
1031+ optional Usage usage = 3 ;
10031032}
10041033
10051034message SearchMatrixOffsetsResponse {
10061035 SearchMatrixOffsets result = 1 ;
10071036 double time = 2 ; // Time spent to process
1008- optional HardwareUsage usage = 3 ;
1037+ optional Usage usage = 3 ;
10091038}
10101039
10111040// ---------------------------------------------
@@ -1080,6 +1109,7 @@ message Match {
10801109 RepeatedIntegers integers = 6 ; // Match multiple integers
10811110 RepeatedIntegers except_integers = 7 ; // Match any other value except those integers
10821111 RepeatedStrings except_keywords = 8 ; // Match any other value except those keywords
1112+ string phrase = 9 ; // Match phrase text
10831113 }
10841114}
10851115
@@ -1166,6 +1196,27 @@ message GeoPoint {
11661196 double lat = 2 ;
11671197}
11681198
1199+ // ---------------------------------------------
1200+ // ----------- Measurements collector ----------
1201+ // ---------------------------------------------
1202+ message Usage {
1203+ optional HardwareUsage hardware = 1 ;
1204+ optional InferenceUsage inference = 2 ;
1205+ }
1206+
1207+
1208+ // ---------------------------------------------
1209+ // ------------ Inference measurements ----------
1210+ // ---------------------------------------------
1211+
1212+ message InferenceUsage {
1213+ map <string , ModelUsage > models = 1 ;
1214+ }
1215+
1216+ message ModelUsage {
1217+ uint64 tokens = 1 ;
1218+ }
1219+
11691220// ---------------------------------------------
11701221// ------------ Hardware measurements ----------
11711222// ---------------------------------------------
0 commit comments