-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1219 lines (814 loc) · 56.6 KB
/
index.html
File metadata and controls
1219 lines (814 loc) · 56.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="alternate" href="/atom.xml" title="Bool_tbb" type="application/atom+xml">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
<script src="/lib/pace/pace.min.js"></script>
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Pisces',
version: '7.5.0',
exturl: false,
sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
copycode: {"enable":false,"show_result":false,"style":null},
back2top: {"enable":true,"sidebar":true,"scrollpercent":true},
bookmark: {"enable":false,"color":"#222","save":"auto"},
fancybox: false,
mediumzoom: false,
lazyload: false,
pangu: false,
algolia: {
appID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
},
localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
path: 'search.xml',
motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
sidebarPadding: 40
};
</script>
<meta name="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
<meta property="og:type" content="website">
<meta property="og:title" content="Bool_tbb">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="Bool_tbb">
<meta property="og:description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="bool_tbb">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="http://yoursite.com/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome: true,
isPost: false,
isPage: false,
isArchive: false
};
</script>
<title>Bool_tbb</title>
<noscript>
<style>
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</head>
<body itemscope itemtype="http://schema.org/WebPage">
<!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container use-motion">
<div class="headband"></div>
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-meta">
<div>
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Bool_tbb</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle">一枚NLPer小菜鸡</p>
</div>
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>
</li>
<li class="menu-item menu-item-search">
<a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
</a>
</li>
</ul>
</nav>
<div class="site-search">
<div class="popup search-popup">
<div class="search-header">
<span class="search-icon">
<i class="fa fa-search"></i>
</span>
<div class="search-input-container">
<input autocomplete="off" autocorrect="off" autocapitalize="none"
placeholder="搜索..." spellcheck="false"
type="text" id="search-input">
</div>
<span class="popup-btn-close">
<i class="fa fa-times-circle"></i>
</span>
</div>
<div id="search-result"></div>
</div>
<div class="search-pop-overlay"></div>
</div>
</div>
</header>
<main class="main">
<div class="main-inner">
<div class="content-wrap">
<div class="content">
<div class="posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2025/03/05/%E5%A4%A7%E6%A8%A1%E5%9E%8B%E5%AD%A6%E4%B9%A0%E6%80%BB%E7%BB%93/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2025/03/05/%E5%A4%A7%E6%A8%A1%E5%9E%8B%E5%AD%A6%E4%B9%A0%E6%80%BB%E7%BB%93/" class="post-title-link" itemprop="url">大模型学习总结</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2025-03-05 00:31:38" itemprop="dateCreated datePublished" datetime="2025-03-05T00:31:38+08:00">2025-03-05</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2025-03-26 00:51:39" itemprop="dateModified" datetime="2025-03-26T00:51:39+08:00">2025-03-26</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<a id="more"></a>
<h3 id="浅层对齐假说"><a href="#浅层对齐假说" class="headerlink" title="浅层对齐假说"></a>浅层对齐假说</h3><p>LIMA(Less Is More for Alignment) 即浅层对齐假说,即一 个模型的知识和能力几乎完全是在预训练中学习的,而对齐则是教会它与用户交互时如何选择子分布。</p>
<h3 id="大模型参数估计"><a href="#大模型参数估计" class="headerlink" title="大模型参数估计"></a>大模型参数估计</h3><p><img src="WechatIMG4.png" alt="avtar"></p>
<p><img src="WechatIMG5.png" alt="avtar"></p>
<p><img src="WechatIMG5.png" alt="avtar"></p>
<p><img src="WechatIMG5.png" alt="avtar"></p>
<p><img src="WechatIMG6.png" alt="avtar"></p>
<p><img src="WechatIMG7.png" alt="avtar"></p>
<p><img src="WechatIMG9.png" alt="avtar"></p>
<p><img src="WechatIMG11.png" alt="avtar"></p>
<p><img src="WechatIMG12.png" alt="avtar"></p>
<h3 id="register-parameter"><a href="#register-parameter" class="headerlink" title="register_parameter"></a>register_parameter</h3><p>注册一个可训练的函数</p>
<h3 id="register-buffer"><a href="#register-buffer" class="headerlink" title="register_buffer"></a>register_buffer</h3><p>模型训练:<br>数据并行(data parallel), 模型及数据独立分发给各GPU,各自计算梯度,汇总到其中一个GPU平均后优化,梯度传播到其它GPU优化。</p>
<p>模型并行,张量并行</p>
<p>DDP(data distributed parallel)</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2025/02/14/PPO%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2025/02/14/PPO%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" class="post-title-link" itemprop="url">PPO学习笔记</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2025-02-14 01:27:29" itemprop="dateCreated datePublished" datetime="2025-02-14T01:27:29+08:00">2025-02-14</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2025-03-26 00:32:45" itemprop="dateModified" datetime="2025-03-26T00:32:45+08:00">2025-03-26</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>rewards:与环境一次交互环境所给的反馈奖励或惩罚。</p>
<p>Action space: 动作的选择空间。</p>
<p>Policy:根据当前的状态给出action概率分布。</p>
<p>Traj:轨迹,状态和动作序列。episode rollout<br>{s0,a0,s1,a1,sn,an}</p>
<p>return: rewards累积和。</p>
<p>期望:每个可能的结果和对应概率乘积之和。</p>
<p>强化学习目标:</p>
<script type="math/tex; mode=display">
\mathrm{E}(\mathrm{x})_{x \sim p(x)}=\sum_x x * p(x) \approx \frac{1}{n} \sum_{i=1}^n x \quad x \sim p(x)</script><p>目标:训练一个神经网络 $\pi$,在所有状态S下,给出相应的action,得到return的期望最大。</p>
<p>或者:训练一个神经网络 $\pi$,在所有trajetory中,得到的return最大。</p>
<script type="math/tex; mode=display">
E(R(\tau))_{\tau \sim P_\theta(\tau)}=\sum_\tau R(\tau) P_\theta(\tau)</script><p>梯度上升⚽️期望最大。</p>
<script type="math/tex; mode=display">
\begin{aligned}
\nabla E(R(\tau))_{\tau \sim P_\theta(\tau)} & =\nabla \sum_\tau R(\tau) P_\theta(\tau) \\
& =\sum_\tau R(\tau) \nabla P_\theta(\tau) \\
& =\sum_\tau R(\tau) \nabla P_\theta(\tau) \frac{P_\theta(\tau)}{P_\theta(\tau)} \\
& =\sum_\tau P_\theta(\tau) R(\tau) \frac{\nabla P_\theta(\tau)}{P_\theta(\tau)} \\
& =\sum_\tau P_\theta(\tau) R(\tau) \frac{\nabla P_\theta(\tau)}{P_\theta(\tau)} \\
& \approx \frac{1}{N} \sum_{n=1}^N R\left(\tau^n\right) \frac{\nabla P_\theta\left(\tau^n\right)}{P_\theta\left(\tau^n\right)} \\
& =\frac{1}{N} \sum_{n=1}^N R\left(\tau^n\right) \nabla \log P_\theta\left(\tau^n\right) \quad \nabla \log f(x)=\frac{\nabla f(x)}{f(x)}
\end{aligned}</script><script type="math/tex; mode=display">
\begin{aligned}
= & \frac{1}{N} \sum_{n=1}^N R\left(\tau^n\right) \nabla \log P_\theta\left(\tau^n\right) \\
= & \frac{1}{N} \sum_{n=1}^N R\left(\tau^n\right) \nabla \log \prod_{t=1}^{T_n} P_\theta\left(a_n^t \mid s_n^t\right) \\
= & \frac{1}{N} \sum_{n=1}^N R\left(\tau^n\right) \sum_{t=1}^{T_n} \nabla \log P_\theta\left(a_n^t \mid s_n^t\right) \\
= & \frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n} R\left(\tau^n\right) \nabla \log P_\theta\left(a_n^t \mid s_n^t\right) \\
& \frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n} R\left(\tau^n\right) \log P_\theta\left(a_n^t \mid s_n^t\right)
\end{aligned}</script><p>上述为:policy gradient</p>
<p>on policy采集数据,训练神经网络。<br>off policy:先采集完数据,再训练神经网络。</p>
<p>actor critor:<br>增加base line 使得在不同 局势下都可以得到优化,<br>好的局势时,朝着好的方向进行,但可以区分哪些更好,哪些相对较好。</p>
<script type="math/tex; mode=display">
\begin{aligned}
& =\frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n} R\left(\tau^n\right) \nabla \log P_\theta\left(a_n^t \mid s_n^t\right) \\
& =\frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n} R_t^n \nabla \log P_\theta\left(a_n^t \mid s_n^t\right) \\
& =\frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n}\left(R_t^n-B\left(s_n^t\right)\right) \nabla \log P_\theta\left(a_n^t \mid s_n^t\right)
\end{aligned}</script><script type="math/tex; mode=display">
\frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n}\left(R_t^n-B\left(s_n^t\right)\right) \nabla \log P_\theta\left(a_n^t \mid s_n^t\right)</script><p>Action-Value Function<br>$R<em>t^n$ 每次都是一次随机采样,方差很大,训练不稳定。<br>$Q</em>\theta(s, a)$ 在state $s$ 下,做出Action a,期望的回报。动作价值函数。<br>State-Value Function<br>$V_\theta(s)$ 在state $s$ 下,期望的回报。状态价值函数。</p>
<p>Advantage Function<br>$A<em>\theta(s, a)=Q</em>\theta(s, a)-V_\theta(s)$ 在state s下,做出Action a,比其他动作能带来多少优势。</p>
<script type="math/tex; mode=display">
\frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n} A_\theta\left(s_n^t, a_n^t\right) \nabla \log P_\theta\left(a_n^t \mid s_n^t\right)</script><p>动作状态函数</p>
<p>价值状态函数</p>
<p>下面第一个是seigema 表达是<br>第二个GAE优势函数表达式<br>第三个是:策略梯度优化目标函数</p>
<script type="math/tex; mode=display">
\begin{aligned}
& \delta_t^V=r_t+\gamma * V_\theta\left(s_{t+1}\right)-V_\theta\left(s_t\right) \\
& A_\theta^{G A E}\left(s_t, a\right)=\sum_{b=0}^{\infty}(\gamma \lambda)^b \delta_{t+b}^V \\
& \frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n} A_\theta^{G A E}\left(s_n^t, a_n^t\right) \nabla \log P_\theta\left(a_n^t \mid s_n^t\right)
\end{aligned}</script><p>ppo算法:</p>
<script type="math/tex; mode=display">
\begin{gathered}
\operatorname{Loss}_{p p o}=-\frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n} A_{\theta^{\prime}}^{G A E}\left(s_n^t, a_n^t\right) \frac{P_\theta\left(a_n^t \mid s_n^t\right)}{P_{\theta^{\prime}}\left(a_n^t \mid s_n^t\right)}+\beta K L\left(P_\theta, P_{\theta^{\prime}}\right) \\
\operatorname{Loss}_{p p o 2}=-\frac{1}{N} \sum_{n=1}^N \sum_{t=1}^{T_n} \min \left(A_{\theta^{\prime}}^{G A E}\left(s_n^t, a_n^t\right) \frac{P_\theta\left(a_n^t \mid s_n^t\right)}{P_{\theta^{\prime}}\left(a_n^t \mid s_n^t\right)}, \operatorname{clip}\left(\frac{P_\theta\left(a_n^t \mid s_n^t\right)}{P_{\theta^{\prime}}\left(a_n^t \mid s_n^t\right)}, 1-\varepsilon, 1+\varepsilon\right) A_{\theta^{\prime}}^{G A E}\left(s_n^t, a_n^t\right)\right)
\end{gathered}</script>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2022/06/06/knowledge-based-Dialog-system/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/06/06/knowledge-based-Dialog-system/" class="post-title-link" itemprop="url">knowledge-based Dialog system</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-06-06 16:14:20" itemprop="dateCreated datePublished" datetime="2022-06-06T16:14:20+08:00">2022-06-06</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2022-06-10 20:47:24" itemprop="dateModified" datetime="2022-06-10T20:47:24+08:00">2022-06-10</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>在Task-oriented-Dialog任务中,[1]提到任务导向型端到端对话系统主要的面临的问题是:第一个是如何有效结合外部的知识到模型的学习框架之中,第二个是如何准确的捕获历史对话的语义信息,通过KG的方式,可以获得更充分的信息知识,比如说多跳的知识信息的查询,这相比较于传统的关系型数据库的查找有更大的优势。</p>
<p>QA任务可以认为是一种单轮对话模式的对话系统,在QA任务中运用知识为对话提供知识的方式有多种多样,在[2]中提到了关于如何结合KG做自然流畅的QA问题,主要运用了seq-seq模型和copy机制,和对相关topic实体的retrival。[3]中将自然语言转换为相应的语义解析器,主要提出了一种结合memory network机制的RNN based的转换网络,其主要贡献为通过memory network优化了在经常遇到省略现象的交互中找到指代实体。[4]遍历符号知识图谱以学习对话中的上下文转换,并使用注意力知识图谱路径解码器预测实体从而响应用户相关信息<br>通过知识图谱结的构化知识提供了信息丰富的常识观察并充当关系归纳偏差,这促进了最近关于多跳推理的符号空间和语义空间之间的常识知识融合的研究[5],</p>
<p>在开放域对话系统中,通过知识图谱中的知识增强,可以使得对话系统的话语中的知识符合世界知识,防止出现存储在模型参数中错误知识的生成[6].[7]进一步通过外部知识完成预训练模型的工作,通过引入知识信息增强对话的真实性。</p>
<p>另外,通过对话系统结合知识图谱完成对话推荐也是一个十分有趣的研究方向[8]</p>
<p>[1]GraphDialog: Integrating Graph Knowledge into End-to-End Task-Oriented Dialogue Systems</p>
<p>[2]Generating natural answers by incorporating copying and retrieving mechanisms in sequence-to-sequence learning</p>
<p>[3]Dialog-to-Action: Conversational Question Answering Over a Large-Scale Knowledge Base</p>
<p>[4]OpenDialKG: Explainable Conversational Reasoning with Attention-based Walks over Knowledge Graphs</p>
<p>[5]Commonsense for generative multi-hop question answering task</p>
<p>[6]Neural generative question answering</p>
<p>[7]PLATO: Pre-trained Dialogue Generation Model with Discrete Latent Variable</p>
<p>[8]Towards Knowledge-Based Recommender Dialog System</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2022/05/26/Grammar-Induction-for-Spoken-Dialogue-Systems/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/05/26/Grammar-Induction-for-Spoken-Dialogue-Systems/" class="post-title-link" itemprop="url">Grammar Induction for Spoken Dialogue Systems</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-05-26 00:38:31" itemprop="dateCreated datePublished" datetime="2022-05-26T00:38:31+08:00">2022-05-26</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2022-06-05 11:36:31" itemprop="dateModified" datetime="2022-06-05T11:36:31+08:00">2022-06-05</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>之前实习的时候做过一些语法推导(Grammar Induction)方面的工作,当时用的方法主要基于N-gram的一些推导,虽然工作量大,但是基本上属于baseline的方法,最近空下来,打算对这部分内容进行深入的研究和学习。<br>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2022/05/26/Grammar-Induction-for-Spoken-Dialogue-Systems/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2022/05/21/Parameter-Efficient-Transfer-Learning/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/05/21/Parameter-Efficient-Transfer-Learning/" class="post-title-link" itemprop="url">Parameter Efficient Transfer Learning</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-05-21 19:38:07" itemprop="dateCreated datePublished" datetime="2022-05-21T19:38:07+08:00">2022-05-21</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2022-05-24 22:53:04" itemprop="dateModified" datetime="2022-05-24T22:53:04+08:00">2022-05-24</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>这两天读了一些(两篇..)关于Parameter Efficient的文章,结构并不复杂,但是感觉还是有些内容可以分享。</p>
<h3 id="什么是参数高效的迁移学习呢?"><a href="#什么是参数高效的迁移学习呢?" class="headerlink" title="什么是参数高效的迁移学习呢?"></a>什么是参数高效的迁移学习呢?</h3><p>在自然语言处理的任务中,目前各个任务中常用的方法普遍基于Transformer模型,更具体来说,基于以Transformer的backbone模型的大规模预训练模型,以此为基础在各种任务上进行fine-tuning。通常情况下,<br>会对所有的模型参数进行微调,当然,通过这样的方式,可以更容易使得模型达到比较好的效果。因此也是大多数工作所进行的方式。</p>
<p>但是呢,这就会衍生出一个问题,首先,训练和部署效率的问题,先说训练,对于全局模型进行微调势必会消耗大量算力以及有一点点费电,那当然也可以通过frozen预训练模型在下有任务微调,这就和今天的主题有些相似了。另外呢,如果有很多很多的任务,你对每一个任务都进行fine-tuning,然后部署保存模型,对于现在动辄billion级别的模型参数来说,比如说你一个模型10GB,那你有100个任务,则需要1TB的存储量。</p>
<p>这时候,如果我们可以插入一小部分网络结构并且只对这一小部分进行微调就能达到一个比较好的效果,岂不美哉。</p>
<p>因此关于这部分的内容就应运而生。<br>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2022/05/21/Parameter-Efficient-Transfer-Learning/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2022/05/01/Bertology-%E8%AF%B4%E4%B8%80%E8%AF%B4%E9%82%A3%E4%BA%9B%E4%B8%8D%E4%B8%BA%E4%BA%BA%E7%9F%A5%E7%9A%84%E7%BB%86%E8%8A%82/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/05/01/Bertology-%E8%AF%B4%E4%B8%80%E8%AF%B4%E9%82%A3%E4%BA%9B%E4%B8%8D%E4%B8%BA%E4%BA%BA%E7%9F%A5%E7%9A%84%E7%BB%86%E8%8A%82/" class="post-title-link" itemprop="url">Bertology:说一说那些不为人知的细节</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-05-01 16:16:22" itemprop="dateCreated datePublished" datetime="2022-05-01T16:16:22+08:00">2022-05-01</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2022-05-08 17:31:00" itemprop="dateModified" datetime="2022-05-08T17:31:00+08:00">2022-05-08</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="序言"><a href="#序言" class="headerlink" title="序言"></a>序言</h1><p>自 Transformer 模型的文章<a href="https://proceedings.neurips.cc/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" target="_blank" rel="noopener">《Attention is all you need》</a>这篇经典发表的时刻,整个自然语言处理界发生了天翻地覆的变化,强大的注意力机制使得模型能够摆脱RNN模型的长时依赖的问题,且在各种NLP下游任务中,效果吊打RNN系列模型。随后经典名作GPT,BERT这些预训练模型的paper相继发表,从此NLP进入预训练时代。由于其对基础的语意句法等nlp的特征超强的捕获能力,基于Transformer系列的backbone预训练模型在下游任务微调成一种常用的方法。</p>
<p>虽然每年有大量的前沿研究基于Bert这样的模型,但是很多文章—-表面是对模型进行了创新获得了不错的效果,究其本质,无非是扩大了模型的参数量,提高训练数据的质量和数量。因此,取得了更为理想的效果。关于为什么模型的效果好,以及每一层的神经网络到底是取得了如何的效果则没有系统的阐释。今天读到了一篇<a href="https://watermark.silverchair.com/tacl_a_00349.pdf?token=AQECAHi208BE49Ooan9kkhW_Ercy7Dm3ZL_9Cf3qfKAc485ysgAAAsowggLGBgkqhkiG9w0BBwagggK3MIICswIBADCCAqwGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM356qe6dtueuLMY59AgEQgIICfeMIeHCgVGdSvJu8D2XfjC5ElP1yXiIVEdIbGODaHM9mO1WisSSW5owwhoZNils1hOJUETd_3bZvcHmLZBMUwDPl90BJI5W5psceyCep9D5F3qW-dy31dxzM2bWVKBUjHL7WE7vcbad4Cvrzq_AlR36jArY0mhSc5ekJJRdbTNMHtskqingzrFuLz8eR1yUpWpq8kDtceTZV1zBJCM_NVinFFwwt1eh9cn7n8PVEm4em5fj912Oo77yMTPnr_6nPORwVjl9ZuboiKWTzV0XJz3TO-PxXcUD_mg-6DdbsS9hXibOZ3oz9bVpXVGKW6XYFOs7BzHT6A6M9lDDKDtAp2R9iBqajMyhukiB1bB6VA0ePRke64wdJ17CF9xibbH8FqlDlaYhieRLmc7DTWbIFA15hsM7Aq1iwB9mYQ49eur0aCzZSZJWRrxugqSs3MuNSnjzJvClzEQwKRBToWUFfQ0FlxG0vpOfswjZz2PnDBDhOZD6VvVF0Gs1I19RJsoaMAxfI5lMNk3tSsvxcsFbRms7EOTXG6O0qlkCsMF4GfaGp6wQq9rsAmgQsGHu1wecwwRrMveNbF7dd-0crKukSCUwZOCXM0_qn5BiOOflI4LXAjJZ6T5A1kseghSFTFHLNM1no4Vxa6tdLY-njxhK50ib5Cytrunc58Kc1qwQbahB3x4UVlKm8ww14pFjnLi2e1nJJi-_YWdu1JNuI6RbhsM_GS1iSxu6KmsH49DTy0urourShCVC-23Y6KM91pry926KPk2r_gGzmoIwC0FSGZ-FCIlMzUING1XRyVlPR9P414Ifv1_hSJKldyzljyMyte-HJhKunk9uuuWOa6f8" target="_blank" rel="noopener">《A Primer in BERTology: What We Know About How BERTWorks》</a>发表于Transactions of the Association for Computational Linguistics。这篇文章对于bert模型的一些细节进行了系统的论述,很全面,因此,读了一下,把它分享给大家。</p>
<h1 id="动机"><a href="#动机" class="headerlink" title="动机"></a>动机</h1><p>众所周知,BERT已经在nlp领域大杀四方,但是对于“why it works well”相对来说没有那么多的研究。如此一来,想要更进一步做出更加solid的研究,需要对该模型有更多的了解。 相比较一些经典的backbone,比如说卷积神经网络(CNN),在感性上的动机则没有特别明显。我们希望对其中的一些结构进行分析,使得模型中具体所做的事情更容易被人们所认识,但是,对于模型过于大的尺寸所造成的预训练不好做(大部分研究人员没有超多的显卡,以及预训练所耗费的经费十分多)且想要做消融实验并不容易。因此对于近些年来对解释bert的文章做一个综述,方便大家对于该模型的认识。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2022/05/01/Bertology-%E8%AF%B4%E4%B8%80%E8%AF%B4%E9%82%A3%E4%BA%9B%E4%B8%8D%E4%B8%BA%E4%BA%BA%E7%9F%A5%E7%9A%84%E7%BB%86%E8%8A%82/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2022/04/18/bilstm-crf-batch-%E7%9A%84%E5%AE%9E%E7%8E%B0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/04/18/bilstm-crf-batch-%E7%9A%84%E5%AE%9E%E7%8E%B0/" class="post-title-link" itemprop="url">bilstm+crf(batch)的实现</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-04-18 21:27:11 / 修改时间:21:40:45" itemprop="dateCreated datePublished" datetime="2022-04-18T21:27:11+08:00">2022-04-18</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="batch版本的条件随机场"><a href="#batch版本的条件随机场" class="headerlink" title="batch版本的条件随机场"></a>batch版本的条件随机场</h2><p>在上一篇文章中我们按照了 pytorch的官方教程复现了 简单版本的 条件随机场。基本了解了其中的代码实现。但是我们可以看到上一篇中的 crf需要反复的条件循环,同时也没有支持批处理的操作,如果实际应用的话,速度应该会慢很多,因此,在这里,我们实现了Batch版本的条件随机场。to be honest, batch版本相比较 傻瓜版本的实现有一丢丢的复杂,尤其是需要考虑大量的矩阵并行的操作,十分伤脑筋。还好,我参考了<a href="https://github.com/jtlin-sync/batch_bilstm_crf" target="_blank" rel="noopener">batch lstm+crf</a>代码并且认真的剖析其中的细节后,基本弄清了其中的实现细节。如果你对 这部分代码感兴趣,可以参考我下面的代码跑起来学一学。在这部分代码中,一些核心地方给出了注释,但是可能仍然不够清晰,希望你可以自己画画图搞清楚这些细节。<br>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2022/04/18/bilstm-crf-batch-%E7%9A%84%E5%AE%9E%E7%8E%B0/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2022/04/15/pytorch%E7%89%88%E6%9C%AC%E7%9A%84bilstm-crf%E7%9A%84%E5%AE%9E%E7%8E%B0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/04/15/pytorch%E7%89%88%E6%9C%AC%E7%9A%84bilstm-crf%E7%9A%84%E5%AE%9E%E7%8E%B0/" class="post-title-link" itemprop="url">pytorch版本的bilstm+crf的实现</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-04-15 01:12:00 / 修改时间:15:28:31" itemprop="dateCreated datePublished" datetime="2022-04-15T01:12:00+08:00">2022-04-15</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="CRF-代码实现"><a href="#CRF-代码实现" class="headerlink" title="CRF 代码实现"></a>CRF 代码实现</h2><p>最近没啥事情,想把CRF相关的内容再捋一捋,因此研究了Pytoch的CRF实现,代码如下展示,之后将会研究如何做batch版本的CRF。</p>
<p>关于CRF的实现,表面上和HMM模型基本一致,从我的角度来看,因为其观测矩阵的实现由模型给出,即 $P(Y|X)$,因此其展示的是判别模型。所以才认为其是CRF模型,<br>如果变成隐马尔可夫模型,需要建模$P(Y,X)$, 十分有趣,不同观测矩阵的给出方式决定了模型的类型。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2022/04/15/pytorch%E7%89%88%E6%9C%AC%E7%9A%84bilstm-crf%E7%9A%84%E5%AE%9E%E7%8E%B0/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2022/04/10/kmeans-numpy%E5%AE%9E%E7%8E%B0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/04/10/kmeans-numpy%E5%AE%9E%E7%8E%B0/" class="post-title-link" itemprop="url">kmeans numpy实现</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-04-10 16:11:32 / 修改时间:16:24:33" itemprop="dateCreated datePublished" datetime="2022-04-10T16:11:32+08:00">2022-04-10</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="k-means算法"><a href="#k-means算法" class="headerlink" title="k-means算法"></a>k-means算法</h2><p>k-means作为基本的无监督机器学习算法,在一些面试场景下经常会被拉起来让做手动实现,算法本身其实不难,但在面试场景下复现的准确且简洁则十分重要,因此,本篇博文实现了k-means基本算法,希望大家都可以动手自己实现一遍以保证在需要手写的时候能够快速完成。关于k-means算法的基本原理,我相信大家都应该十分的清楚,因此在这个不多展开介绍,不懂的同学请自行百度或者Google。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2022/04/10/kmeans-numpy%E5%AE%9E%E7%8E%B0/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2022/04/01/Pytorch-Autograd-%E6%9C%BA%E5%88%B6%E4%BB%8B%E7%BB%8D/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/tb3.jpeg">
<meta itemprop="name" content="bool_tbb">
<meta itemprop="description" content="关于一些在NLP领域的学习总结,或者随便写点啥。">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Bool_tbb">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/04/01/Pytorch-Autograd-%E6%9C%BA%E5%88%B6%E4%BB%8B%E7%BB%8D/" class="post-title-link" itemprop="url">Pytorch Autograd 机制介绍</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-04-01 14:23:16" itemprop="dateCreated datePublished" datetime="2022-04-01T14:23:16+08:00">2022-04-01</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2022-04-02 21:20:33" itemprop="dateModified" datetime="2022-04-02T21:20:33+08:00">2022-04-02</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="什么是-Autograd"><a href="#什么是-Autograd" class="headerlink" title="什么是 Autograd?"></a>什么是 Autograd?</h2><p>Autograd是反向自动微分系统。从概念上讲,autograd 记录一个图结构,记录执行操作时创建数据的所有操作,一个有向无环图,其叶子是输入张量,根是输出张量。通过从根到叶跟踪此图,可以使用链式法则自动计算梯度。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2022/04/01/Pytorch-Autograd-%E6%9C%BA%E5%88%B6%E4%BB%8B%E7%BB%8D/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<nav class="pagination">
<span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
</nav>
</div>
</div>
<div class="toggle sidebar-toggle">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
<aside class="sidebar">
<div class="sidebar-inner">
<ul class="sidebar-nav motion-element">
<li class="sidebar-nav-toc">
文章目录
</li>
<li class="sidebar-nav-overview">
站点概览
</li>
</ul>
<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
</div>