surfacerankingoutliers_llm
Rankingaggregate · returns varchar

OUTLIERS_LLM

LLM-backed outlier detection (escape hatch for OUTLIERS)

Per-group — reads the whole group in one call.

rankingllmllm-escape-hatchjson

Syntax

OUTLIERS_LLM({{ texts }})
OUTLIERS_LLM({{ texts }}, {{ num_outliers }})
OUTLIERS_LLM({{ texts }}, {{ num_outliers }}, '{{ criteria }}')

Arguments

nametypedescription
textsJSON
num_outliersINTEGER
criteria(optional)VARCHAR

About

LLM-backed escape hatch for outlier detection. Use when the canonical embedding path (OUTLIERS) can't match the kind of outlier you want because it requires categorical/taxonomic reasoning that needs world knowledge — e.g., "chicken doesn't belong in a list of fruits" without having to pass an explicit criteria phrase. For routine outlier detection on naturally clustered collections, prefer OUTLIERS — it is much faster and handles most cases, especially when you pass a `criteria` argument to steer it.

Examples

LLM escape hatch identifies non-fruit item as outlier (no criteria needed)

WITH
  test_data AS (
    SELECT
      *
    FROM
      (
        VALUES
          ('apple'),
          ('banana'),
          ('orange'),
          ('grape'),
          ('strawberry'),
          ('watermelon'),
          ('chicken'),
          ('mango'),
          ('pineapple')
      ) AS t (item)
  )
SELECT
  OUTLIERS_LLM (item, 1)
FROM
  test_data

Nearby rabbit holes

same domain
Climb back to The Looking Glass