Finatext Tech Blog
📄

Snowflakeにおける非構造化データを構造化データに変える選択肢

に公開
2026/05/29
Snowflake関連記事の記事です

はじめに

こんにちは。ナウキャストでデータエンジニア/LLMエンジニアとして頑張っているTakumiです。

Snowflakeでは、非構造化データ(PDF等)から情報を抽出するCortex AI Functionsが続けてPublic Preview・GAとなりました。2026年時点では、新規・既存パイプラインとも AI_EXTRACT と AI_PARSE_DOCUMENT を中心に整理するのが正しいです。

かつて Document AI として提供されていた Snowsight 上のモデルビルド UI と <model_build_name>!PREDICT は、2026-03-16 に廃止されています。Snowflake は新規・既存パイプラインの移行先として AI_EXTRACT を明示しており、全文テキスト化・RAG前処理には AI_PARSE_DOCUMENT を使う流れが定着しています。

この記事では、現行の主役である AI_EXTRACT / AI_PARSE_DOCUMENT の使い分け、旧 Document AI からの移行、コスト、本番運用の観点をお伝えします。

この記事でわかること

  • AI_EXTRACT / AI_PARSE_DOCUMENT (OCR / LAYOUT) の概要・制限・SQL例
  • 旧 Document AI からの移行の考え方
  • ユースケース別の使い分け
  • 現行単価に基づくコスト試算
  • 本番運用(コスト監視・権限・前処理の分岐)

機能概要

まず、現行で選ぶべき機能の比較表です。旧 Document AI は「移行・過去互換」として分離しています。

項目 AI_EXTRACT AI_PARSE_DOCUMENT OCR AI_PARSE_DOCUMENT LAYOUT 旧Document AI
位置づけ 構造化抽出の本命 高速な全文テキスト化 レイアウト保持つきMarkdown化 旧UI/モデルビルド型の抽出機能
主な用途 エンティティ・リスト・テーブル抽出 OCR、全文テキスト化 RAG前処理、表・見出し・階層保持 既存モデルの移行・過去互換
新規利用の推奨 推奨 推奨 推奨 非推奨
入力 text または FILE FILE FILE 旧 Document AI UI / Model Build
SQL例 AI_EXTRACT(file => TO_FILE(...), responseFormat => ...) AI_PARSE_DOCUMENT(TO_FILE(...), {'mode':'OCR'}) AI_PARSE_DOCUMENT(TO_FILE(...), {'mode':'LAYOUT'}) 旧 <model>!PREDICT は廃止済み
最大ファイルサイズ 100MB未満 100MB 100MB 旧UI前提は廃止済み
最大ページ 125ページ 2,000ページ 2,000ページ 旧UI/PREDICTは廃止済み
日本語 Japanese対応 公式対応言語一覧にJapaneseなし 公式対応言語一覧にJapaneseなし 旧Document AIは日本語非対応だった
コスト(目安) 5.00 credits / 1M tokens 0.5 credits / 1,000 pages 3.33 credits / 1,000 pages 8 credits / hour of compute(新規比較の主役にしない)

旧Document AIからAI_EXTRACTへの移行

Document AI は、Arctic-TILT を使ってドキュメントからデータを抽出する機能として提供されていました。Snowsight でモデルを作成し、Fine-tuning した上で <model_build_name>!PREDICT で推論するワークフローが中心でした。

2026-03-16 以降、Document AI UI と <model>!PREDICT は利用できません。 新規に Document AI UI でモデルをビルドする前提の設計は使えません。

既存利用者向けには、Model Registry へ移行済みの fine-tuned arctic-extract モデルを、AI_EXTRACT の model => パラメータで継続利用できる場合があります。移行状況はアカウントごとに異なるため、Document AI decommission と移行ガイドを確認してください。

AI_EXTRACT

AI_EXTRACT は、Document AI の後継として位置づけられる 構造化抽出の本命 です。PDF・画像・Office文書などの FILE 入力に対応し、JSON Schema 形式の responseFormat でエンティティ・リスト・テーブルを 1回の呼び出し で抽出できます。

対応ファイル形式: PDF, PNG, PPT/PPTX, EML, DOC/DOCX, JPEG/JPG, HTML, TXT, TIF/TIFF, BMP, GIF, WEBP, MD

制限: ファイルサイズ 100MB未満、最大 125ページ

請求書のような定型フォーマットから項目を抜く例です。scores => TRUE を付けると、抽出値ごとの信頼度スコアが返り、低スコアだけ人手確認に回す設計が可能です。

SELECT AI_EXTRACT(
  file => TO_FILE('@db.schema.files', 'invoice.pdf'),
  responseFormat => {
    'schema': {
      'type': 'object',
      'properties': {
        'invoice_number': {
          'description': '請求書番号',
          'type': 'string'
        },
        'vendor_name': {
          'description': '請求元の会社名',
          'type': 'string'
        },
        'line_items': {
          'description': '明細テーブル',
          'type': 'object',
          'column_ordering': ['item_name', 'quantity', 'amount'],
          'properties': {
            'item_name': {
              'description': '品目名',
              'type': 'array'
            },
            'quantity': {
              'description': '数量',
              'type': 'array'
            },
            'amount': {
              'description': '金額',
              'type': 'array'
            }
          }
        }
      }
    }
  },
  scores => TRUE
);

Model Registry に移行済みの fine-tuned モデルがある場合は、model => '<model_name>' で推論できます。ただし、新規に Document AI UI でモデルをビルドする前提は廃止済み です。

参考: AI_EXTRACT

小話

AI_EXTRACT は情報抽出だけがユースケースではありません。文書種別の分類など、メタデータ付与にも使えます。

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

上記のように、Cortex Search Service 構築時のメタデータ付与パイプラインにも組み込めます。

AI_PARSE_DOCUMENT

AI_PARSE_DOCUMENT は、ドキュメントを読み込んでテキスト内容を抽出し、結果をJSON形式で返します。OCR モードと LAYOUT モードをサポートしています。

  • OCRモード: プレーンテキストの高速抽出。スキャン文書やテキスト中心の文書向け。
  • LAYOUTモード: Markdown で表・見出し・階層を保持。RAG前処理や複雑な文書の全文理解向け(複雑な文書では推奨される選択肢)。

page_split、page_filter、extract_images も指定可能です。LAYOUT + extract_images: true では、埋め込み画像を最大50個まで抽出でき(追加コストなし)、画像内の意味理解は別途 AI_EXTRACT / AI_COMPLETE 等と組み合わせます。

対応ファイル形式: PDF, PPTX, DOCX, JPEG/JPG, PNG, TIFF/TIF, HTML, TXT

制限: 最大ファイルサイズ 100MB、最大 2,000ページ(2026-04-30 の更新で OCR/LAYOUT ともに拡大)

構文は TO_FILE で FILE オブジェクトを渡します。

SELECT AI_PARSE_DOCUMENT(
  TO_FILE('@DOC_AI_DB.DOC_AI_SCHEMA.AI_EXTRACT_STG', 'sample_pdf.pdf'),
  {'mode': 'OCR', 'page_split': TRUE}
) AS multipage;

旧 SNOWFLAKE.CORTEX.PARSE_DOCUMENT('@stage', 'file.pdf', {...}) は後方互換のため残っていますが、新規用途では AI_PARSE_DOCUMENT を使う よう Snowflake が明記しており、旧関数は 2026年末に非推奨化予定 です。

参考: AI_PARSE_DOCUMENT / PARSE_DOCUMENT (legacy) / 2,000 pages limit

adobeのサンプルpdfを使って、実行結果のイメージを見てみましょう。

OCR

SELECT AI_PARSE_DOCUMENT(
  TO_FILE('@DOC_AI_DB.DOC_AI_SCHEMA.AI_EXTRACT_STG', 'sample_pdf.pdf'),
  {'mode': 'OCR', 'page_split': TRUE}
) AS multipage;
OCRモードの実行結果
{"metadata":{"pageCount":4},"pages":[{"content":"PDF BOOKMARK SAMPLE\nSample Date: May 2001\nPrepared by: Accelio Present Applied Technology\nCreated and Tested Using: • Accelio Present Central 5.4\n• Accelio Present Output Designer 5.4\nFeatures Demonstrated: • Primary bookmarks in a PDF file.\n• Secondary bookmarks in a PDF file.\nOverview\nThis sample consists of a simple form containing four distinct fields. The data file contains eight\nseparate records.\nBy default, the data file will produce a PDF file containing eight separate pages. The selective\nuse of the bookmark file will produce the same PDF with a separate pane containing\nbookmarks. This screenshot of the sample output shows a PDF file with bookmarks.\nAcrobat Reader - [ap_bookmark.pdf]\n) File Edit Document View Window Help\nBookmarks \\Thumbnails E.. Imvoices by Date\n2000-01-1 1 2000-01-2 1 2000-01-3\n2000-01-4 2000-01-5 Date 2000-01-1 2000-01-6\n2000-01-7 Description Description for item # 1 2000-01-8\nType TYPE1\nAmount 11.00\nThe left pane displays the available bookmarks for this PDF. You may need to enable the\ndisplay of bookmarks in Adobe Acrobat Reader by clicking Window > Show Bookmarks.\nSelecting a date from the left pane displays the corresponding page within the document.\nNote that the index has been sorted according to the specification in the bookmark file, and that\npages within the file are created according to the original order in the data file.\nPDF Bookmark Sample Page 1 of 4","index":0},{"content":"Sample Data File Sample Bookmark File\n^reformat trunc [invoices] ^symbolset WINLATIN1 Invoices by Date=0 ^field trans_date trans_date=1,A 2000-01-1 [type] ^field description Invoices by Item Type=0 Description for item #1 trans_type=1,A ^field trans_type [amount] TYPE1 Invoices by Transaction Amount=0 ^field trans_amount trans_amount=1,D 11.00 ^page 1 ^field trans_date 2000-01-2 ^field description Description for item #2 ^field trans_type TYPE2 ^field trans_amount 11.00 ^page 1 ^field trans_date 2000-01-3 ^field description Description for item #3 ^field trans_type TYPE3\nThe example bookmark file includes three distinct sections:\n• Invoices sorted, ascending, by date.\n• Invoices sorted, ascending, by item type.\n• Invoices sorted, descending, by transaction amount.\nPDF Bookmark Sample Page 2 of 4","index":1},{"content":"Sample Files\nThis sample package contains:\nFilename Description\nap_bookmark.IFD The template design.\nap_bookmark.mdf The template targeted for PDF output.\nap_bookmark.dat A sample data file in DAT format.\nap_bookmark.bmk A sample bookmark file.\nap_bookmark.pdf Sample PDF output.\nap_bookmark_doc.pdf A document describing the sample.\nDeploying the Sample\nTo deploy this sample in your environment:\n1. Open the template design ap_bookmark.IFD in Output Designer and recompile the\ntemplate for the appropriate presentment target.\n2. Modify the -z option in the ^job command in the data file ap_bookmark.dat to:\n• Identify the target output device.\n• Identify the bookmark file using the -abmk command.\n• Identify the section for which to generate bookmarks, if desired, using the -abms\ncommand.\nFor example,\nTo bookmark by … Use the command line parameter …\nInvoices -abmkap_bookmark.bmk -abmsinvoices\nType -abmkap_bookmark.bmk -abmstype\nAmount -abmkap_bookmark.bmk -abmsamount\nPDF Bookmark Sample Page 3 of 4","index":2},{"content":"3. Place the accompanying files in directories consistent with your implementation:\n• Place ap_bookmark.IFD in the Designs subdirectory for Output Designer.\n• Place ap_bookmark.mdf in the forms subdirectory accessible to Central.\n• Place ap_bookmark.bmk in an addressable directory.\nRunning the Sample\n• To run this sample, place ap_bookmark.dat in the collector directory scanned by Central.\nPDF Bookmark Sample Page 4 of 4","index":3}]}

4ページのPDFで約1.4秒。大量PDFのパイプラインでも現実的な時間でしょう。

LAYOUT

SELECT AI_PARSE_DOCUMENT(
  TO_FILE('@DOC_AI_DB.DOC_AI_SCHEMA.AI_EXTRACT_STG', 'sample_pdf.pdf'),
  {'mode': 'LAYOUT', 'page_split': TRUE}
) AS multipage;
LAYOUTモードの実行結果
{"metadata":{"pageCount":4},"pages":[{"content":"# ACCELIO.\n\n## PDF Bookmark Sample\n\n|  Sample Date: | May 2001  |\n| --- | --- |\n|  Prepared by: | Accelio Present Applied Technology  |\n|  Created and Tested Using: | - Accelio Present Central 5.4  |\n|   | - Accelio Present Output Designer 5.4  |\n|  Features Demonstrated: | - Primary bookmarks in a PDF file.  |\n|   | - Secondary bookmarks in a PDF file.  |\n\n## Overview\n\nThis sample consists of a simple form containing four distinct fields. The data file contains eight separate records.\n\nBy default, the data file will produce a PDF file containing eight separate pages. The selective use of the bookmark file will produce the same PDF with a separate pane containing bookmarks. This screenshot of the sample output shows a PDF file with bookmarks.\n\n![img-0.jpeg](img-0.jpeg)\n\nThe left pane displays the available bookmarks for this PDF. You may need to enable the display of bookmarks in Adobe® Acrobat® Reader by clicking **Window > Show Bookmarks**. Selecting a date from the left pane displays the corresponding page within the document.\n\nNote that the index has been sorted according to the specification in the bookmark file, and that pages within the file are created according to the original order in the data file.","index":0},{"content":"# $\\square$ \n\n## ACCELIO.\n\n## Sample Data File\n\n^reformat trunc\n^symbolset WINLATIN1\n^field trans_date\n2000-01-1\n^field description\nDescription for item \\#1\n^field trans_type\nTYPE1\n^field trans_amount\n11.00\n^page 1\n^field trans_date\n2000-01-2\n^field description\nDescription for item \\#2\n^field trans_type\nTYPE2\n^field trans_amount\n11.00\n^page 1\n^field trans_date\n2000-01-3\n^field description\nDescription for item \\#3\n^field trans_type\nTYPE3\n\n## Sample Bookmark File\n\n[invoices]\nInvoices by Date $=0$\ntrans_date=1,A\n[type]\nInvoices by Item Type=0\ntrans_type=1,A\n[amount]\nInvoices by Transaction Amount=0\ntrans_amount=1,D\n\nThe example bookmark file includes three distinct sections:\n\n- Invoices sorted, ascending, by date.\n- Invoices sorted, ascending, by item type.\n- Invoices sorted, descending, by transaction amount.","index":1},{"content":"# $\\square$ \n\n## ACCELIO.\n\n## Sample Files\n\nThis sample package contains:\n\n| Filename | Description |\n| :-- | :-- |\n| ap_bookmark.IFD | The template design. |\n| ap_bookmark.mdf | The template targeted for PDF output. |\n| ap_bookmark.dat | A sample data file in DAT format. |\n| ap_bookmark.bmk | A sample bookmark file. |\n| ap_bookmark.pdf | Sample PDF output. |\n| ap_bookmark_doc.pdf | A document describing the sample. |\n\n## Deploying the Sample\n\nTo deploy this sample in your environment:\n\n1. Open the template design ap_bookmark.IFD in Output Designer and recompile the template for the appropriate presentment target.\n2. Modify the -z option in the ^job command in the data file ap_bookmark.dat to:\n\n- Identify the target output device.\n- Identify the bookmark file using the -abmk command.\n- Identify the section for which to generate bookmarks, if desired, using the -abms command.\n\nFor example,\n\n| To bookmark by $\\ldots$ | Use the command line parameter ... |\n| :-- | :-- |\n| Invoices | -abmkap_bookmark.bmk -abmsinvoices |\n| Type | -abmkap_bookmark.bmk -abmstype |\n| Amount | -abmkap_bookmark.bmk -abmsamount |","index":2},{"content":"# ACCELIO. \n\n3. Place the accompanying files in directories consistent with your implementation:\n\n- Place ap_bookmark.IFD in the Designs subdirectory for Output Designer.\n- Place ap_bookmark.mdf in the forms subdirectory accessible to Central.\n- Place ap_bookmark.bmk in an addressable directory.\n\n\n## Running the Sample\n\n- To run this sample, place ap_bookmark.dat in the collector directory scanned by Central.","index":3}]}

Markdown形式で表・見出しが保持されます。同じ4ページで約9秒と、OCRより重いです。LAYOUTでは extract_images: true で埋め込み画像の切り出しも可能です。

ユースケースを考える

各機能の特徴を踏まえた使い分けです。

ユースケース 使う機能 理由
請求書・契約書・申込書から項目を抜きたい AI_EXTRACT 構造化抽出が目的なら主役
表も含めてJSON化したい AI_EXTRACT table extraction を JSON Schema で指定できる
全文をRAGに入れたい AI_PARSE_DOCUMENT LAYOUT Markdownで表・見出し・階層を保持できる
とにかく安くOCRしたい AI_PARSE_DOCUMENT OCR 単価が最も安い
長大なPDFを処理したい AI_PARSE_DOCUMENT 最大2,000ページまで対応
図表・画像を切り出したい AI_PARSE_DOCUMENT LAYOUT + extract_images 埋め込み画像を最大50個まで抽出可能
旧Document AIモデルを継続利用したい AI_EXTRACT + migrated model Model Registry移行済みモデルのみ継続利用可能

AI_EXTRACT

様々な非構造化データから柔軟にデータを抽出したい場合、思いついた項目をJSON Schemaで定義して試したい場合は AI_EXTRACT が適しています。請求書番号・明細テーブル・日付などを1クエリで取り出せます。

旧 Document AI のように Snowsight でモデルをビルドする手間はありませんが、プロンプト設計(responseFormat)の品質が精度とコストに直結します。すべてのページ・すべての項目を一度に投げるより、文書分類・対象ページの絞り込みを先に行うと改善しやすいです。

AI_PARSE_DOCUMENT

文書全体をテキストデータ化したい場合は AI_PARSE_DOCUMENT の出番です。魔改造された Word / Excel 由来のPDFを、LLMが読める形に整える前処理としても有効です。

OCR と LAYOUT の分岐は、「文字列の羅列では後処理(LLMによる理解)が難しくなるか」で判断します。表の行列対応や階層構造が重要なら LAYOUT、スキャン文書の高速テキスト化なら OCR です。

ユースケースまとめ

  • 「特定項目の構造化抽出」 → AI_EXTRACT
  • 「全文テキスト化(安く・速く)」 → AI_PARSE_DOCUMENT (OCR)
  • 「全文テキスト化 & 構造も保存(RAG前処理)」 → AI_PARSE_DOCUMENT (LAYOUT)
  • 「旧Document AIモデルの継続」 → AI_EXTRACT + Model Registry移行済みモデル(新規ビルドは不可)

コスト試算

コスト計算には以下のサンプルPDFを用います。

https://ontheline.trincoll.edu/images/bookdown/sample-local-pdf.pdf

前提条件

  • AWS Tokyo リージョン
  • 契約は Enterprise であること(1 credit = $4.3)

コストテーブル

Credit Consumption Table および Cost considerations for Cortex AI Functions を参照。

現行の主な単価:

  • AI_EXTRACT – arctic-extract: 5.00 credits / 1M tokens
  • AI_EXTRACT – arctic-extract – finetuned: 10 credits / 1M tokens
  • AI_PARSE_DOCUMENT LAYOUT: 3.33 credits / 1,000 pages
  • AI_PARSE_DOCUMENT OCR: 0.5 credits / 1,000 pages

変数定義

pages = 3
page_tokens = 970 * 3 = 2910          # Snowflake課金ロジック: 970 tokens/page
response_format_tokens = 400         # 仮
output_tokens = 200                  # 仮
total_tokens = 2910 + 400 + 200 = 3510

AI_EXTRACT は「ページ数 × 970 tokens」に加え、responseFormat と出力トークンも課金対象です。実測平均トークンだけで見積もるより、970 tokens/page の公式ロジックに合わせる方が正確です。

計算結果サマリー

機能 単価の前提 3ページ時の概算 credits コスト ($)
AI_EXTRACT 5.00 credits / 1M tokens ≈ 0.0176 (3510/1e6×5.00) ≈ $0.076
AI_PARSE_DOCUMENT (OCR) 0.5 credits / 1,000 pages 0.0015 (3/1000×0.5) ≈ $0.006
AI_PARSE_DOCUMENT (LAYOUT) 3.33 credits / 1,000 pages ≈ 0.0100 (3/1000×3.33) ≈ $0.043
旧Document AI 8 credits / hour of compute (ページ比例比較から除外) —

スケールを大きくしてコストを見てみる

同じ様式のファイルを繰り返し処理する前提では、コストはおおむね線形に伸びます。

本番運用で考えるべきこと

1. コスト監視

Cortex AI Functions はトークンまたはページ単位で課金されます。検証時は小さく始めるだけでなく、本番では利用履歴の監視が必須です。

ACCOUNT_USAGE.CORTEX_AI_FUNCTIONS_USAGE_HISTORY(GA)で、関数・モデル・ユーザー・ロール・ウェアハウス・クエリ単位の使用量を追跡できます。月次支出の検知、ユーザー別制限、暴走クエリの検知とキャンセルにも使えます。

参考: Monitor and control Cortex AI Functions cost

2. 低スコア抽出の人手確認

AI_EXTRACT で scores => TRUE を指定すると、抽出値ごとに信頼度スコアが付きます。一定閾値以下の結果だけ人手確認に回す設計が、業務利用では現実的です。

3. 前処理の分岐

全文理解や RAG には AI_PARSE_DOCUMENT、特定項目の抽出には AI_EXTRACT を使います。すべてを AI_EXTRACT に投げないこと。文書分類・ページ抽出・対象項目の絞り込みを先に行うと、精度とコストの両方を改善しやすいです。

4. 権限

Cortex AI Functions の利用には、少なくとも以下が必要です。

  • データベース権限: USE AI FUNCTIONS
  • アカウント権限: CORTEX_USER または AI_FUNCTIONS_USER

本番ロール設計では、必要最小限のロールにこれらを付与してください。

個人的に考えていること

自分としては今回紹介した機能は、本気で日本の魔改造Excelを救えるのではないかと思っています。結合されているセルはPythonによる操作を行うと壊れます。かと言って、全て手作業でテーブルに起こすわけにもいかない。そんな扱いに困っているデータ群を抽出することができます。

これまで活かし切ることのできなかったデータを活用可能にするソリューションの一つとして、期待していますし使いこなせる様に精進します!

ちょっと宣伝

先日行われた Snowflake World Tour Tokyo 2025 で登壇しました。その際の資料で AI_EXTRACT を使ったデータパイプラインを紹介しています(登壇時点では Document AI も含む内容です)。ご覧いただけますと幸いです!

https://speakerdeck.com/kevinrobot34/swt-2025-snowflake-intelligence-and-document-ai

Finatext Tech Blog
Finatext Tech Blog

Discussion