카테고리:

문자열 및 이진 함수 (AI 함수)

AI_EXTRACT

입력 문자열 또는 파일에서 정보를 추출합니다.

구문

입력 문자열에서 정보 추출:

AI_EXTRACT( <text>, <responseFormat> )
Copy
AI_EXTRACT( text => <text>,
            responseFormat => <responseFormat> )
Copy

파일에서 정보 추출:

AI_EXTRACT( <file>, <responseFormat> )
Copy
AI_EXTRACT( file => <file>,
            responseFormat => <responseFormat> )
Copy

인자

text

추출을 위한 입력 문자열입니다.

file

추출을 위한 FILE 입니다.

지원되는 파일 형식:

  • PDF

  • PNG

  • PPTX

  • EML

  • DOC, DOCX

  • JPEG, JPG

  • HTM, HTML

  • TEXT, TXT

  • TIF, TIFF

파일은 크기는 100MB 미만이어야 합니다.

responseFormat

다음 응답 형식 중 하나로 추출할 정보입니다.

  • 추출할 기능 이름과 정보를 매핑하는 간단한 오브젝트 스키마입니다. 예를 들면 다음과 같습니다.

    {'name': 'What is the last name of the employee?', 'address': 'What is the address of the employee?'}
    
  • 추출할 정보가 포함된 문자열 배열입니다. 예를 들면 다음과 같습니다.

    ['What is the last name of the employee?', 'What is the address of the employee?']
    
  • 두 개의 문자열(추출할 기능 이름과 정보)을 포함하는 배열의 배열입니다. 예를 들면 다음과 같습니다.

    [['name', 'What is the last name of the employee?'], ['address', 'What is the address of the employee?']]
    
  • 추출할 기능 이름과 정보를 콜론(“:”)으로 구분하여 포함하는 문자열 배열입니다. 예를 들면 다음과 같습니다.

    ['name: What is the last name of the employee?', 'address: What is the address of the employee?']
    

참고

자연어로 질문하거나 추출할 정보(예: 도시, 거리, ZIP 코드)를 설명할 수 있습니다. 예를 들면 다음과 같습니다.

['address': 'City, street, ZIP', 'name': 'First and last name']

반환

추출된 정보를 포함하는 JSON 오브젝트입니다.

액세스 제어 요구 사항

사용자는 SNOWFLAKE.CORTEX_USER 데이터베이스 역할 이 부여된 역할을 사용해야 합니다. 이 권한 부여에 대한 내용은 필수 권한 섹션을 참조하세요.

사용법 노트

  • 다음 언어가 지원됩니다.

    • 아랍어

    • 벵골어

    • 버마어

    • 세부아노어

    • 중국어

    • 체코어

    • 네덜란드어

    • 영어

    • 프랑스어

    • 독일어

    • 히브리어

    • 힌디어

    • 인도네시아어

    • 이탈리아어

    • 일본어

    • 크메르어

    • 한국어

    • 라오어

    • 말레이어

    • 페르시아어

    • 폴란드어

    • 포르투갈어

    • 러시아어

    • 스페인어

    • 타갈로그어

    • 태국어

    • 터키어

    • 우르두어

    • 베트남어

  • 문서의 길이는 125페이지를 넘지 않아야 합니다.

  • 추출할 수 있는 최대 기능 수는 100개입니다.

  • 최대 출력 길이는 질문당 512개 토큰입니다.

  • 목록을 추출하려면 각 질문의 시작 부분에 List: 를 추가합니다. 예:

    [['languages', 'List: What languages are supported for AI_EXTRACT?']]
    
  • 콜론을 사용하여 기능 이름과 추출할 정보를 구분하는 응답 형식을 사용할 때는 기능 이름 안에 콜론(“:”)을 사용할 수 없습니다. 예를 들면 다음과 같습니다.

    ['location: Where does the employee live?', 'name:employee: What is the first name of the employee?']
    
  • 신뢰도 점수는 지원되지 않습니다.

다음 예제에서는 입력 텍스트에서 정보를 추출합니다.

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?'}
);
Copy

다음 예제에서는 입력 텍스트에서 정보를 추출하고 구문 분석합니다.

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?"}')
);
Copy

다음 예제에서는 document.pdf 파일에서 정보를 추출합니다.

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?']]
);
Copy

다음 예제에서는 스테이지의 모든 파일에서 정보를 추출합니다.

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);
Copy