Snowflake Document Processing · Topic 7 of 7

Cost, Best Practices and Fine-Tuning arctic-extract Models

Control document processing cost and accuracy: page and token billing, warehouse size, page filters, scores, and fine-tuning arctic-extract for AI_EXTRACT.

  • 5 min
In a nutshell
  • AI_PARSE_DOCUMENT bills per page. AI_EXTRACT counts 970 tokens per page plus prompt and output tokens.
  • Page filters, parse once, streams and a warehouse no larger than MEDIUM reduce cost.
  • Fine-tune with SNOWFLAKE.CORTEX.FINETUNE, a Dataset (file, prompt, response) and base model arctic-extract.

What it is

Document functions bill by the work done on pages and tokens, so cost control means processing fewer pages, fewer times. Accuracy control means better questions first, and when questions are not enough, fine-tuning the arctic-extract model that AI_EXTRACT uses so it learns your document types.

Control costfilter pages, parse oncethenImprove promptsclear questionsthenUse scoresfind weak answersthenFine tune arctic extractlabeled documents

How it works

What drives cost

FunctionHow usage is counted
AI_PARSE_DOCUMENTPDF and DOCX are billed per page. An image file (JPEG, JPG, PNG, TIF, TIFF) counts as one page. HTML and TXT count each 3,000 character chunk as one page
AI_EXTRACTPages per document, input prompt tokens and output tokens. Each page of a paged format counts as 970 tokens, and each image file is one page

Image extraction in LAYOUT mode adds no charge, and requesting scores in AI_EXTRACT adds no cost. This page does not list prices, so remember the units, not the rates.

Cost and best practice checklist

  • Select only the pages you need. Use page_filter or FL_FILTER_PAGES, so you are billed for fewer pages.
  • Parse once, extract many times. Store the parsed Markdown in a table so later questions do not pay to parse again.
  • Process only new files. Use a stream on the stage so a pipeline never reprocesses old documents.
  • Use a warehouse no larger than MEDIUM. Larger sizes do not make these functions faster, so they only add waste.
  • Pick the mode that fits. OCR is for plain text. Use LAYOUT when structure matters, and AGENTIC (preview) only when visuals matter.
  • Mind the question budget. A table question counts as 10 entity questions in AI_EXTRACT, so batch questions sensibly.
  • Use scores for review. Send only low scoring answers to a person instead of checking everything.
  • Enable cross-region inference when needed. It raises the AI_EXTRACT page cap from 125 to 1,000 and keeps one bad file from failing the whole statement.
Exam tip

If a scenario asks for the lowest cost way to extract five fields from page 1 of 400 page contracts, the answer is AI_EXTRACT with a page filter for page 1, not parsing every page first.

Why fine-tune arctic-extract

Zero shot extraction works for many documents. If your documents are unusual (custom forms, dense tables, domain wording) and good questions still give inconsistent answers, fine-tuning adapts the model to your documents. The result is a model you call from AI_EXTRACT.

How fine-tuning works

You train through the Cortex fine-tuning function with a Snowflake Dataset.

  1. Put the documents on an internal stage or a named external stage.
  2. Build a table with a FILE column, a prompt column and a response column.
  3. Create a Dataset from it, add a version, and use FL_GET_STAGE and FL_GET_RELATIVE_PATH for the file path.
  4. Start the job:
SELECT SNOWFLAKE.CORTEX.FINETUNE(
  'CREATE', 'docs.public.invoice_model', 'arctic-extract',
  'snow://dataset/docs.public.invoice_ds/versions/v1'
);

Other modes include 'DESCRIBE' for job properties, plus SHOW and CANCEL.

Documentson stagelabeled inDatasetfile, prompt, responseFINETUNEFine tuned modelschema objectmodel argumentAI_EXTRACT

Dataset rules

ColumnContent
FilePath to the document on a stage
PromptJSON of key and question pairs, in any format AI_EXTRACT accepts as responseFormat
ResponseJSON object of key and answer pairs
  • Keys in prompt and response must match.
  • Include a row for every question, even if the default answer is already right.
  • Use None as the response when the document does not contain the answer.
  • Snowflake recommends at least 20 documents.

Limits

  • Up to 100 unique entity questions and 10 table questions in the training data.
  • File formats: PDF, PNG, JPG and JPEG, TIFF and TIF.
  • Pages per document: 64 in AWS US West 2 and AWS Europe Central 1, 125 in Azure East US 2.
  • Up to 1,000 unique files per Dataset.
  • Questions multiplied by total pages must be at most 50,000.
  • Client side encrypted stages are not supported.
  • It is incompatible with custom network policies.
  • Generally available in AWS US West 2 (Oregon), AWS Europe Central 1 (Frankfurt) and Azure East US 2 (Virginia).
  • max_epochs is an optional option from 2 to 10. If omitted, the system chooses.

Privileges

The user needs the SNOWFLAKE.CORTEX_USER database role, granted by ACCOUNTADMIN. Training also needs USAGE or OWNERSHIP on the Dataset's database and schema, READ or OWNERSHIP on the stage with the documents, and USAGE plus CREATE MODEL on the schema that receives the model. For inference you need OWNERSHIP, USAGE or READ on the model.

Using the model

SELECT AI_EXTRACT(
  model => 'docs.public.invoice_model',
  file  => TO_FILE('@docs.public.inbox', 'inv_0042.pdf')
);

Without responseFormat the model uses the questions it was trained on. Passing responseFormat overrides them. Scores also work with fine-tuned models.

Watch out

Fine-tuning is a last step, not a first one. Fix the wording of questions and the page selection first, because tuning needs labeled data and effort.

Common mistakes

Fine-tuning before improving prompts. Better questions are cheaper and faster.

Training on too few documents. Snowflake recommends at least 20.

Mismatched keys between prompt and response. They must be identical.

Using a client side encrypted stage or a custom network policy. Both are unsupported for training.

Paying to parse again. Store parsed output instead.

Using a large warehouse. MEDIUM is enough.

What to remember for the exam

  • AI_PARSE_DOCUMENT bills per page. AI_EXTRACT counts 970 tokens per page plus prompt and output tokens.
  • Page filters, parse once, streams and a warehouse no larger than MEDIUM reduce cost.
  • Fine-tune with SNOWFLAKE.CORTEX.FINETUNE, a Dataset (file, prompt, response) and base model arctic-extract.
  • At least 20 documents recommended, up to 100 entity and 10 table questions.
  • Call the result with the model argument of AI_EXTRACT. responseFormat overrides the trained questions.

Check yourself

  • How do you cut cost when only page 1 of each contract matters?

    Select that page with a page filter or FL_FILTER_PAGES so only it is processed and billed.

  • What three columns does an arctic-extract training Dataset need?

    File, Prompt and Response.

  • How do you run a fine-tuned model?

    Call AI_EXTRACT with the model argument set to the model's fully qualified name.

Topic 7 of 7 in Snowflake Document Processing

Test yourself on Snowflake Document Processing

The full Snowflake GES-C02 question bank has 585 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.