Aggregate functions in Flock perform operations on groups of rows, returning a single result for each group. They’re particularly useful for summarizing, ranking, and reordering data, often used with the GROUP BY clause. Each aggregate LLM function page documents Text, Image, and Voice modalities.

1. Available Aggregate Functions

  1. llm_reduce: Summarize or consolidate a group
  2. llm_rerank: Reorder rows by relevance (sliding window)
  3. llm_first: Most relevant row in a group
  4. llm_last: Least relevant row in a group

2. Context Columns API

3. When to Use Aggregate Functions

  • Summarization: llm_reduce over text, image collections, or audio clips
  • Ranking: llm_first, llm_last, or llm_rerank by text, visual, or spoken criteria
  • Structured output: JSON schemas via model_parameters — see each function’s Output section