Skip to content

Rerank

This example assumes using Jina; is in scope and apiKey contains your Jina API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using var client = new JinaClient(apiKey);

        RerankingResponse output = await client.SearchFoundationModels.RerankAsync(
            new TextRerankerRequest
            {
                Model = TextRerankerRequestModel.JinaRerankerV2BaseMultilingual,
                Query = "Organic skincare products for sensitive skin",
                TopN = 3,
                Documents =
                [
                    "Organic skincare for sensitive skin with aloe vera and chamomile.",
                    "New makeup trends focus on bold colors and innovative techniques.",
                    "Bio-Hautpflege für empfindliche Haut mit Aloe Vera und Kamille.",
                    "Neue Make-up-Trends setzen auf kräftige Farben und innovative Techniken.",
                    "Cuidado de la piel orgánico para piel sensible con aloe vera y manzanilla.",
                    "Las nuevas tendencias de maquillaje se centran en colores vivos y técnicas innovadoras.",
                ],
            });

        foreach (RerankingResult result in output.Results)
        {
            Console.WriteLine($@"
Index: {result.Index}
Document: {result.Document?.Value1 ?? result.Document?.Value2?.Text}
RelevanceScore: {result.RelevanceScore}");
        }