Arcana.Reranker.CrossEncoder (Arcana v2.0.1)

Copy Markdown View Source

Local cross-encoder reranker using Bumblebee.

Scores query-chunk pairs with a cross-encoder model, producing raw relevance logits. Much more accurate than bi-encoder similarity since the model sees the query and chunk together.

Usage

# In Arcana.Pipeline
ctx
|> Pipeline.search()
|> Pipeline.rerank(reranker: Arcana.Reranker.CrossEncoder)
|> Pipeline.answer()

# Directly
{:ok, reranked} = Arcana.Reranker.CrossEncoder.rerank(
  "What is Elixir?",
  chunks,
  threshold: 0.0
)

Configuration

The serving must be started in your supervision tree:

children = [
  {Arcana.Reranker.CrossEncoder, model: "cross-encoder/ms-marco-MiniLM-L-6-v2"}
]

Options

  • :model - HuggingFace model ID (default: cross-encoder/ms-marco-MiniLM-L-6-v2)
  • :threshold - Minimum logit score to keep (default: 0.0)
  • :top_k - Keep top N results regardless of threshold (overrides threshold)

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])