LLM-based re-ranker that scores chunk relevance in a single batched call.
Sends all chunks to the LLM in one prompt, gets back JSON scores (0-10), then filters by threshold and sorts by score descending.
Usage
# With Arcana.Pipeline (uses ctx.llm automatically)
ctx
|> Pipeline.search()
|> Pipeline.rerank()
|> Pipeline.answer()
# Directly
{:ok, reranked} = Arcana.Reranker.LLM.rerank(
"What is Elixir?",
chunks,
llm: &my_llm/1,
threshold: 7
)Custom prompt
Pass a :prompt function with arity 2 receiving (question, passages) where
passages is a list of {id, chunk} tuples:
prompt_fn = fn question, passages ->
# Build your own prompt using the question and passages
end
LLM.rerank("question", chunks, llm: llm, prompt: prompt_fn)