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 (all but ai.terms, below) — the LLM counterpart, at the
value level, of §9’s generation-time examples: steering. The primitives, by where they stand in a query:
{ai: {hint, model, confidence, fresh, voice, wordcount}}— steer and tune the fetch behind an edge, as a nested directive map (§7.2; the flatai_*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;CALL ai.fromText(text, '<pattern>') YIELD …— project a typed graph shape out of text (§7.8);CALL ai.terms(input, '<what the terms name>' [, {ai: {…}}]) YIELD term, kind, confidence— propose the search terms a person’s words could mean, for the query to look up in the data (§7.10). The one primitive that shapes what is fetched rather than judging what was: the model suggests, the data decides.

