AI: What Is AI?
AI (Artificial Intelligence) is no longer just a concept from science fiction movies—it has permeated everyday scenarios such as search engines, email filtering, autonomous driving, and code generation. This chapter will help you develop a comprehensive understanding of AI, including its essence, three key elements, and five major branches.
1. What You'll Learn
- The Definition and Nature of AI (From Rule-Driven to Data-Driven)
- The Three Key Elements of AI: Data / Algorithms / Models
- Key Differences Between Traditional Software and AI Software
- The Five Major Branches of AI
- Why Developers Must Understand AI
2. A True Story of a Backend Developer
(1) Pain Point: Confusion Surrounding a Company’s “AI Transformation”
Alice is a backend developer with five years of experience. Her company suddenly mandated that all projects be “AI-enabled.” She didn’t know where to start—what exactly was the connection between ChatGPT, machine learning, deep learning, and large language models? At a technical meeting, a colleague casually mentioned, “We use Transformers for recommendations,” and Alice could only pretend she understood.
(2) AI Solutions
Bob told her, "Don't worry. AI is simply a shift from 'you write the rules' to 'you provide data so the machine can learn the rules.' Let's first get a clear picture of the big picture—AI isn't a single, monolithic thing, but rather a general term for a set of technologies."
▶ Example: Overview of AI Technology Branches (Difficulty: ⭐)
AI (Artificial Intelligence)
├── Machine Learning (ML)
│ ├── Supervised Learning
│ ├── Unsupervised Learning
│ └── Reinforcement Learning
├── Deep Learning (DL)
│ ├── CNN (Computer Vision)
│ ├── RNN / Transformer (NLP)
│ └── GAN / Diffusion (Generation)
├── Natural Language Processing (NLP)
├── Computer Vision (CV)
└── Robotics
(3) Benefits: From Confusion to Clarity
After completing this course, Alice realized that AI isn’t a mystery—it’s a structured tree. The recommendation system she’s working on falls under the “supervised learning → classification” branch, so she can achieve results without needing to understand computer vision.
3. What Is Artificial Intelligence?
Artificial intelligence (AI) is a technology that enables computers to understand, learn, reason, and make decisions. It no longer relies on fixed rules written by humans, but instead automatically discovers patterns in data.
(1) Traditional Programs vs. AI Programs
The key difference between traditional programs and AI programs lies in "who writes the rules":
| Dimension | Traditional Program | AI Program |
|---|---|---|
| Input | Data + Rules | Data + Answers (Labels) |
| Processing | Calculate according to rules | Learn rules from data |
| Output | Result | Rule (Model) + Prediction |
| Modification Method | Manually modify the code | Retrain using new data |
| Analogy | You write a recipe for a chef to follow | You let the chef taste the dish and come up with the recipe on their own |
▶ Example: Traditional Rules vs. AI-Based Spam Detection (Difficulty: ⭐⭐)
# Traditional approach: you write the rules
def is_spam_traditional(email):
"""Rule-based spam detection"""
spam_keywords = ["free", "winner", "click here", "urgent"]
for keyword in spam_keywords:
if keyword in email.lower():
return True
return False
# AI approach: machine learns the rules from data
# from sklearn.naive_bayes import MultinomialNB
# model = MultinomialNB()
# model.fit(training_emails, training_labels) # Machine learns rules
# prediction = model.predict(new_email) # Machine applies learned rules
Output: (Run the example to see the actual output, or refer to the expected-output note in the code comments above.)
(2) The Formal Definition of AI
Different scholars have offered different definitions, but the core idea is the same—to enable machines to exhibit intelligent behavior:
| Source | Definition | Keywords |
|---|---|---|
| Alan Turing (1950) | If a machine's responses make it impossible to distinguish between the machine and a human, then the machine can be considered intelligent | Turing Test |
| John McCarthy (1956) | AI is the ability of machines to perform tasks that typically require human intelligence | Intelligent behavior |
| Stuart Russell | AI research on how to design agents that make rational decisions in their environments | Rational Decision-Making |
4. The Three Key Elements of AI: Data / Algorithms / Models
An AI system consists of three core elements, all of which are essential:
graph TB
A[Data] --> C[Model]
B[Algorithm] --> C
C --> D[Prediction / Decision]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e9
style D fill:#fff3e0
(1) Data — The Fuel for AI
Data is the raw material for AI learning. Without data, even the best algorithms are like a skilled cook without ingredients—they can’t do anything.
▶ Example: Load and examine a dataset (Difficulty: ⭐)
# Example: loading and inspecting a dataset
import pandas as pd
# Load a CSV dataset (e.g., house prices)
df = pd.DataFrame({
'area_sqm': [50, 80, 120, 65, 200, 90],
'rooms': [2, 3, 4, 2, 5, 3],
'location_score': [7, 8, 6, 9, 5, 7],
'price_usd': [150000, 280000, 350000, 220000, 500000, 260000]
})
print(df.describe())
area_sqm rooms location_score price_usd
count 6.000000 6.00000 6.000000 6.000000e+00
mean 84.166667 3.16667 7.000000 2.933333e+05
std 51.968585 1.16905 1.414214 1.196533e+05
min 50.000000 2.00000 5.000000 1.500000e+05
max 200.000000 5.00000 9.000000 5.000000e+05
Data Type Classification:
| Data Type | Description | Example | AI Processing Method |
|---|---|---|---|
| Structured data | Has a fixed format (rows and columns) | CSV, SQL tables | Can be fed directly into ML models |
| Semi-structured data | Partially structured | JSON, XML, HTML | Input after feature extraction |
| Unstructured Data | No fixed format | Images, audio, natural language | Processed using deep learning |
(2) Algorithm — How AI Learns
An algorithm is a mathematical method for extracting patterns from data. Different tasks require different algorithms:
| Task Type | Typical Algorithm | What It Does |
|---|---|---|
| Category | Decision Trees, SVM, KNN | Classifying Data into Known Categories |
| Regression | Linear Regression, Random Forests | Predicting Continuous Values |
| Clustering | K-Means, DBSCAN | Automatically identifying groups in data |
| Generation | GAN, Transformer | Generate new data (text/images) |
(3) Model — The Results of AI Learning
A model is the result of training an algorithm on data. Training is like "learning," and a model is like the "knowledge acquired."
▶ Example: Algorithm + Data → Model (Difficulty ⭐)
Algorithm + Data → Training → Model
Example:
Linear Regression + House Price Data → Training → Price Prediction Model
(trained weights: price = 2500 * area + 15000 * rooms - 5000)
(4) An Analogy of the Three Elements
| AI Elements | Analogy | Description |
|---|---|---|
| Data | Ingredients | Good ingredients (high-quality data) are the foundation of a good dish (a good model) |
| Algorithm | Recipe | Different recipes (algorithms) are suitable for different ingredients (data types) |
| Model | Prepared dish | The final product after training, ready to "eat" (prediction) |
5. The Five Major Branches of AI
AI is not a single technology, but rather a disciplinary system comprising multiple subfields:
mindmap
root((AI))
Machine Learning
Supervised
Unsupervised
Reinforcement
Deep Learning
CNN
RNN
Transformer
NLP
Translation
Sentiment
Chat
Computer Vision
Classification
Detection
Generation
Robotics
Navigation
Manipulation
| Branch | Core Mission | Typical Applications | Representative Technologies |
|---|---|---|---|
| Machine Learning (ML) | Learning patterns from data | Spam filtering, housing price prediction | Decision trees, SVM, random forests |
| Deep Learning (DL) | Learning with Multi-Layer Neural Networks | Image Recognition, Speech Recognition | CNN, RNN, Transformer |
| Natural Language Processing (NLP) | Understanding and generating human language | Translation, chatbots, summarization | BERT, GPT, T5 |
| Computer Vision (CV) | Understanding and Generating Images/Videos | Face Recognition, Autonomous Driving, AI Art | YOLO, ResNet, Stable Diffusion |
| Robotics | Intelligent Action in the Physical World | Warehouse robots, surgical robots | ROS, reinforcement learning |
6. A Brief History of AI Development
Understanding the history of AI can help you grasp why today’s AI is so powerful (and why it might face another “winter”):
| Period | Event | Significance |
|---|---|---|
| 1950 | Turing published "Computing Machinery and Intelligence" | Raised the question, "Can machines think?" |
| 1956 | Dartmouth Conference; the term “AI” is coined | AI becomes a distinct field of study |
| 1960s–70s | The Rise of Expert Systems | Early Attempts to Put AI to Practical Use |
| 1974–1980 | The First AI Winter | Unfulfilled promises, funding cut off |
| 1980s | Revival of expert systems + introduction of backpropagation | Second wave of AI |
| 1987–1993 | The Second AI Winter | Expert systems were too costly to maintain |
| 2012 | AlexNet Wins ImageNet (The Deep Learning Revolution) | Demonstrates the Power of Deep Neural Networks + GPUs |
| 2017 | Google published "Attention Is All You Need" | Transformer architecture introduced, NLP paradigm shift |
| 2022 | ChatGPT Launched | Generative AI Goes Mainstream |
| 2023–2026 | GPT-4o, Claude, Llama, Qwen | The Era of Multimodal + Open Source + Agents |
7. Why Developers Must Understand AI
AI is reshaping every aspect of software development:
| Dimension | Risks of Not Understanding AI | Benefits of Understanding AI |
|---|---|---|
| Employment | Jobs requiring "CRUD skills" are being replaced by AI tools | AI engineer is the fastest-growing job role |
| Product | Product lacks smart features | Quickly add smart features using an AI API |
| Efficiency | Manual, repetitive work | AI-assisted coding/testing/documentation |
| Competitiveness | Outdated tech stack | Mastering AI development = a technical advantage |
▶ Example: Enhancing Apps with AI APIs (Difficulty: ⭐⭐)
# Example: Adding AI to your app is just a few lines of code
# (This requires an OpenAI API key, covered in Lesson 10)
# from openai import OpenAI
# client = OpenAI(api_key="your-api-key")
#
# response = client.chat.completions.create(
# model="gpt-4o-mini",
# messages=[
# {"role": "system", "content": "You are a helpful coding assistant."},
# {"role": "user", "content": "Explain recursion in Python in 2 sentences."}
# ]
# )
# print(response.choices[0].message.content)
Output: (Run the example to see the actual output, or refer to the expected-output note in the code comments above.)
8. Complete Example: Comparing Traditional Programs and AI Programs
Below is a complete Python example that compares the differences between "manually written rules" and "machine learning" for spam detection:
▶ Example: Comparing Traditional Programs and AI Programs for Spam Detection (Difficulty: ⭐⭐⭐)
# ============================================
# Compare: Rule-based vs Machine Learning
# Task: Spam email detection
# ============================================
# --- Approach 1: Traditional rule-based program ---
def is_spam_rules(email_text):
"""Detect spam using hand-written rules"""
spam_words = ["free", "winner", "click", "urgent", "congratulations"]
spam_count = sum(1 for word in spam_words if word in email_text.lower())
return spam_count >= 2 # Arbitrary threshold
# --- Approach 2: Machine Learning (simulated) ---
# In real code, we would train a model on thousands of labeled emails.
# Here we simulate the trained model's behavior.
def is_spam_ml(email_text):
"""Detect spam using a trained ML model (simulated)"""
# A real model learns patterns like:
# - ALL CAPS subject lines → likely spam
# - Multiple exclamation marks → likely spam
# - Specific sender domains → likely spam
# - Word combinations humans wouldn't think of
learned_spam_score = 0.85 # Simulated confidence
return learned_spam_score > 0.5
# --- Test both approaches ---
test_emails = [
"Congratulations! You are our lucky winner! Click here to claim your FREE prize!",
"Hey, can we reschedule tomorrow's meeting to 3 PM?",
"URGENT: Your account will be closed! Click here immediately!",
]
print("=== Rule-based vs ML Spam Detection ===")
for email in test_emails:
rule_result = is_spam_rules(email)
ml_result = is_spam_ml(email)
print(f"Email: {email[:60]}...")
print(f" Rule-based: {'Spam' if rule_result else 'Ham'}")
print(f" ML model: {'Spam' if ml_result else 'Ham'}")
print()
=== Rule-based vs ML Spam Detection ===
Email: Congratulations! You are our lucky winner! Click here to cl...
Rule-based: Spam
ML model: Spam
Email: Hey, can we reschedule tomorrow's meeting to 3 PM?...
Rule-based: Ham
ML model: Spam
Email: URGENT: Your account will be closed! Click here immediately!...
Rule-based: Spam
ML model: Spam
❓ FAQ
📖 Summary
- AI is a technology that enables computers to learn patterns from data and make intelligent decisions; its core lies in the shift "from rule-based to data-driven."
- Traditional programs = You write the rules → The machine executes them; AI programs = You provide the data → The machine learns the rules
- The three essential elements of AI are all indispensable: data (fuel) + algorithms (methods) + models (results)
- The five major branches of AI: ML, DL, NLP, CV, and Robotics; modern applications often involve the integration of multiple branches
- For developers, understanding AI is not optional—AI is reshaping software development, and developers who know how to use AI have a competitive advantage.
- The history of AI has seen three waves and two winters; the current wave of generative AI is driven by Transformers and massive computing power
📝 Exercises
- Basic Question (Difficulty: ⭐): List five AI applications from your daily life and identify which branch each belongs to (ML / DL / NLP / CV / Robotics).
- Advanced Problem (Difficulty ⭐⭐): Describe the differences between a traditional program and an AI program when determining whether an email is spam (specifying the input, processing, and output for each).
- Challenge (Difficulty: ⭐⭐⭐): Try out an AI product (such as ChatGPT, Midjourney, or GitHub Copilot) and write a 100-character analysis: Which branches of AI does it use? What challenges would you face if you tried to do the same thing with traditional programming?