surfaceextractionrelations
Extractionscalar · returns json

RELATIONS

Extract (head, type, tail) relation triples from text

Per-row — runs once for each row.

extractionllmtext

Syntax

RELATIONS({{ text }})

Arguments

nametypedescription
textVARCHAR

About

Open information extraction — pulls structured (head, type, tail) triples from free-form text via the specialist zoo's Rebel-large. No schema required, no entity pre-specification; the model extracts every relation it finds. Returns a JSON array of triple objects. Use DuckDB's JSON operators to unnest / filter them, or feed directly into the LARS KG system. Example output: [ {"head": "Bill Gates", "type": "founded", "tail": "Microsoft"}, {"head": "Microsoft", "type": "headquarters location", "tail": "Redmond"} ] Common patterns: -- All triples per article SELECT article_id, RELATIONS(body) FROM news; -- Flatten triples into rows SELECT article_id, t->>'head' AS head, t->>'type' AS rel, t->>'tail' AS tail FROM news, json_each(RELATIONS(body)) AS t; -- Filter by relation type SELECT article_id, body FROM news WHERE EXISTS ( SELECT 1 FROM json_each(RELATIONS(body)) t WHERE t->>'type' LIKE '%founder%' ); For LLM-style reasoning or schema-guided extraction (single complex object per row rather than open triples), use ASK or EXTRACTS_LLM.

Examples

Basic triple extraction (Microsoft should appear in the triples)

SELECT
  relations ('Bill Gates founded Microsoft in 1975.')

Headquarters relation extraction

SELECT
  relations (
    'Apple Inc. is headquartered in Cupertino, California.'
  )

Nearby rabbit holes

same domain
Climb back to The Looking Glass