Skip to content

Proposal: add rerank operation for cross-encoder / rerank-API models #253

Open

Description

@Krishnachaitanyakc

Problem

RAG pipelines run a re-rank step after retrieval — cross-encoder or rerank-API — to score and re-order candidate documents before inference. There's no gen_ai.operation.name value for it today, so latency, cost, and per-document scores can't be attributed independently of retrieval and inference.

#217 just established gen_ai.retrieval.* as a separate namespace. rerank is the natural next operation in that direction. Distinct from gen_ai.evaluation.result (rerank produces scores, doesn't judge other models) and from embeddings (cross-encoder, no vector exposed). No existing issue mentions rerank (verified via repo search).

Proposal

Add rerank to gen_ai.operation.name + a single gen_ai.rerank.client span, with three attributes: gen_ai.rerank.candidate.count, gen_ai.rerank.top_n, gen_ai.rerank.scores (opt_in). Primary reference scenario: Cohere SDK 6.1.0 — every attribute sourced from a typed kwarg or response field. Voyage and Jina follow the same shape (Voyage uses top_k).

Open questions

  1. huggingface provider enum — bundle with the rerank PR or prerequisite issue? Needed for LlamaIndex SentenceTransformerRerank.
  2. Token usage shape — Cohere reports meta.billed_units.search_units (custom unit). Add gen_ai.usage.search_units opt_in, or omit usage attrs entirely until cross-provider patterns emerge?
  3. gen_ai.rerank.scores cardinality — keep opt_in on the span, or downgrade to event-only?
  4. Span-kind — ship client now and defer internal, or define both now?

Happy to draft the PR once SIG signals direction.

Activity

  1. AgentGymLeader commented on Jun 5, 2026

    @AgentGymLeader
    Contributor

    This split makes sense to me. Rerank has a different latency/cost/cardinality profile from both retrieval and inference, so treating it as a separate operation seems consistent with the retrieval split in #217.

    For the open questions, my leaning would be:

    • start with the client span first, and defer internal until there are concrete in-process cross-encoder scenarios
    • avoid adding usage units until there are a couple of providers with compatible semantics
    • avoid putting per-document scores on the span by default; if they are captured, span events or a clearly opt-in shape with a cardinality/payload warning seems safer
    • keep provider enum changes separate unless the first reference scenario actually requires one

    That would keep the initial PR small while leaving room for richer rerank telemetry later.

  2. Krishnachaitanyakc commented on Sep 5, 2026

    @Krishnachaitanyakc
    MemberAuthor

    @lmolkova Reviving this since open-telemetry/opentelemetry-python-genai#566 lists it under "Blocked on Semantic Conventions". Withdrawing the gen_ai.rerank.* attributes and the separate span type: per #249's grouping rule this is a rerank value on gen_ai.operation.name reusing gen_ai.retrieval.client, same as your call on #353. Derivable from cohere==7.1.1 ClientV2.rerank and llama-index's ReRankStartEvent. Happy to open the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions