Skip to main content

Overview

Build a structured data extraction model from PDFs:
  • Upload PDFs to generate synthetic training data
  • Use question/answer templates to enforce JSON output format
  • Extract fields like date, amount, currency, business name, and location
  • Create snapshots, get recommendations, and launch fine-tuning
Export your Prem API key as API_KEY before running any script. Place your invoice PDF files in the same directory or update the PDF_FILES array.
1

Set PDF file paths

Define the PDF files you want to process. Make sure these files exist in your working directory.
2

Generate dataset from PDFs

Create a project and generate synthetic Q&A pairs from PDF files. See Create Project and Create Synthetic Dataset for details.
3

Wait for generation

Poll the dataset status until generation completes. See Get Dataset for details.
4

Create snapshot and get recommendations

Create a snapshot and generate model recommendations. See Create Snapshot, Generate Recommendations, and Get Recommendations for details.
5

Start fine-tuning

Launch a fine-tuning job with recommended experiments. See Create Fine-Tuning Job for details.
6

Monitor job

Monitor fine-tuning job progress and status. See Get Fine-Tuning Job for details.

Full Example