Skip to content

Commit f99c33e

Browse files
committed
Notes
1 parent 0ffaf94 commit f99c33e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankFeaturePhaseRankCoordinatorContext.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public TextSimilarityRankFeaturePhaseRankCoordinatorContext(
5656

5757
@Override
5858
protected void computeScores(RankFeatureDoc[] featureDocs, ActionListener<float[]> scoreListener) {
59+
60+
// Reconcile the input strings with the documents that they belong to. Input size 6.
61+
// Let's say we have 6 snippets that we reranked from 2 documents (3 snippets each)
62+
5963
// Wrap the provided rankListener to an ActionListener that would handle the response from the inference service
6064
// and then pass the results
6165
final ActionListener<InferenceAction.Response> inferenceListener = scoreListener.delegateFailureAndWrap((l, r) -> {
@@ -76,7 +80,7 @@ protected void computeScores(RankFeatureDoc[] featureDocs, ActionListener<float[
7680
)
7781
);
7882
} else {
79-
float[] scores = extractScoresFromRankedDocs(rankedDocs);
83+
float[] scores = extractScoresFromRankedDocs(rankedDocs); // Return is size 2
8084
l.onResponse(scores);
8185
}
8286
});
@@ -177,7 +181,7 @@ private float[] extractScoresFromRankedDocs(List<RankedDocsResults.RankedDoc> ra
177181
for (RankedDocsResults.RankedDoc rankedDoc : rankedDocs) {
178182
scores[rankedDoc.index()] = rankedDoc.relevanceScore();
179183
}
180-
return scores;
184+
return scores; // Return a float of size 2 (max score index per doc)
181185
}
182186

183187
private static float normalizeScore(float score) {

0 commit comments

Comments
 (0)