Chapter 2 · Python
Python: What is Artificial Intelligence?
Run this example
Edit and run the python example
Change the source and run it here. Use the output panel to compare your result with the expected highlights below.
Output
Run the code to see output here.
Example 1 - Classify an Enterprise Policy Assistant
Scenario
An employee asks, "Can I work from another country for six weeks?"
The application authenticates the employee, retrieves policy sections the employee is authorized to view, asks an LLM to draft an answer, checks that each policy claim has a citation, and routes exceptions to Global Mobility.
Six-Axis Classification
| Axis | Classification | Evidence |
|---|---|---|
| Field | Artificial Intelligence and NLP | The system infers and generates language outputs |
| Method | retrieval, deterministic policy checks, and Deep Learning inference | Different components produce behavior differently |
| Model family | LLM Foundation Model | A broadly pretrained language model is adapted at request time |
| Capability | retrieve, generate, validate, and abstain | These are observable system behaviors |
| Application | employee policy assistant | The application includes identity, sources, UI, workflow, and telemetry |
| Authority | inform and recommend | It may not approve an employment or tax exception |
Model Boundary
The LLM receives a question and authorized evidence, then proposes text. It does not authenticate the employee, decide document permissions, establish which policy version is authoritative, or approve an exception.
Failure Contract
The system must abstain or escalate when:
- no authoritative source is retrieved,
- sources conflict,
- the requested policy is outside the employee's access rights,
- a citation does not support the generated claim,
- the user asks for an exception or binding decision,
- the model or retrieval service is unavailable.
Architect Decision
Treat citations as structured evidence, not decoration. Store source ID, version, effective date, owner, and access decision with the trace. A response that cannot be reconstructed from authorized evidence is not auditable.
What This Teaches
The same system is simultaneously an AI application, an LLM-backed product, a retrieval workflow, and a controlled recommendation service. Those statements do not conflict because they describe different axes.
Example 2 - Runnable AI System Classifier
Objective
Use a transparent rule engine to classify several systems on independent axes and reject contradictory descriptions.
The program does not pretend to discover whether arbitrary software is AI. It shows what evidence an engineer must supply and which implications can be checked mechanically.
What the Program Validates
- an LLM claim requires a learned Deep Learning mechanism,
- a Foundation Model claim requires broad pretraining and reuse,
decideorexecuteauthority requires explicit controls,- generation is a capability rather than a model family,
- unresolved evidence is reported instead of silently forced into a category.
Verified Output
The examples include:
- deterministic payroll validation,
- a symbolic medical expert system,
- a credit-risk model,
- an enterprise policy assistant,
- an intentionally contradictory profile.
The final profile must report validation errors. That failure is part of the example: a taxonomy tool should expose unsupported claims rather than make every product look like valid AI.
Engineering Exercise
Add a content-moderation workflow with:
- a learned classifier,
- deterministic legal-policy overrides,
- human review for uncertain cases,
recommendrather thanexecuteauthority.
Then add one invalid version that grants execution authority without a review, fallback, or rollback control. The validator should reject it.
Production Extension
In a real architecture review, serialize this profile as an ADR attachment and link every asserted capability to evaluation evidence. The classifier is not a governance system; it is a small executable contract that makes ambiguous language visible during design review.