1 of 52

Machine Learning - �Basic Principles & Practice�Other Topic: Modern Paradigm

Cong Li 李聪

机器学习 – 基础原理与实践

番外:现代范式

2 of 52

Deep Learning 深度学习

  • Complex Networks 复杂网络
    • A lot of layers 很多层
    • Comprehensive structure 详尽的结构
  • Many Paradigms Invoked 催生出很多范式

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

3 of 52

High Dimensional Features Learned 学习到的高维特征

  • Network Layers 网络层
    • Derive new features from existing ones 从现有特征中衍生出新特征
      • Automatically through a learning process 通过学习过程自动习得
      • Not manually prescribed 而非人工指定
  • Start from Recalling Convolutional Neural Network 从回忆卷积神经网络开始

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

4 of 52

Recall 回忆

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

16x16

14x14

1 3x3 convolution 1 new feature

一个3x3卷积

一个新特征

5 of 52

Recall 回忆

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

16x16

32 convolutions

32 new features

32个卷积

32个新特征

14x14

6 of 52

Recall 回忆

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

16x16

14x14

14x14x32

32 features for each 14x14 location

14x14的每个位置上都有32个特征

Each 3x3 convolution operator learned, not prescribed

每个3x3卷积算子都是学习到的,而非人工指定

7 of 52

Recall 回忆

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

16x16

14x14

14x14x32

1 3x3x32 convolution 1 new feature

一个3x3x32卷积

一个新特征

12x12

8 of 52

Recall 回忆

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

16x16

14x14

14x14x32

64 convolutions

64 new features

64个卷积

64个新特征

12x12

9 of 52

Recall 回忆

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

16x16

14x14

14x14x32

12x12

12x12x64

64 features for each 12x12 location

12x12的每个位置上都有64个特征

Each 3x3x32 convolution operator learned, not prescribed

每个3x3x32卷积算子都是学习到的,而非人工指定

10 of 52

Another Example 另一个例子

  • Netflix User Rating of Films Netflix用户对电影的评分

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Film 1

电影1

Film 2

电影2

Film 3

电影3

User 1 用户1

8

3

User 2 用户2

7

9

User 3 用户3

5

8

User 4 用户4

2

3

 

11 of 52

Another Example 另一个例子

  • Netflix User Rating of Films Netflix用户对电影的评分

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Film 1

电影1

Film 2

电影2

Film 3

电影3

User 1 用户1

8

3

?

User 2 用户2

7

?

9

User 3 用户3

?

5

8

User 4 用户4

2

?

3

 

12 of 52

High Dimensional Features�高维特征属性

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

 

电影本身 Film

用户关注 User preference

1

Horror film?

是否为恐怖片?

Prefer horror films?

是否喜欢恐怖片?

13 of 52

High Dimensional Features�高维特征属性

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

 

电影本身 Film

用户关注 User preference

1

Horror film?

是否为恐怖片?

Prefer horror films?

是否喜欢恐怖片?

2

A certain actor’s presence & performance

某个演员出镜率和表现

Favor the actor?

是否关注某个演员

14 of 52

High Dimensional Features�高维特征属性

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

 

电影本身 Film

用户关注 User preference

1

Horror film?

是否为恐怖片?

Prefer horror films?

是否喜欢恐怖片?

2

A certain actor’s presence & performance

某个演员出镜率和表现

Favor the actor?

是否关注某个演员

3

A certain director

为某个导演执导

Favor the director?

偏好某个导演的影片

Imagination here. Feature semantics learned automatically, not prescribed 这里只是想象。特征语义自动习得,并非事先预设

15 of 52

Model 模型

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Film 1

电影1

Film 2

电影2

Film 3

电影3

User 1 用户1

8

3

User 2 用户2

7

9

User 3 用户3

5

8

User 4 用户4

2

3

 

 

16 of 52

Model 模型

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Film 1

电影1

Film 2

电影2

Film 3

电影3

User 1 用户1

8

3

User 2 用户2

7

9

User 3 用户3

5

8

User 4 用户4

2

3

Rating of user 3 for film 2

用户3对电影的评分

17 of 52

Model 模型

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Film 1

电影1

Film 2

电影2

Film 3

电影3

User 1 用户1

8

3

User 2 用户2

7

9

User 3 用户3

5

8

User 4 用户4

2

3

Rating of user 3 for film 2

用户3对电影的评分

 

18 of 52

Training 训练

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Film 1

电影1

Film 2

电影2

Film 3

电影3

User 1 用户1

8

3

User 2 用户2

7

9

User 3 用户3

5

8

User 4 用户4

2

3

19 of 52

Training 训练

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Film 1

电影1

Film 2

电影2

Film 3

电影3

User 1 用户1

8

3

User 2 用户2

7

9

User 3 用户3

5

8

User 4 用户4

2

3

 

20 of 52

Prediction 预测

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

 

Film 1

电影1

Film 2

电影2

Film 3

电影3

User 1 用户1

8

3

?

User 2 用户2

7

9

User 3 用户3

5

8

User 4 用户4

2

3

21 of 52

Prediction 预测

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

 

Film 1

电影1

Film 2

电影2

Film 3

电影3

User 1 用户1

8

3

User 2 用户2

7

9

User 3 用户3

5

8

User 4 用户4

2

?

3

22 of 52

Learning Residual 学习残差 (1)

  • In CNN for USPS Dataset 用于USPS数据集的卷积神经网络
    • 1st layer: strokes composed of local patterns 第一层:局部模式构成的笔画
    • 2nd layer: high-level patterns constructed from local patterns 第二层:局部模式构建而成的高层次模式
  • Residual Network 残差网络
    • Not explicitly discriminating high-level or low-level features 不明确区分高低层次和低层次特征

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

23 of 52

Learning Residual 学习残差 (2)

  • Learning Residual 学习残差
    • Each layer: iteratively update the high dimensional features 每一层:递进地更新高维特征
      • Modify existing feature values 更改已有的特征属性值
      • Create new features 构建新的特征

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

24 of 52

Residual Network 残差网络

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

一个

例子

Text processing 句子处理

Initial feature representation from a table

初始特征表示来自一张表格

Complex network

复杂网络

+

Residual

残差

+

+

+

+

Updated feature representation

更新后的特征表示

25 of 52

More Residual Layers 更多残差层

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Complex network

复杂网络

+

Complex network

复杂网络

+

Each layer iteratively updates the feature representation

每一层都递进地更新了特征表示

Flexible number of layers, no need to consider which layer corresponds to which level of feature representation

灵活的层数,无需考虑哪一层对应于哪一级别的特征表示

26 of 52

Language Model 语言模型

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Predict the next word w/ probability 预测下一个词及其概率

幸运

挑战

机遇

问题

气候变化是全世界面临的

0.3

0.0015

0.4

0.001

27 of 52

Why Predicting the Next Word�为什么要预测下一个词 (1)

  • Linguistic Capability 语言学能力
    • Gramar, sentence structure, word semantics, etc. 语法,句子结构,词汇语义等
  • Knowledge 知识
    • Examples 例子
      • Einstein developed relativity (vs painting)
      • In 1969, Neil Armstrong became the first person to walk on the moon

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

28 of 52

Why Predicting the Next Word�为什么要预测下一个词 (2)

  • Logic & Reasoning 逻辑和推理
    • Continuous generation of words as an answer to a question 针对一个问题,持续生成后续词构成回答
  • Abundance of Training Data 充裕的训练数据
    • Texts everywhere 到处都是文本
      • But need curation w/ quality 但需要高质量的甄筛和管理

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

29 of 52

Iterative Generation 反复生成

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

… In 1969, Neil Armstrong became the first person to

Complex network

复杂网络

Preceding text information

前文信息

walk

30 of 52

Iterative Generation 反复生成

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

walk

Complex network

复杂网络

Preceding text information

前文信息

31 of 52

Iterative Generation 反复生成

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

walk

Complex network

复杂网络

Preceding text information

前文信息

on

32 of 52

Iterative Generation 反复生成

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

on

Complex network

复杂网络

Preceding text information

前文信息

33 of 52

Iterative Generation 反复生成

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

on

Complex network

复杂网络

Preceding text information

前文信息

the

34 of 52

Iterative Generation 反复生成

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

the

Complex network

复杂网络

Preceding text information

前文信息

35 of 52

Iterative Generation 反复生成

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

the

Complex network

复杂网络

Preceding text information

前文信息

moon

36 of 52

Iterative Generation 反复生成

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

moon

Complex network

复杂网络

Preceding text information

前文信息

37 of 52

Iterative Generation 反复生成

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

moon

Complex network

复杂网络

Preceding text information

前文信息

End-of-sequence

38 of 52

Attention Mechanism �注意力机制

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

In

1969

Neil

Armstrong

became

the

first

person

to

walk

Target word query

目标词查询

Preceding text information 前文信息

Source word keys

源词键名

Dot product

点乘

0.02

1.2

0.9

1.3

0.5

0.01

1.1

0.6

0.05

0.3

39 of 52

Attention Mechanism �注意力机制

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

In

1969

Neil

Armstrong

became

the

first

person

to

walk

0.02

1.2

0.9

1.3

0.5

0.01

1.1

0.6

0.05

0.3

Softmax to probabilities

指数归一化为概率

0.0501

0.1631

0.1208

0.1803

0.0810

0.04900.1476

0.0895

0.0516

0.0663

40 of 52

Attention Mechanism �注意力机制

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

In

1969

Neil

Armstrong

became

the

first

person

to

walk

0.0501

0.1631

0.1208

0.1803

0.0810

0.04900.1476

0.0895

0.0516

0.0663

Another preceding text information 另一种前文信息

Source word values

源词键值

 

 

41 of 52

Attention Mechanism �注意力机制

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

In

1969

Neil

Armstrong

became

the

first

person

to

walk

0.0501

0.1631

0.1208

0.1803

0.0810

0.04900.1476

0.0895

0.0516

0.0663

Contribution from preceding text to ‘walk’ 来自前文的对’walk’的贡献

 

 

 

42 of 52

Contemporary LLMs �当代大规模语言模型

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Input word token(s) 输入词符

Embedding layer 特征表示层

High dimensional features 高维特征

High dimensional features 高维特征

High dimensional features 高维特征

Output layer 输出层

Next token probabilities 下一个词符概率

Transformer module Transformer模块

Transformer module Transformer模块

High dimensional features 高维特征

Transformer module Transformer模块

High dimensional features 高维特征

43 of 52

Transformer Module�Transformer模块

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

High dimensional features 高维特征

Higher dimensional features 更高维特征

Fully connecter layer 全连通层

Fully connecter layer 全连通层

Normalization layer 归一化层

Normalization layer 归一化层

High dimensional features 高维特征

Preceding text information

前文信息

Attention 注意力

Fully connecter layer 全连通层

Fully connecter layer 全连通层

All the keys/values

所有的键名/键值

New key/value

新的键名/键值

Current query 当前查询

+

+

Residual 残差

Residual 残差

Attention sub-module

注意力子模块

Incorporation information from the preceding text

整合前文的信息

44 of 52

Transformer Module�Transformer模块

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

High dimensional features 高维特征

Higher dimensional features 更高维特征

Fully connecter layer 全连通层

Fully connecter layer 全连通层

Normalization layer 归一化层

Normalization layer 归一化层

High dimensional features 高维特征

Preceding text information

前文信息

Attention 注意力

Fully connecter layer 全连通层

Fully connecter layer 全连通层

All the keys/values

所有的键名/键值

New key/value

新的键名/键值

Current query 当前查询

+

+

Multi-layer perceptron

sub-module

多层感知器子模块

Further transform features

进一步变换特征

45 of 52

Reasoning w/ a Long Output Path 基于长输出路径的推理

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

DeepSeek’s input template DeepSeek的输入模板

46 of 52

Reasoning w/ a Long Output Path 基于长输出路径的推理

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

A DeepSeek example 一个DeepSeek的例子

47 of 52

Reasoning Model 推理模型

  • Strong LLM 强大的语言模型
    • Generating long & correct output, e.g., 生成长而正确的输出,例如
      • Reflection 反省
      • Self-verification 自我验证
  • Difficulties 困难
    • Iteratively outputting words of a concise reasoning: not trainable in general 逐词输出精简赅要的推理:几乎无法训练
    • Tentative & reflective reasoning: no enough training data 试探与反思型推理:缺乏足够的训练数据

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

48 of 52

Reinforcement Learning �强化学习

  • Different Learning Paradigm 另一种学习范式
    • Not supervising each step 并非监督每一步
    • But by exploring w/ trial-and-error & getting rewards in achieving goals 而由在探索试错、接受完成任务的奖励来引导
  • Classical Methods in Games 博弈任务中的经典方法
    • Example: AlphaGo 例如AlphaGo

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

49 of 52

Sampling Output 输出采样

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Generate the next word based on probability

依据概率生成下一个词

幸运

挑战

机遇

问题

气候变化是全世界面临的

0.3

0.0015

0.4

0.001

X

X

50 of 52

Policy Gradient 策略梯度

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

Training task

训练任务

Output sequence 1

输出序列1

X

X

Task judge

任务裁判

Discourage all the steps

不赞赏所有步骤

Encourage all the steps

赞赏所有步骤

Discourage all the steps

不赞赏所有步骤

Output sequence 2

输出序列2

Output sequence n

输出序列n

Sampling output sequences based on the current model probabilities

基于当前模型概率

采样得到输出序列

Synthesize a loss function value

综合成一个损失函数值

Update model w/ gradient descent

用梯度下降更新模型

51 of 52

Summary 总结

  • Learning High Dimensional Features 学习高维特征
  • Learning Residuals 学习残差
  • Iteratively Predicting Next Words 反复地预测下一个词
    • Using attention 采用注意力机制
  • Long-Path Reasoning 长路径推理
    • Trained by reinforcement learning 以强化学习训练

Machine Learning – Basic Principles & Practice: Other Topic: Modern Paradigm

机器学习 – 基础原理与实践:番外:现代范式

52 of 52

The End