Runoob Tutorial ArchiveEnglish

AI Introduction

AI Introduction

Imagine this scenario:

These scenarios were like science fiction five years ago, but now they are everyday life; AI is not the future, it is already embedded in the products you use every day.

The appearance of ChatGPT at the end of 2022 was a watershed moment:


Definition of Artificial Intelligence

In simple terms: Artificial Intelligence (AI) is a technology that enables computers to possess human-like intelligent behaviors.

The intelligent behaviors mentioned here include: understanding text, understanding speech, recognizing images, making decisions, and learning from experience.

The English abbreviation AI is pronounced A-I (reading the two letters separately), and the full name is Artificial Intelligence.

What AI can do

The following capabilities are quite mature in today's AI:

Capabilities Typical Applications Have you used it?
Language Understanding and Generation Translation, writing, summarizing articles, answering questions ChatGPT, Claude
Image Recognition Face unlock, document scanning, medical image analysis Mobile album classification, station turnstile
Voice interaction Speech-to-text, voice assistant Siri, Xiaoai Assistant, French voice input
Content generation AI painting, video generation, music creation Midjourney, Suno
Code assistance Code completion, bug fixing, automatic code generation GitHub Copilot, Cursor

What AI cannot do

Knowing the boundaries of AI is more important than knowing its capabilities.

AI does not truly understand anything—it is just performing probability calculations. If you say "The weather is nice today," it doesn't know what "nice" feels like; it only knows what words usually follow that sentence.

AI has no consciousness, no emotions, and no goals of its own; it will not want to do anything.

AI can hallucinate, meaning it can seriously fabricate non-existent facts, names, papers, or data because it is essentially predicting the next word, not verifying facts.

AI lacks judgment in novel situations it hasn't seen before; its performance may be very poor if the training data does not contain similar scenarios.

837b31a9 1c6d 45fe 98 d c798cc1d84d8

Remember:AI is a powerful assistant, not a trusted authority..

For high-risk decisions involving medicine, law, investment, etc., AI output can only be for reference and cannot be the final basis.


Brief History of AI

AI did not appear suddenly; its history spans over 70 years and has gone through three cycles of boom and bust.

First Wave: Symbolism (1950s–1980s)

In 1956, a group of scientists met at Dartmouth College, and the term artificial intelligence was officially proposed.

The mainstream approach at the time was simple: write human expert knowledge into a series of rules and store them in a computer, then use the rules to reason when a problem occurred. This approach is called expert systems.

For example, a medical diagnosis expert system stores thousands of rules internally: if the patient has a fever and cough, it might be a cold; if the fever is over 39 degrees and lasts for three days, it suggests a blood test.

The problem is that real-world rules are endless; if you write five thousand rules, and a patient presents with a sixth thousand combination of symptoms, the system doesn't know what to do.

Moreover, modifying the rules is extremely painful—adding one new rule might conflict with hundreds of existing rules.

In the late 1980s, people realized this path was unsustainable, and AI entered its first winter.

The Second Wave: The Rise of Machine Learning (1990s–2010s)

Researchers changed their approach: instead of having humans write the rules, they let the machine find patterns from the data itself.

For example, to identify spam emails, instead of writing rules like "if it contains the word 'win' it is spam," they show the machine ten thousand labeled emails (five thousand normal, five thousand spam) and let the algorithm figure out what spam emails usually look like.

During this period, classic algorithms such as Support Vector Machine (SVM), Random Forest, and Logistic Regression were born, performing very well in scenarios like spam filtering, credit card fraud detection, and product recommendation.

However, there was a bottleneck: features needed to be designed by humans. For example, in image recognition, you first have to manually extract features like "edges," "color distribution," and "texture" before feeding them to the algorithm. The human ability to extract features determined the upper limit of the model.

The Third Wave: Deep Learning and Large Models (2010s–Present)

In 2012, a deep neural network called AlexNet overwhelmingly outperformed traditional methods in the ImageNet image recognition competition, officially starting the era of deep learning.

The core breakthrough of deep learning is that features no longer need to be designed manually; the model learns layer by layer directly from the raw data.

In 2017, Google published the paper "Attention Is All You Need," proposing the Transformer architecture.

In November 2022, OpenAI released ChatGPT, reaching over 100 million users in two months, truly bringing AI to the masses.

From 2023 to the present, large models such as GPT-4, Claude, and Gemini continue to iterate, with new directions like multimodal, AI Agent, and reasoning models constantly emerging.

The core thread of the three waves, summarized in one sentence:

Waves Core idea Who is working Representative events
First time (1950s–1980s) Humans write rules, machines execute Programmers write rules 1956 Dartmouth Conference
Second (1990s–2010s) Machines learn from data patterns Humans design features, algorithms learn patterns 1997 Deep Blue defeats chess champion
Third (2010s–present) Deep networks + massive data + huge computing power Models learn features themselves ChatGPT released in 2022

The evolution path of AI: rule-driven → data-driven → deep learning → large models → agents. More granularly, we can divide it into 5 stages:

4 65eb16 ffd 4 e a64 dd5e3476adbc


Three easily confused concepts: AI, ML, DL

AI (Artificial Intelligence), ML (Machine Learning), and DL (Deep Learning) are often conflated by the media, but their definitions are not equivalent; they are not the same thing.

First, look at a relationship diagram:

Relationship diagram of AI, machine learning, and deep learning

Containment relationship: AI ⊃ ML ⊃ DL

Not all AI is ML, and not all ML is DL.

Clarify the differences between the three with an example

Suppose we want to create a program to determine if an email is spam, the three approaches correspond to three levels:

Example

============================================

Approach one: Rule-based (AI, but not ML)

The programmer manually writes the rules, with no "learning" process

============================================

def

is_spam_by_rules

(

email_text:

str

)

bool

:

   

"Determine spam email using keyword rules—pure manual rules, no learning"

   

If any of the following keywords are matched, it is judged as spam email

spam_keywords

=

[

       

"Congratulations on winning"

,

       

"Free Claim"

,

       

"Click to Claim"

,

       

"Limited-time offer"

,

       

"runoob Gift Pack"

,

 

For testing, can be replaced in actual scenarios

   

]

   

for

keyword

in

spam_keywords:

       

if

keyword

in

email_text:

           

return

True

   

return

False

Test: An email content is as follows

test_email

=

"Congratulations on receiving the runoob big gift package, click to claim!"

result

=

is_spam_by_rules

(

test_email

)

print

(

f

"Rule judgment result: {'Spam' if result else 'Normal email'}"

)

Output: Rule-based judgment result: Spam

The advantage of rule-based methods is that they are simple and direct, but the disadvantages are: rules cannot be written completely or exhaustively. If spam changes its wording, for example, to "Congratulations on winning a big prize," the rule will miss it.

Example

============================================

Approach Two: Classic Machine Learning (ML, but not DL)

Automatically learns patterns from historical data without needing to write rules manually

============================================

def

train_simple_classifier

(

emails:

list

,

labels:

list

)

:

   

"""Train the simplest machine learning classifier
Approach: count the frequency of each word in spam and normal emails,
and use the frequency difference to judge new emails"""

   

Count the occurrences of each word in the two types of emails

spam_word_count

=

{

}

 

Total number of times the word appears in spam

ham_word_count

=

{

}

   

Total count of the word appearing in normal emails

spam_total

=

0

       

Total spam word count

ham_total

=

0

         

Total word count of normal emails

   

for

email_text

,

label

in

zip

(

emails

,

labels

)

:

words

=

email_text.

split

(

)

       

for

word

in

words:

           

if

label

==

"spam"

:

spam_word_count

[

word

]

=

spam_word_count.

get

(

word

,

0

)

1

spam_total +

=

1

           

else

:

ham_word_count

[

word

]

=

ham_word_count.

get

(

word

,

0

)

1

ham_total +

=

1

   

Return the learned statistics (this is the "model")

   

return

{

       

"spam_word_count"

: spam_word_count

,

       

"ham_word_count"

: ham_word_count

,

       

"spam_total"

: spam_total

,

       

"ham_total"

: ham_total

,

   

}

def

predict

(

model:

dict

,

email_text:

str

)

str

:

   

"Predict new emails using the learned model"

words

=

email_text.

split

(

)

spam_score

=

0.0

 

Spam score

ham_score

=

0.0

   

Normal email score

   

for

word

in

words:

       

Calculate the probability of this word appearing in spam (add smoothing to avoid division by zero)

spam_prob

=

(

model

[

"spam_word_count"

]

.

get

(

word

,

0

)

1

)

/

(

model

[

"spam_total"

]

1

)

ham_prob

=

(

model

[

"ham_word_count"

]

.

get

(

word

,

0

)

1

)

/

(

model

[

"ham_total"

]

1

)

spam_score +

=

spam_prob

ham_score +

=

ham_prob

   

return

"spam"

if

spam_score

ham_score

else

"ham"

Training data: 4 labeled emails

emails

=

[

   

"Congratulations on winning! Claim your free gift package"

,

         

Spam

   

Limited-time offer, click to claim runoob gift package

,

     

Trash

   

Meeting tomorrow, remember to bring the report

,

               

Normal

   

"Want to have dinner together this weekend, are you free?"

,

             

Normal

]

labels

=

[

"spam"

,

"spam"

,

"ham"

,

"ham"

]

model

=

train_simple_classifier

(

emails

,

labels

)

Predict new email

new_email

=

"Congratulations on winning the grand prize, come claim it"

result

=

predict

(

model

,

new_email

)

print

(

f

"ML method judgment result: {'spam' if result == 'spam' else 'normal email'}"

)

Output: ML method judgment result: spam

The ML method no longer requires manually written rules; it learns automatically from data.

However, it still requires humans to design "features"—in this example, the feature is "judging by word frequency." If the feature is designed poorly, the model's performance will not improve.

Example

============================================

Approach 3: Deep Learning (a subset of DL, ML)

Use a multi-layer neural network to let the model learn features itself

Here, we use pseudocode + comments to explain the principle, without relying on any framework

============================================

The approach for deep learning spam classification:

1. Convert each word into a vector (a sequence of numbers); this step is called "word embedding"

2. Feed these vectors into a multi-layer neural network

3. Each layer automatically extracts increasingly abstract features

4. The last layer outputs the probability of "garbage" or "normal"

Below is a conceptual three-layer neural network structure:

class

SimpleNeuralNetwork:

   

"""Conceptual demonstration: the structure of a three-layer neural network (without training logic)"""

   

def

init

(

self

,

input_size:

int

,

hidden_size:

int

,

output_size:

int

)

:

       

"""Initialize weights of network layers"""

       

import

random

       

Layer 1: Input -> Hidden Layer (Apply a non-linear transformation to the input features)

       

self

.

w1

=

[

[

random

.

random

(

)

for

_

in

range

(

hidden_size

)

]

                   

for

_

in

range

(

input_size

)

]

       

Layer 2: Hidden layer -> Output layer (mapping abstract features to final classification)

       

self

.

w2

=

[

[

random

.

random

(

)

for

_

in

range

(

output_size

)

]

                   

for

_

in

range

(

hidden_size

)

]

   

def

forward

(

self

,

x:

list

)

list

:

       

"""Forward propagation: input data goes through the network to get output"""

       

First layer transformation

hidden

=

[

sum

(

x

[

i

]

self

.

w1

[

i

]

[

j

]

for

i

in

range

(

len

(

x

)

)

)

                 

for

j

in

range

(

len

(

self

.

w1

[

0

]

)

)

]

       

ReLU activation function (negative values become 0, positive values remain unchanged)

hidden

=

[

max

(

0

,

h

)

for

h

in

hidden

]

       

The second layer transformation yields the final output

output

=

[

sum

(

hidden

[

i

]

self

.

w2

[

i

]

[

j

]

for

i

in

range

(

len

(

hidden

)

)

)

                 

for

j

in

range

(

len

(

self

.

w2

[

0

]

)

)

]

       

return

output

Assume each word has been converted into a 100-dimensional vector (automatically completed by the word embedding layer)

Input 100-dimensional vector $\rightarrow$ Hidden layer with 64 neurons $\rightarrow$ Output of 2 values (garbage probability, normal probability)

model

=

SimpleNeuralNetwork

(

input_size

=

100

,

hidden_size

=

64

,

output_size

=

2

)

print

(

"Three-layer neural network structure created: 100 -> 64 -> 2"

)

Output: Three-layer neural network structure created: 100 -> 64 -> 2

Comparison of three approaches:

Approach Who is working Category Pros and cons
Rule-based method Programmer-written rules AI (non-ML) Simple and direct, but rules are hard to write completely and difficult to maintain
Classic ML Algorithms derive rules from data patterns, features are designed by humans ML (non-DL) Performs well with small amounts of data, strong interpretability
Deep Learning The model learns the features itself DL Performs well with massive data, but requires a large amount of computing power

When someone says, "Our company is doing AI," you can ask, "Are you using rules, traditional machine learning, or deep learning?"—this can help you quickly judge the other party's technical roadmap.


Weak AI, Strong AI, Super AI

In addition to classifying by technical roadmap, AI can also be divided into three levels based on "intelligence level."

Weak AI (Narrow AI) — already achieved

Can only perform excellently on specific tasks, and is lost when switching tasks.

AlphaGo can beat world champions at Go, but it cannot write a poem.

ChatGPT is very good at chatting, but if you give it a medical image to diagnose, it can't do it.

All the AI products we can access today are weak AI.

"Weak" does not mean weak capability, but rather narrow scope—it is only good in one or a few specific fields.

Strong AI (AGI, Artificial General Intelligence) — not yet achieved

Able to learn and work in any field like a human. No need to train separately for each new task; it can get started by looking at a few examples.

AGI is the ultimate goal of companies like OpenAI, Anthropic, and Google DeepMind.

There is no recognized AGI yet. When will it be achieved? Optimistically, 5-10 years, pessimistically, over 50 years; no one can say for sure.

Super AI (ASI, Artificial Superintelligence) — purely theoretical

To comprehensively surpass human intelligence in all fields. To make scientific discoveries that humans cannot, and solve problems that humans cannot understand.

This is a common trope in science fiction, but it is still very far from reality.

Relationship between the three levels:

Level Scope of capabilities Current status Example
Weak AI Single domain Widely existing ChatGPT, facial recognition, AlphaGo
Strong AI (AGI) General domain, comparable to humans Not yet achieved —
Super AI (ASI) Completely surpass humans Pure theoretical concept —

Correcting common misconceptions

There are two misconceptions about AI that are widely circulated and deserve to be clarified specifically.

Misconception one: AI has consciousness

AI does not have consciousness.

Do not be deceived by AI's tone; it can write a poem that makes you shed tears, but it has no feeling about that poem and doesn't even know what crying means.

When you chat with ChatGPT and it says "I feel" or "I think," no actual "feeling" or "thinking" is happening.

What AI does is essentially just predict the next most probable word based on all the preceding text.

To put it another way: if you input "The weather today is really," it predicts the next word is "good" (85% probability), "hot" (8%), or "cold" (5%), and then selects "good." Then, based on "The weather today is really good," it predicts the next word is "ah"... and so on, generating word by word.

The entire process has no subjective experience, no self-awareness, and no intention; it is merely mimicking the probability distribution of human language.

55ec6ed c8d9 4f6a b 3c fb565 b548 1

Misconception 2: AI will replace humans.

A more accurate way to put it is: AI will not replace humans, but people who use AI will replace those who do not.

History has repeatedly verified this pattern:

For individuals, the most important thing is not to fear AI, but to learn how to collaborate with AI.