Skip to content
Handbook navigation

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.

Unlock execution

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

AxisClassificationEvidence
FieldArtificial Intelligence and NLPThe system infers and generates language outputs
Methodretrieval, deterministic policy checks, and Deep Learning inferenceDifferent components produce behavior differently
Model familyLLM Foundation ModelA broadly pretrained language model is adapted at request time
Capabilityretrieve, generate, validate, and abstainThese are observable system behaviors
Applicationemployee policy assistantThe application includes identity, sources, UI, workflow, and telemetry
Authorityinform and recommendIt 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,
  • decide or execute authority 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:

  1. deterministic payroll validation,
  2. a symbolic medical expert system,
  3. a credit-risk model,
  4. an enterprise policy assistant,
  5. 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,
  • recommend rather than execute authority.

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.

Python — What is Artificial Intelligence? | KnowledgeOS