문서 처리 AI_COMPLETE

Cortex AI_COMPLETE 함수는 PDF, Microsoft Word 및 기타 문서 파일 형식으로 저장된 데이터를 이해할 수 있는 범용 AI 함수입니다. AI_COMPLETE을 사용하여 다음과 같은 다양한 문서 데이터 추출 작업을 수행할 수 있습니다.

  • 그래프와 차트의 데이터를 사용하여 질문에 답변하기

  • 차트와 문서 텍스트 간의 관계 찾기

  • 특정 질문의 문서 내용 요약하기

  • 문서에서 엔터티 추출하기

다른 :doc:`문서 처리 AI 함수 <ai-documents>`에 비해 AI_COMPLETE의 장점은 모델을 선택할 수 있다는 점이므로, 특정 문서 처리 작업에 가장 적합한 모델을 사용할 수 있습니다.

AI_COMPLETE으로 문서 처리하기

COMPLETE 함수는 내부 Snowflake 스테이지 또는 외부 스테이지에 저장된 문서 파일을 처리합니다. 완성 프롬프트는 단일 문서 또는 여러 문서를 참조할 수 있습니다. 예를 들어, 원래 문서와 번역된 문서를 함수에 대한 입력으로 제공하고 모델에 번역 품질을 평가하라는 메시지를 표시하여 마케팅 자료 번역의 정확성을 비교합니다.

함수를 호출할 때 사용할 모델과 프롬프트를 지정해야 합니다. 프롬프트에는 처리하려는 각 문서에 대한 FILE 오브젝트 참조와 함께 지침이 포함되어야 합니다. 샘플 프롬프트 및 완성 프롬프트는 예제 `_를 참조하고 함수 호출 구문은 :doc:/sql-reference/functions/ai_complete-prompt-object` 섹션을 참조하세요.

입력 요구 사항

AI_COMPLETE는 디지털 기반 문서와 스캔 문서 모두에 최적화되어 있습니다. 다음 테이블은 입력 문서에 대한 제한 사항과 요구 사항을 나열합니다.

지원되는 파일 유형

모든 모델: .txt, .md, .pdf
Claude 모델: .txt, .md, .pdf, .doc, .docx, .xls, .xlsx, .csv, .xhtml

스테이지 암호화

서버 측 암호화:

데이터 타입

FILE 오브젝트

참고

스테이지에서 AI_COMPLETE으로 파일을 처리하는 기능은 현재 사용자 지정 네트워크 정책과 호환되지 않습니다.

다음 예제에서는 AI_COMPLETE을 사용하여 차트 Q&A, 상황에 맞는 문서 요약, 기술 보고서 탐색의 3가지 일반적인 사용 사례에 대한 문서를 처리하는 방법을 보여줍니다.

차트 Q&A 예제

"Breaking the Gridlock" EU 보고서의 제목 페이지

다음 예제에서는 Anthropic의 Claude Opus 4 모델을 사용하여 @docs 스테이지에 저장된 문서 ``hdr2023-24snapshoten.pdf``의 컨텍스트 내에서 차트에 표시된 데이터를 분석합니다.

SELECT AI_COMPLETE(
  MODEL => 'claude-4-opus',
  PROMPT => PROMPT('Compare the distributions of HDI in each group: low HDI group, medium HDI group, high HDI group and very high HDI group visualized in {0}', TO_FILE('@docs', 'hdr2023-24snapshoten.pdf'))
);

응답:

Looking at the document, I can see Figure S.2 on page 6 which shows the recovery of HDI values since the 2020-2021
decline across different HDI groups. The visualization shows:

**Low HDI group**:
- 49% recovered
- 51% did not recover

**Medium HDI group**:
- The document doesn't provide specific recovery percentages for this group in the figure

**High HDI group**:
- The document doesn't provide specific recovery percentages for this group in the figure

**Very high HDI group**:
- 100% recovered (all OECD countries)

The document also provides additional insights about HDI distributions:

1. **Inequality trends** (Figure S.3, page 7): The inequality between very high HDI and low HDI countries has been
   increasing since 2020, reversing a long-term declining trend. The difference in HDI values between these groups
   increased from 0.38 in 2017 to 0.39 in 2020 and is projected to continue rising.

2. **Overall recovery patterns**: The text notes that "every Organisation for Economic Co-operation and Development
   country is projected to have recovered, but only about half of the Least Developed Countries are projected to have
   done so."

3. **Global HDI trajectory**: While the global HDI value is projected to reach a record high in 2023, it remains below
   its pre-2019 trend, suggesting a permanent shift in the development trajectory.

The document emphasizes the highly unequal nature of recovery across HDI groups, with countries in higher HDI
categories showing much stronger recovery rates than those in lower HDI categories.

상황에 맞는 문서 요약의 예제

EU 결의안 1008/2008의 첫 페이지

다음 예제에서는 Anthropic의 Claude Sonnet 4 모델을 사용하여 복잡한 레이아웃의 법률 텍스트 요약을 추출합니다. 문서 ``CELEX_32008R1008_EN_TXT.pdf``는 @docs 스테이지에 저장되며, 프롬프트는 요약 컨텍스트의 범위를 좁힙니다.

SELECT AI_COMPLETE(
  MODEL => 'claude-4-sonnet',
  PROMPT => PROMPT('summarize the changes from the perspective of private aviation {0}', TO_FILE('@docs', 'CELEX_32008R1008_EN_TXT.pdf'))
);

응답:

From a private aviation perspective, this EU Regulation 1008/2008 introduces several significant changes that affect
private operators and business aviation:

## Key Changes Affecting Private Aviation:

### **Operating License Requirements**
- **Stricter financial oversight**: Private operators must demonstrate they can meet financial obligations for 24
  months from start of operations, with enhanced monitoring during the first two years
- **Simplified requirements for smaller operators**: Aircraft under 10 tonnes MTOM and/or less than 20 seats need
  only demonstrate €100,000 net capital (unless operating scheduled services or exceeding €3 million turnover)

### **Aircraft Registration and Leasing**
- **Flexible registration**: Private operators can register aircraft either in their home Member State or anywhere within the Community

- **Wet lease restrictions**: Stricter limitations on wet leasing aircraft from third countries, requiring prior
  approval and justification based on:
  - Exceptional needs (up to 7 months, renewable once)
  - Seasonal capacity requirements
  - Operational difficulties when EU-registered aircraft unavailable
- **Safety equivalence**: All third-country leased aircraft must meet equivalent safety standards to EU requirements.

### **Enhanced Supervision**

- **Unified oversight**: The same Member State authority now oversees both the Air Operator Certificate (AOC) and
  operating license, improving efficiency for operators with bases in multiple countries
- **Regular assessments**: Mandatory financial reviews, particularly after two years of operation and when potential
  problems are suspected

### **Insurance Requirements**
- **Extended coverage**: Insurance requirements now explicitly include mail liability coverage in addition to
  passengers, cargo, and third parties

### **Operational Flexibility**
- **Code-sharing freedom**: Private operators can more freely enter into code-share arrangements on intra-Community
  routes and routes to third countries
- **Pricing freedom**: Complete freedom to set fares and rates for intra-Community services

### **Administrative Streamlining**
- **Consolidated regulation**: The three separate regulations are now combined into one comprehensive framework,
  simplifying compliance
- **Reduced bureaucracy**: Member States cannot require documents already provided to licensing authorities

These changes generally **liberalize** private aviation operations within the EU while **strengthening** financial
and safety oversight, creating a more integrated and competitive market for private operators.

기술 보고서 탐색

75mm 포 사양 소책자의 첫 페이지

다음 예제에서는 Gemini 3 Pro 모델을 사용하여 기술 보고서의 다이어그램에 표시된 피해자 데이터를 분석합니다. 문서 75mm-M3-spec-booklet-MK-VI.pdf``는 ``@docs 스테이지에 저장됩니다.

SELECT AI_COMPLETE(
  MODEL => 'gemini-3-pro',
  PROMPT => PROMPT('explain findings from figures 69-73 of {0}', TO_FILE('@docs', '75mm-M3-spec-booklet-MK-VI.pdf'))
);

응답:

Based on the provided document, specifically **page 4**, here is an explanation of the findings from Figures 69
through 73. These figures illustrate the fragmentation patterns and effectiveness of the **75-mm Shell, H.E., M48**
when fired from an M3 Gun. They visualize how dangerous the shell is to personnel (casualties) and equipment
(perforation of mild steel) at different burst heights and orientations.

지원되는 모델 및 제한 사항

Snowflake Cortex에서 사용 가능한 모든 모델에는 모델의 *컨텍스트 윈도우*로 알려진 총 입력 및 출력 토큰 수에 제한이 있습니다. 컨텍스트 윈도우 크기는 토큰 단위로 측정됩니다. 컨텍스트 윈도우 제한을 초과하는 입력은 오류를 발생시킵니다.

텍스트 모델의 경우 토큰은 일반적으로 약 4자의 텍스트를 나타냅니다. 제한에 해당하는 단어 수는 토큰에 제공된 컨텍스트 윈도우보다 약간 적습니다. 이미지 모델의 경우 문서당 토큰 수는 비전 모델의 아키텍처에 따라 다릅니다. 프롬프트 내의 토큰(예: “이 문서 요약:”)도 모델의 컨텍스트 윈도우에 기여합니다.

모델

컨텍스트 윈도우(토큰)

파일 유형

파일 크기

프롬프트당 문서 수

gemini-3-pro

1,000,000

.pdf, .txt, .md

10MB, 최대 900페이지

20

claude-3-7-sonnet

200,000

.txt, .md, .pdf, .doc, .docx, .xls, .xlsx, .csv, .xhtml

4.5MB

5

claude-4-sonnet

200,000

.txt, .md, .pdf, .doc, .docx, .xls, .xlsx, .csv, .xhtml

4.5MB

5

claude-4-opus

200,000

.txt, .md, .pdf, .doc, .docx, .xls, .xlsx, .csv, .xhtml

4.5MB

5

claude-haiku-4-5

200,000

.txt, .md, .pdf, .doc, .docx, .xls, .xlsx, .csv, .xhtml

4.5MB

5

claude-sonnet-4-5

200,000

.txt, .md, .pdf, .doc, .docx, .xls, .xlsx, .csv, .xhtml

4.5MB

5

claude-opus-4-5

200,000

.txt, .md, .pdf, .doc, .docx, .xls, .xlsx, .csv, .xhtml

4.5MB

5

액세스 제어 요구 사항

AI_COMPLETE 함수를 사용하려면 ACCOUNTADMIN 역할을 가진 사용자가 함수를 호출할 사용자에게 SNOWFLAKE.CORTEX_USER 데이터베이스 역할을 부여해야 합니다. 자세한 내용은 Cortex LLM 권한 항목을 참조하십시오.

사용자에게 처리 중인 스테이지 및 파일에 대한 READ 액세스 권한도 있어야 합니다.

비용 고려 사항

비용은 파일 크기가 아닌 :ref:`처리된 토큰 <label-cortex_llm_cost_considerations>`의 총 개수에 따라 결정됩니다. 문서가 업로드되면 텍스트 내용이 추출되어 토큰으로 변환됩니다. 시각적 페이지 세그먼트(이미지)도 토큰으로 변환됩니다. 청구는 입력 토큰(모델이 읽는 텍스트와 이미지)과 출력 토큰(모델이 생성하는 텍스트)의 합계를 기반으로 합니다.

실제 토큰 수는 모델의 기본 아키텍처와 문서 구성 및 구조에 따라 다릅니다. 밀집된 테이블, 스프레드시트, 정형 데이터, 코드, 반복되는 머리글 및 바닥글 또는 OCR 파생 텍스트와 같은 내용은 토큰 볼륨을 증가시킬 수 있습니다. 반대로, 추출 가능한 텍스트가 최소화된 이미지가 많거나 슬라이드 기반 문서의 경우 토큰 수가 감소할 수 있습니다.

참고

AI_COUNT_TOKENS 함수는 현재 다중모달 모델에서 문서 입력을 지원하지 않습니다.

모델 선택하기

MMLongBench-Doc 벤치마크는 페이지 간 정보 검색을 포함하여 모델의 다중모달 및 긴 컨텍스트 이해 능력을 평가하는 데 사용됩니다.

모델

MMLongBench-Doc 점수

claude-3-5-sonnet

46.8%

claude-3-7-sonnet

52.8%

claude-4-sonnet

50.2%

claude-4-opus

53.0%

claude-haiku-4-5

48.9%

claude-sonnet-4-5

61.4%

claude-opus-4-5

63.8%

claude-sonnet-4-6

62.3%

gemini-3-pro

60.5%

리전 가용성

리전 가용성 섹션을 참조하십시오.

오류 조건

Snowflake Cortex AI_COMPLETE는 다음과 같은 오류 메시지를 표시할 수 있습니다.

메시지

설명

_COMPLETE_WITH_PROMPT_HISTORY_LLM$V1에서 원격 서비스 오류 발생: 400 ‘“invalid request parameters: unsupported document content type: application/vnd.ms-excel”

지원되지 않는 형식의 선택한 파일(이 예제에서는 Microsoft Excel 파일)입니다. Claude 모델만 Excel 파일을 지원합니다.

다음의 원격 서비스 오류로 인해 외부 함수 _COMPLETE_WITH_PROMPT_HISTORY_LLM$V1에 대한 요청 실패: 400 ‘“invalid request parameters: File data exceeds the limit of 10.00 MB for file prefix/file.pdf”

파일 크기가 제한(이 예제에서는 10MB)을 초과합니다.

원격 파일 @docs/file.pdf’를 찾을 수 없습니다. 몇 가지 잠재적인 원인이 있습니다. 파일이 존재하지 않을 수 있습니다. 필수 자격 증명이 누락되었거나 유효하지 않을 수 있습니다. 복사 명령을 실행하는 경우 자동 제거 옵션을 사용하여 파일이 로드 중이거나 파일이 두 개의 다른 테이블에 동시에 로드되고 있지 않을 때 파일이 삭제되지 않도록 하세요.

파일 이름에 오류가 있을 수 있습니다. 파일 이름이 대소문자를 구분합니다. 또는 파일이 삭제되었을 수 있습니다.

보안 오브젝트에 오류 발생

스테이지가 존재하지 않음을 나타낼 수 있습니다. 스테이지 이름을 확인하고 스테이지가 존재하고 액세스할 수 있는지 확인합니다. 스테이지 이름의 시작 부분에 at 기호(@)를 사용해야 합니다. 스테이지가 서버 측 암호화를 사용하는지 확인합니다.

다음의 원격 서비스 오류로 인해 외부 함수 COMPLETE$V6에 대한 요청 실패: 400 ‘“model "model_name" does not support given modality”

요청에 제공된 모델이 문서 또는 텍스트 모달리티를 지원하지 않습니다.

외부 함수 _COMPLETE_WITH_PROMPT 에 대한 요청이 원격 서비스 오류로 인해 실패: 500 ‘“internal error”

서버 측에서 요청을 처리하는 데 문제가 있습니다. 파일이 손상되거나 잘린 경우일 수 있습니다.