Skip to content

7. LLM query primitives — filter, rerank, and steer with the ai namespace

Vector edges (§6) answer “which rows are about X” with an embedding — cheap, but only as good as the similarity model, and blind to any judgment that isn’t cosine distance. Sometimes the discriminator is one no property and no embedding captures: “news actually about my funding round”, “papers whose method is genuinely transformer-based, not just name-dropping it”, “the issues most relevant to this outage”. For those, the query can call a per-row LLM judgment inline, expressed as a reserved ai.* function.

These run at execution time, over the rows a query has already fetched — the LLM counterpart, at the value level, of §9’s generation-time examples: steering. Four primitives across the three query positions:

  • {ai: {hint, model, confidence, fresh, voice, wordcount}} — steer and tune the fetch behind an edge, as a nested directive map (§7.2; the flat ai_* spellings are RETIRED);
  • {realm: {…}} — the realm’s OWN prompt parameters, passed verbatim (§7.2.2);
  • WHERE ai.relevant(n, '<criterion>') — filter rows by subjective relevance;
  • ORDER BY ai.score(n, '<criterion>') DESC — rerank rows by subjective fit;
  • RETURN ai.classify(n, '<dimension>') — label each row along a subjective dimension.