snowflake.snowpark.DataFrameAIFunctions.extract¶
- DataFrameAIFunctions.extract(input_column: Union[snowflake.snowpark.column.Column, str], *, response_format: Optional[Union[Dict[str, str], List]] = None, output_column: Optional[str] = None) snowflake.snowpark.DataFrame[source]¶
Extract structured information from text or files using a response schema.
- Parameters:
input_column – The column (Column object or column name as string) containing the text or FILE data to extract information from. Use
to_filefor staged file paths.response_format –
The schema describing information to extract. Supports:
Simple object schema (dict) mapping feature names to extraction prompts:
{'name': 'What is the last name of the employee?', 'address': 'What is the address of the employee?'}Array of strings containing the information to be extracted:
['What is the last name of the employee?', 'What is the address of the employee?']Array of arrays containing two strings (feature name and extraction prompt):
[['name', 'What is the last name of the employee?'], ['address', 'What is the address of the employee?']]Array of strings with colon-separated feature names and extraction prompts:
['name: What is the last name of the employee?', 'address: What is the address of the employee?']
output_column – The name of the output column to be appended. If not provided, a column named
AI_EXTRACT_OUTPUTis appended.
- Returns:
A new DataFrame with an appended JSON object containing the extracted fields under
response.
Examples:
This function or method is experimental since 1.39.0.