ExAgent.Services.JinaRerankerService (ExAgent v0.3.0)

Copy Markdown View Source

HTTP service for a self-hosted jina-reranker-m0 server.

The contract

POST {base_url}/v1/rerank:

{"query": "...", "documents": ["...", "..."],
 "top_n": 5, "return_documents": false}

answering

{"model": "...",
 "results": [{"index": 0, "relevance_score": 0.28,
              "document": {"text": "..."}}]}

Results arrive ordered by descending score. document is nested under a "text" key and only present when asked for; return_documents defaults to true server-side, and this service sends false unless you opt in, because :index already identifies the document and echoing a corpus back is waste.

Verified against a running deployment: the server rejects unknown body fields, requires at least one document, and caps a batch at 512.

Summary

Functions

Reorders documents by relevance to query.

Functions

rerank(provider, query, documents, opts \\ [])

@spec rerank(
  ExAgent.Providers.JinaRerankerM0.t(),
  String.t(),
  [String.t()],
  keyword()
) ::
  {:ok, ExAgent.Reranking.t()} | {:error, ExAgent.Error.t()}

Reorders documents by relevance to query.

Options

  • :model - overrides the provider's :model in the request body
  • :top_n - return only the best n; the server still scores every document
  • :return_documents - echo the document text back (default false)

Examples

ExAgent.rerank(provider, "who restarts processes?", chunks, top_n: 5)