Learn / AI in 5 Minutes

AI in 5 Minutes

Spark treats train→status→expect as language statements — not SDK glue. Orchestrate and gate jobs first, then classify, extract, and pipeline.

Train → status → expect

model train / model build submit via backend "http" to a trainer you run at SPARK_TRAIN_URL. Dry-run shows the job path with fixtures (no GPU). Live needs that service. Assert bound job and status with expect:

model train dataset "examples/fixtures/train/dataset.jsonl" base "fixture-base" out "out/train/job-dry-001" backend "http" -> job
model status "job-dry-001" -> status
expect contains job fixture "examples/fixtures/train/want_accepted.txt"
expect contains status fixture "examples/fixtures/train/want_succeeded.txt"
./spark --dry-run examples/train_eval.spark

See Model training, Playground, or the Build a Model tutorial.

classify — label text

classify Intent { support, sales, spam }
  from "My account is locked and I need help"
  min_confidence 0.7
  -> intent

print intent
./spark --dry-run examples/classify_intent.spark

extract — structured data

extract Person {
  name: string
  age: int
  email?: string
} from "Ada Lovelace was born in 1815"
  fixture "examples/fixtures/extract/person.json" -> person

print person

A field is required unless its name ends in ?. Dry-run validates the JSON in fixture against the schema — a missing required field or a wrong type stops the run with a non-zero exit.

./spark --dry-run examples/extract_person.spark

pipeline — compose steps

let doc "Office printers need regular cleaning."

pipeline {
  ask "Summarize: {doc}" -> summary
  | ask "Translate to Spanish: {summary}" -> es
}

print es

Steps share bindings. Prefix a step with | inside the block.

voice — listen, think, speak (optional)

Speech pipelines are supported but not primary product positioning. See the language reference for full voice surface.

voice {
  listen -> user
  classify Intent { support, sales } from user -> intent
  ask "Reply helpfully to: {user}" -> reply
  speak reply -> "out.wav"
}

Try it interactively

Open Playground to edit classify and pipeline samples and preview dry-run output before installing locally.

See all functions → — browse 100+ language ops and stdlib helpers with search and filters.

Next lesson

Function Catalog — full surface area beyond model, classify, extract, and pipeline. Then Build a Model to submit a train job (or eval helpers + optional model plan).