Skip to main content

LLM_EXTRACT

Description​

Used to extract information corresponding to specific labels from text.

Syntax​

LLM_EXTRACT([<resource_name>], <text>, <labels>)

Parameters​

ParameterDescription
<resource_name>The specified resource name, optional
<text>The text from which to extract information
<labels>Array of labels to extract

Return Value​

Returns a string containing all extracted labels and their corresponding values.

If any input is NULL, returns NULL.

The result is generated by a large language model, so the output may vary.

Examples​

SET default_llm_resource = 'resource_name';
SELECT LLM_EXTRACT('Apache Doris is an MPP-based real-time data warehouse known for its high query speed.',
['product_name', 'architecture', 'key_feature']) AS Result;
+---------------------------------------------------------------------------------------+
| Result |
+---------------------------------------------------------------------------------------+
| product_name="Apache Doris", architecture="MPP-based", key_feature="high query speed" |
+---------------------------------------------------------------------------------------+
SELECT LLM_EXTRACT('resource_name', 'Apache Doris began in 2008 as an internal project named Palo.',
['original name', 'founding time']) AS Result;
+----------------------------------------+
| Result |
+----------------------------------------+
| original name=Palo, founding time=2008 |
+----------------------------------------+