Member Junction
    Preparing search index...

    Decision-based implementation of the BaseReranker class. It asks through AIDecisionRunner, with the query as the state and each document as one Likelihood question ("This note bears on the request: "), in one call or, for more documents than a call may carry, in parallel calls. A document's relevance score is the probability. Documents with equal scores keep their input order.

    Every call writes an MJ: AI Prompt Runs row through the decision runner, which also selects the decision model, resolves its credentials and fails over. When the reranker is given a parent run (ParentPromptRunID, which AIRerankerRunner sets), those rows are its children, and a rerank's response carries their tokens and cost as Usage.

    Configuration:

    • The decision prompt is the one whose ID the reranker is given, or Default Decision when it is given none. It receives that ID the same way LLMReranker receives its prompt's.
    • It needs no API key: the decision runner resolves its own models' keys.
    • When there are more documents than one call may carry, they are split across parallel calls. A call carries at most the smallest MaxQuestionsPerCall among the prompt's models, or, when none declares one, DecisionRerankOptions.MaxDocumentsPerCall in the rerank's options, or DEFAULT_DECISION_RERANK_DOCUMENTS_PER_CALL.
    • The decision calls share one time budget, DecisionRerankOptions.TimeoutMS in the rerank's options, or DEFAULT_DECISION_RERANK_TIMEOUT_MS.

    A failed decision call, an answer missing for any document, or a budget that runs out fails the whole rerank. No score is ever invented.

    The scores are Likelihood probabilities, which are not calibrated, so a low RerankerConfiguration.minRelevanceThreshold suits this reranker: 0.1 is the recommended start.

    Usage:

    const reranker = MJGlobal.Instance.ClassFactory.CreateInstance<BaseReranker>(
    BaseReranker,
    'DecisionReranker',
    '', // No API key needed
    '', // No model name needed
    decisionPromptID, // or '' for Default Decision
    contextUser
    );
    const response = await reranker.Rerank({ query, documents });

    Hierarchy

    • BasePromptBackedReranker
      • DecisionReranker
    Index

    Constructors

    • Create a new DecisionReranker instance.

      Parameters

      • apiKey: string

        Not used, pass an empty string

      • modelName: string

        The reranker model's API name, for logging only

      • promptID: string

        ID of the decision prompt to ask, or an empty string for Default Decision

      • contextUser: UserInfo

        User context for the decision calls

      Returns DecisionReranker

    Properties

    _modelName: string
    ParentPromptRunID?: string

    The MJ: AI Prompt Runs row this rerank is recorded under. When set, every prompt run the reranker makes is created as its child (ParentID), so its cost rolls up to the rerank's run. AIRerankerRunner sets it to its own run before it calls the driver.

    Accessors

    • get apiKey(): string

      Only sub-classes can access the API key

      Returns string

    • get ModelName(): string

      Get the model name used for this reranker

      Returns string

    Methods

    • The response for a call its signal ended, before or during the driver's work. A caller cancellation is classified Cancelled, so it is never failed over; an abort caused by a timeout reads as a retriable network error.

      Parameters

      • signal: AbortSignal
      • error: unknown
      • startTime: number

      Returns RerankResponse

    • Create a standardized error response. Used internally when validation fails or an exception occurs.

      Parameters

      • message: string
      • startTime: number

      Returns RerankResponse

    • Scores every document with one Likelihood question, splitting the questions across parallel calls when there are more than one call may carry. Records the usage of every call, the failed ones included, before it fails on any of them.

      Parameters

      Returns Promise<RerankResult[]>

    • Filter results by minimum relevance threshold. Utility method for implementations that need to filter low-scoring results.

      Parameters

      Returns RerankResult[]

    • Sort results by relevance score in descending order. Utility method for implementations.

      Parameters

      Returns RerankResult[]