Skip to content

Rerank

Add-on for OG AI Core. Knowledge finds passages by how close their meaning is to the question. That is fast, but the closest match is not always the best answer. OG Rerank reads a bigger set of matches with a rerank model and puts them in order of how well each one answers the question. The chatbot still gets its usual number of passages, only better ones.

Requires: OG AI Core with Pro (Knowledge is a Pro feature), an OpenRouter environment in Settings > AI, and a Rerank licence. WordPress 6.0+, PHP 8.1+. OG AI Core 1.2.35 or later.

What it improves

  • Knowledge (embeddings), in every vector store OG AI Core supports.
  • User Memory: saved memories and past-chat search results come back with the most useful first.

If the rerank model is slow or fails, the chatbot carries on with the usual order.

Install

Install it from OG AI Core > Manage add-ons > Get add-ons: one click if you own it, or enter its licence key.

Set up

  1. In OG AI Core, open Settings > AI > Default Environments > Rerank.
  2. Pick the environment and the rerank model.
  3. Set Passages to check: how many matches the rerank model reads before the usual number is kept. 5 to 50, default 25.
  4. Click Test rerank to check it works.
  5. Open OG AI Core > Add-ons > Rerank and choose, per chatbot, what uses rerank:
Mode Reranks
Knowledge and User Memory Both (the default for chatbots you have not set)
Knowledge only Knowledge matches
User Memory only Memories and past-chat results
Off Nothing

Tip

A chatbot's Max Results and Min Score in its Knowledge environment still decide how many passages it gets. Rerank only changes which ones, and in what order.

How it works

OG AI Core asks for a bigger pool of matches through ogaie_context_rerank_pool, then passes them to ogaie_context_rerank, which returns them best first. User Memory uses ogaie_rerank_texts. Without the add-on, nothing changes.

Filter Arguments Returns
ogaie_context_rerank_pool int 0, array [ 'envId', 'botId' ] How many matches to fetch (0 = the usual number).
ogaie_context_rerank null, array $matches, array [ 'query', 'minScore', 'maxSelect', 'envId', 'embeddings', 'botId' ] The matches to use, best first, or null to keep the order.
ogaie_rerank_texts null, string $question, array $texts, array $context The new order, or null.

Data

Settings are in the option ogrr_settings (env, model, candidates, bots). The last error is kept in ogrr_last_error and shown on the add-on page.

Knowledge · User Memory · OG AI Core