- Kategorien:
Zeichenfolgen- und Binärfunktionen (AI-Funktionen)
AI_EXTRACT¶
Extrahiert Informationen aus einer Eingabezeichenfolge oder Datei.
Syntax¶
Extract information from an input string:
AI_EXTRACT( <text>, <responseFormat> )
AI_EXTRACT( text => <text>,
responseFormat => <responseFormat> )
Extract information from a file:
AI_EXTRACT( <file>, <responseFormat> )
AI_EXTRACT( file => <file>,
responseFormat => <responseFormat> )
Argumente¶
text
Eine Eingabezeichenfolge für die Extraktion.
file
Eine FILE für die Extraktion.
Unterstützte Dateiformate:
PDF
PNG
PPTX
EML
DOC, DOCX
JPEG, JPG
HTM, HTML
TEXT, TXT
TIF, TIFF
Die Dateien müssen kleiner als 100 MB sein.
responseFormat
Informationen, die in einem der folgenden Antwortformate extrahiert werden sollen:
Einfaches Objektschema, das den Feature-Namen und die zu extrahierenden Informationen zuordnet, z. B.:
{'name': 'What is the last name of the employee?', 'address': 'What is the address of the employee?'}
Ein Array von Zeichenfolgen, die die zu extrahierenden Informationen enthalten, z. B.:
['What is the last name of the employee?', 'What is the address of the employee?']
Ein Array von Arrays, die zwei Zeichenfolgen enthalten (Feature-Name und die zu extrahierenden Informationen), z. B.:
[['name', 'What is the last name of the employee?'], ['address', 'What is the address of the employee?']]
Ein Array von Zeichenfolgen, die den Feature-Namen und die zu extrahierenden Informationen enthalten, getrennt durch einen Doppelpunkt („:“), z. B.:
['name: What is the last name of the employee?', 'address: What is the address of the employee?']
Bemerkung
Sie können entweder Fragen in natürlicher Sprache stellen oder die zu extrahierenden Informationen beschreiben ( z. B. Stadt, Straße, ZIP-Code), zum Beispiel:
['address': 'City, street, ZIP', 'name': 'First and last name']
Rückgabewerte¶
Ein JSON-Objekt, das die extrahierten Informationen enthält.
Anforderungen an die Zugriffssteuerung¶
Benutzer müssen eine Rolle verwenden, der die Datenbankrolle SNOWFLAKE.CORTEX_USER zugewiesen wurde: Weitere Informationen zum Erteilen dieser Berechtigung finden Sie unter Erforderliche Berechtigungen.
Nutzungshinweise¶
Die folgenden Sprachen werden unterstützt:
Arabisch
Bengalisch
Birmanisch
Cebuano
Chinesisch
Tschechisch
Holländisch
Englisch
Französisch
Deutsch
Hebräisch
Hindi
Indonesisch
Italienisch
Japanisch
Khmer
Koreanisch
Lao
Malaiisch
Persisch
Polnisch
Portugiesisch
Russisch
Spanisch
Tagalog
Thailändisch
Türkisch
Urdu
Vietnamesisch
Die Dokumente dürfen nicht mehr als 125 Seiten umfassen.
Die maximale Anzahl an Features, die extrahiert werden können, ist 100.
Die maximale Ausgabelänge beträgt 512 Token pro Frage.
Um eine Liste zu extrahieren, fügen Sie
List:
am Anfang jeder Frage hinzu. Beispiel:[['languages', 'List: What languages are supported for AI_EXTRACT?']]
Sie können keinen Doppelpunkt („:“) in einem Feature-Namen verwenden, wenn Sie das Antwortformat verwenden, das einen Doppelpunkt verwendet, um den Feature-Namen und die zu extrahierenden Informationen voneinander zu trennen. Beispiel:
['location: Where does the employee live?', 'name:employee: What is the first name of the employee?']
Konfidenzwerte werden nicht unterstützt.
Beispiele¶
Im folgenden Beispiel werden Informationen aus dem Eingabetext extrahiert:
SELECT AI_EXTRACT(
text => 'John Smith lives in San Francisco and works for Snowflake',
responseFormat => {'name': 'What is the first name of the employee?', 'city': 'What is the address of the employee?'}
);
Im folgenden Beispiel werden Informationen aus dem Eingabetext extrahiert und zurückgegeben:
SELECT AI_EXTRACT(
text => 'John Smith lives in San Francisco and works for Snowflake',
responseFormat => PARSE_JSON('{"name": "What is the first name of the employee?", "address": "What is the address of the employee?"}')
);
Im folgenden Beispiel werden Informationen aus der document.pdf
-Datei extrahiert:
SELECT AI_EXTRACT(
file => TO_FILE('@db.schema.files','document.pdf'),
responseFormat => [['name', 'What is the first name of the employee?'], ['city', 'Where does the employee live?']]
);
Im folgenden Beispiel werden Informationen aus allen Dateien in einem Stagingbereich extrahiert:
SELECT AI_EXTRACT(
file => TO_FILE('@db.schema.files', relative_path),
responseFormat => [
'What is this document?',
'How would you classify this document?'
]
) FROM DIRECTORY (@db.schema.files);
Rechtliche Hinweise¶
Siehe KI und ML in Snowflake für rechtliche Hinweise.