You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

fastnlp_tutorial_paddle_e1.ipynb 58 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# 使用 paddlenlp 和 FastNLP 实现中文文本情感分析\n",
  8. "\n",
  9. "本篇教程属于 **`FastNLP v0.8 tutorial` 的 `paddle examples` 系列**。在本篇教程中,我们将为您展示如何使用 `paddlenlp` 自然语言处理库和 `FastNLP` 来完成比较简单的情感分析任务。\n",
  10. "\n",
  11. "1. 基础介绍:飞桨自然语言处理库 ``paddlenlp`` 和语义理解框架 ``ERNIE``\n",
  12. "\n",
  13. "2. 准备工作:使用 ``tokenizer`` 处理数据并构造 ``dataloader``\n",
  14. "\n",
  15. "3. 模型训练:加载 ``ERNIE`` 预训练模型,使用 ``FastNLP`` 进行训练"
  16. ]
  17. },
  18. {
  19. "cell_type": "markdown",
  20. "metadata": {},
  21. "source": [
  22. "### 1. 基础介绍:飞桨自然语言处理库 paddlenlp 和语义理解框架 ERNIE\n",
  23. "\n",
  24. "#### 1.1 飞桨自然语言处理库 paddlenlp\n",
  25. "\n",
  26. "``paddlenlp`` 是由百度以飞桨 ``PaddlePaddle`` 为核心开发的自然语言处理库,集成了多个数据集和 NLP 模型,包括百度自研的语义理解框架 ``ERNIE`` 。在本篇教程中,我们会以 ``paddlenlp`` 为基础,使用模型 ``ERNIE`` 完成中文情感分析任务。"
  27. ]
  28. },
  29. {
  30. "cell_type": "code",
  31. "execution_count": 8,
  32. "metadata": {},
  33. "outputs": [
  34. {
  35. "name": "stdout",
  36. "output_type": "stream",
  37. "text": [
  38. "2.3.3\n"
  39. ]
  40. }
  41. ],
  42. "source": [
  43. "import sys\n",
  44. "sys.path.append(\"../\")\n",
  45. "\n",
  46. "import paddle\n",
  47. "import paddlenlp\n",
  48. "from paddlenlp.transformers import AutoTokenizer\n",
  49. "from paddlenlp.transformers import AutoModelForSequenceClassification\n",
  50. "\n",
  51. "print(paddlenlp.__version__)"
  52. ]
  53. },
  54. {
  55. "cell_type": "markdown",
  56. "metadata": {},
  57. "source": [
  58. "#### 1.2 语义理解框架 ERNIE\n",
  59. "\n",
  60. "``ERNIE(Enhanced Representation from kNowledge IntEgration)`` 是百度提出的基于知识增强的持续学习语义理解框架,至今已有 ``ERNIE 2.0``、``ERNIE 3.0``、``ERNIE-M``、``ERNIE-tiny`` 等多种预训练模型。``ERNIE 1.0`` 采用``Transformer Encoder`` 作为其语义表示的骨架,并改进了两种 ``mask`` 策略,分别为基于**短语**和**实体**(人名、组织等)的策略。在 ``ERNIE`` 中,由多个字组成的短语或者实体将作为一个统一单元,在训练的时候被统一地 ``mask`` 掉,这样可以潜在地学习到知识的依赖以及更长的语义依赖来让模型更具泛化性。\n",
  61. "\n",
  62. "<img src=\"./figures/paddle-ernie-1.0-masking.png\" width=\"50%\" height=\"50%\" align=\"center\"></img>\n",
  63. "\n",
  64. "<img src=\"./figures/paddle-ernie-1.0-masking-levels.png\" width=\"70%\" height=\"70%\" align=\"center\"></img>\n",
  65. "\n",
  66. "``ERNIE 2.0`` 则提出了连续学习(``Continual Learning``)的概念,即首先用一个简单的任务来初始化模型,在更新时用前一个任务训练好的参数作为下一个任务模型初始化的参数。这样在训练新的任务时,模型便可以记住之前学习到的知识,使得模型在新任务上获得更好的表现。``ERNIE 2.0`` 分别构建了词法、语法、语义不同级别的预训练任务,并使用不同的 task id 来标示不同的任务,在共计16个中英文任务上都取得了SOTA效果。\n",
  67. "\n",
  68. "<img src=\"./figures/paddle-ernie-2.0-continual-pretrain.png\" width=\"70%\" height=\"70%\" align=\"center\"></img>\n",
  69. "\n",
  70. "``ERNIE 3.0`` 将自回归和自编码网络融合在一起进行预训练,其中自编码网络采用 ``ERNIE 2.0`` 的多任务学习增量式构建预训练任务,持续进行语义理解学习。其中自编码网络增加了知识增强的预训练任务。自回归网络则基于 ``Tranformer-XL`` 结构,支持长文本语言模型建模,并在多个自然语言处理任务中取得了SOTA的效果。\n",
  71. "\n",
  72. "<img src=\"./figures/paddle-ernie-3.0-framework.png\" width=\"50%\" height=\"50%\" align=\"center\"></img>\n",
  73. "\n",
  74. "接下来,我们将展示如何在 ``FastNLP`` 中使用基于 ``paddle`` 的 ``ERNIE 1.0`` 框架进行中文情感分析。"
  75. ]
  76. },
  77. {
  78. "cell_type": "markdown",
  79. "metadata": {},
  80. "source": [
  81. "### 2. 使用 tokenizer 处理数据并构造 dataloader\n",
  82. "\n",
  83. "#### 2.1 加载中文数据集 ChnSentiCorp\n",
  84. "\n",
  85. "``ChnSentiCorp`` 数据集是由中国科学院发布的中文句子级情感分析数据集,包含了从网络上获取的酒店、电影、书籍等多个领域的评论,每条评论都被划分为两个标签:消极(``0``)和积极(``1``),可以用于二分类的中文情感分析任务。通过 ``paddlenlp.datasets.load_dataset`` 函数,我们可以加载并查看 ``ChnSentiCorp`` 数据集的内容。"
  86. ]
  87. },
  88. {
  89. "cell_type": "code",
  90. "execution_count": 9,
  91. "metadata": {},
  92. "outputs": [
  93. {
  94. "name": "stdout",
  95. "output_type": "stream",
  96. "text": [
  97. "训练集大小: 9600\n",
  98. "{'text': '选择珠江花园的原因就是方便,有电动扶梯直接到达海边,周围餐馆、食廊、商场、超市、摊位一应俱全。酒店装修一般,但还算整洁。 泳池在大堂的屋顶,因此很小,不过女儿倒是喜欢。 包的早餐是西式的,还算丰富。 服务吗,一般', 'label': 1, 'qid': ''}\n",
  99. "{'text': '15.4寸笔记本的键盘确实爽,基本跟台式机差不多了,蛮喜欢数字小键盘,输数字特方便,样子也很美观,做工也相当不错', 'label': 1, 'qid': ''}\n",
  100. "{'text': '房间太小。其他的都一般。。。。。。。。。', 'label': 0, 'qid': ''}\n"
  101. ]
  102. }
  103. ],
  104. "source": [
  105. "from paddlenlp.datasets import load_dataset\n",
  106. "\n",
  107. "train_dataset, val_dataset, test_dataset = load_dataset(\"chnsenticorp\", splits=[\"train\", \"dev\", \"test\"])\n",
  108. "print(\"训练集大小:\", len(train_dataset))\n",
  109. "for i in range(3):\n",
  110. " print(train_dataset[i])"
  111. ]
  112. },
  113. {
  114. "cell_type": "markdown",
  115. "metadata": {},
  116. "source": [
  117. "#### 2.2 处理数据\n",
  118. "\n",
  119. "可以看到,原本的数据集仅包含中文的文本和标签,这样的数据是无法被模型识别的。同英文文本分类任务一样,我们需要使用 ``tokenizer`` 对文本进行分词并转换为数字形式的结果。我们可以加载已经预训练好的中文分词模型 ``ernie-1.0-base-zh``,将分词的过程写在函数 ``_process`` 中,然后调用数据集的 ``map`` 函数对每一条数据进行分词。其中:\n",
  120. "- 参数 ``max_length`` 代表句子的最大长度;\n",
  121. "- ``padding=\"max_length\"`` 表示将长度不足的结果 padding 至和最大长度相同;\n",
  122. "- ``truncation=True`` 表示将长度过长的句子进行截断。\n",
  123. "\n",
  124. "至此,我们得到了每条数据长度均相同的数据集。"
  125. ]
  126. },
  127. {
  128. "cell_type": "code",
  129. "execution_count": 10,
  130. "metadata": {},
  131. "outputs": [
  132. {
  133. "name": "stderr",
  134. "output_type": "stream",
  135. "text": [
  136. "\u001b[32m[2022-06-22 21:31:04,168] [ INFO]\u001b[0m - We are using <class 'paddlenlp.transformers.ernie.tokenizer.ErnieTokenizer'> to load 'ernie-1.0-base-zh'.\u001b[0m\n",
  137. "\u001b[32m[2022-06-22 21:31:04,171] [ INFO]\u001b[0m - Already cached /remote-home/shxing/.paddlenlp/models/ernie-1.0-base-zh/vocab.txt\u001b[0m\n"
  138. ]
  139. },
  140. {
  141. "name": "stdout",
  142. "output_type": "stream",
  143. "text": [
  144. "{'text': '选择珠江花园的原因就是方便,有电动扶梯直接到达海边,周围餐馆、食廊、商场、超市、摊位一应俱全。酒店装修一般,但还算整洁。 泳池在大堂的屋顶,因此很小,不过女儿倒是喜欢。 包的早餐是西式的,还算丰富。 服务吗,一般', 'label': 1, 'qid': '', 'input_ids': [1, 352, 790, 1252, 409, 283, 509, 5, 250, 196, 113, 10, 58, 518, 4, 9, 128, 70, 1495, 1855, 339, 293, 45, 302, 233, 554, 4, 544, 637, 1134, 774, 6, 494, 2068, 6, 278, 191, 6, 634, 99, 6, 2678, 144, 7, 149, 1573, 62, 12043, 661, 737, 371, 435, 7, 689, 4, 255, 201, 559, 407, 1308, 12043, 2275, 1110, 11, 19, 842, 5, 1207, 878, 4, 196, 198, 321, 96, 4, 16, 93, 291, 464, 1099, 10, 692, 811, 12043, 392, 5, 748, 1134, 10, 213, 220, 5, 4, 201, 559, 723, 595, 12043, 231, 112, 1114, 4, 7, 689, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}\n"
  145. ]
  146. }
  147. ],
  148. "source": [
  149. "max_len = 128\n",
  150. "model_checkpoint = \"ernie-1.0-base-zh\"\n",
  151. "tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)\n",
  152. "def _process(data):\n",
  153. " data.update(tokenizer(\n",
  154. " data[\"text\"],\n",
  155. " max_length=max_len,\n",
  156. " padding=\"max_length\",\n",
  157. " truncation=True,\n",
  158. " return_attention_mask=True,\n",
  159. " ))\n",
  160. " return data\n",
  161. "\n",
  162. "train_dataset.map(_process, num_workers=5)\n",
  163. "val_dataset.map(_process, num_workers=5)\n",
  164. "test_dataset.map(_process, num_workers=5)\n",
  165. "\n",
  166. "print(train_dataset[0])"
  167. ]
  168. },
  169. {
  170. "cell_type": "markdown",
  171. "metadata": {},
  172. "source": [
  173. "得到数据集之后,我们便可以将数据集包裹在 ``PaddleDataLoader`` 中,用于之后的训练。``FastNLP`` 提供的 ``PaddleDataLoader`` 拓展了 ``paddle.io.DataLoader`` 的功能,详情可以查看相关的文档。"
  174. ]
  175. },
  176. {
  177. "cell_type": "code",
  178. "execution_count": 11,
  179. "metadata": {},
  180. "outputs": [],
  181. "source": [
  182. "from fastNLP.core import PaddleDataLoader\n",
  183. "import paddle.nn as nn\n",
  184. "\n",
  185. "train_dataloader = PaddleDataLoader(train_dataset, batch_size=32, shuffle=True)\n",
  186. "val_dataloader = PaddleDataLoader(val_dataset, batch_size=32, shuffle=False)\n",
  187. "test_dataloader = PaddleDataLoader(test_dataset, batch_size=1, shuffle=False)"
  188. ]
  189. },
  190. {
  191. "cell_type": "markdown",
  192. "metadata": {},
  193. "source": [
  194. "### 3. 模型训练:加载 ERNIE 预训练模型,使用 FastNLP 进行训练\n",
  195. "\n",
  196. "#### 3.1 使用 ERNIE 预训练模型\n",
  197. "\n",
  198. "为了实现文本分类,我们首先需要定义文本分类的模型。``paddlenlp.transformers`` 提供了模型 ``AutoModelForSequenceClassification``,我们可以利用它来加载不同权重的文本分类模型。在 ``FastNLP`` 中,我们可以定义 ``train_step`` 和 ``evaluate_step`` 函数来实现训练和验证过程中的不同行为。\n",
  199. "\n",
  200. "- ``train_step`` 函数在获得返回值 ``logits`` (大小为 ``(batch_size, num_labels)``)后计算交叉熵损失 ``CrossEntropyLoss``,然后将 ``loss`` 放在字典中返回。``FastNLP`` 也支持返回 ``dataclass`` 类型的训练结果,但二者都需要包含名为 **``loss``** 的键或成员。\n",
  201. "- ``evaluate_step`` 函数在获得返回值 ``logits`` 后,将 ``logits`` 和标签 ``label`` 放在字典中返回。\n",
  202. "\n",
  203. "这两个函数的参数均为数据集中字典**键**的子集,``FastNLP`` 会自动进行参数匹配然后输入到模型中。"
  204. ]
  205. },
  206. {
  207. "cell_type": "code",
  208. "execution_count": 12,
  209. "metadata": {},
  210. "outputs": [
  211. {
  212. "name": "stderr",
  213. "output_type": "stream",
  214. "text": [
  215. "\u001b[32m[2022-06-22 21:31:15,577] [ INFO]\u001b[0m - We are using <class 'paddlenlp.transformers.ernie.modeling.ErnieForSequenceClassification'> to load 'ernie-1.0-base-zh'.\u001b[0m\n",
  216. "\u001b[32m[2022-06-22 21:31:15,580] [ INFO]\u001b[0m - Already cached /remote-home/shxing/.paddlenlp/models/ernie-1.0-base-zh/ernie_v1_chn_base.pdparams\u001b[0m\n"
  217. ]
  218. }
  219. ],
  220. "source": [
  221. "import paddle.nn as nn\n",
  222. "\n",
  223. "class SeqClsModel(nn.Layer):\n",
  224. " def __init__(self, model_checkpoint, num_labels):\n",
  225. " super(SeqClsModel, self).__init__()\n",
  226. " self.model = AutoModelForSequenceClassification.from_pretrained(\n",
  227. " model_checkpoint,\n",
  228. " num_classes=num_labels,\n",
  229. " )\n",
  230. "\n",
  231. " def forward(self, input_ids, attention_mask, token_type_ids):\n",
  232. " logits = self.model(input_ids, attention_mask=attention_mask, token_type_ids=token_type_ids)\n",
  233. " return logits\n",
  234. "\n",
  235. " def train_step(self, input_ids, attention_mask, token_type_ids, label):\n",
  236. " logits = self(input_ids, attention_mask, token_type_ids)\n",
  237. " loss = nn.CrossEntropyLoss()(logits, label)\n",
  238. " return {\"loss\": loss}\n",
  239. "\n",
  240. " def evaluate_step(self, input_ids, attention_mask, token_type_ids, label):\n",
  241. " logits = self(input_ids, attention_mask, token_type_ids)\n",
  242. " return {'pred': logits, 'target': label}\n",
  243. "\n",
  244. "model = SeqClsModel(model_checkpoint, num_labels=2)"
  245. ]
  246. },
  247. {
  248. "cell_type": "markdown",
  249. "metadata": {},
  250. "source": [
  251. "#### 3.2 设置参数并使用 Trainer 开始训练\n",
  252. "\n",
  253. "现在我们可以着手使用 ``FastNLP.Trainer`` 进行训练了。\n",
  254. "\n",
  255. "首先,为了高效地训练 ``ERNIE`` 模型,我们最好为学习率指定一定的策略。``paddlenlp`` 提供的 ``LinearDecayWithWarmup`` 可以令学习率在一段时间内从 0 开始线性地增长(预热),然后再线性地衰减至 0 。在本篇教程中,我们将学习率设置为 ``5e-5``,预热时间为 ``0.1``,然后将得到的的 ``lr_scheduler`` 赋值给 ``AdamW`` 优化器。\n",
  256. "\n",
  257. "其次,我们还可以为 ``Trainer`` 指定多个 ``Callback`` 来在基础的训练过程之外进行额外的定制操作。在本篇教程中,我们使用的 ``Callback`` 有以下三种:\n",
  258. "\n",
  259. "- ``LRSchedCallback`` - 由于我们使用了 ``Scheduler``,因此需要将 ``lr_scheduler`` 传给该 ``Callback`` 以在训练中进行更新。\n",
  260. "- ``LoadBestModelCallback`` - 该 ``Callback`` 会评估结果中的 ``'acc#accuracy'`` 值,保存训练中出现的正确率最高的模型,并在训练结束时加载到模型上,方便对模型进行测试和评估。\n",
  261. "\n",
  262. "在 ``Trainer`` 中,我们还可以设置 ``metrics`` 来衡量模型的表现。``Accuracy`` 能够根据传入的预测值和真实值计算出模型预测的正确率。还记得模型中 ``evaluate_step`` 函数的返回值吗?键 ``pred`` 和 ``target`` 分别为 ``Accuracy.update`` 的参数名,在验证过程中 ``FastNLP`` 会自动将键和参数名匹配从而计算出正确率,这也是我们规定模型需要返回字典类型数据的原因。\n",
  263. "\n",
  264. "``Accuracy`` 的返回值包含三个部分:``acc``、``total`` 和 ``correct``,分别代表 ``正确率``、 ``数据总数`` 和 ``预测正确的数目``,这让您能够直观地知晓训练中模型的变化,``LoadBestModelCallback`` 的参数 ``'acc#accuracy'`` 也正是代表了 ``accuracy`` 指标的 ``acc`` 结果。\n",
  265. "\n",
  266. "在设定好参数之后,调用 ``run`` 函数便可以进行训练和验证了。"
  267. ]
  268. },
  269. {
  270. "cell_type": "code",
  271. "execution_count": 13,
  272. "metadata": {},
  273. "outputs": [
  274. {
  275. "data": {
  276. "text/html": [
  277. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">[21:31:16] </span><span style=\"color: #000080; text-decoration-color: #000080\">INFO </span> Running evaluator sanity check for <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span> batches. <a href=\"file://../fastNLP/core/controllers/trainer.py\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">trainer.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file://../fastNLP/core/controllers/trainer.py#631\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">631</span></a>\n",
  278. "</pre>\n"
  279. ],
  280. "text/plain": [
  281. "\u001b[2;36m[21:31:16]\u001b[0m\u001b[2;36m \u001b[0m\u001b[34mINFO \u001b[0m Running evaluator sanity check for \u001b[1;36m2\u001b[0m batches. \u001b]8;id=4641;file://../fastNLP/core/controllers/trainer.py\u001b\\\u001b[2mtrainer.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=822054;file://../fastNLP/core/controllers/trainer.py#631\u001b\\\u001b[2m631\u001b[0m\u001b]8;;\u001b\\\n"
  282. ]
  283. },
  284. "metadata": {},
  285. "output_type": "display_data"
  286. },
  287. {
  288. "data": {
  289. "text/html": [
  290. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
  291. ],
  292. "text/plain": []
  293. },
  294. "metadata": {},
  295. "output_type": "display_data"
  296. },
  297. {
  298. "data": {
  299. "text/html": [
  300. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  301. "</pre>\n"
  302. ],
  303. "text/plain": [
  304. "\n"
  305. ]
  306. },
  307. "metadata": {},
  308. "output_type": "display_data"
  309. },
  310. {
  311. "data": {
  312. "text/html": [
  313. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">60</span> -----------------------------\n",
  314. "</pre>\n"
  315. ],
  316. "text/plain": [
  317. "---------------------------- Eval. results on Epoch:\u001b[1;36m0\u001b[0m, Batch:\u001b[1;36m60\u001b[0m -----------------------------\n"
  318. ]
  319. },
  320. "metadata": {},
  321. "output_type": "display_data"
  322. },
  323. {
  324. "data": {
  325. "text/html": [
  326. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  327. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.895833</span>,\n",
  328. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  329. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1075.0</span>\n",
  330. "<span style=\"font-weight: bold\">}</span>\n",
  331. "</pre>\n"
  332. ],
  333. "text/plain": [
  334. "\u001b[1m{\u001b[0m\n",
  335. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.895833\u001b[0m,\n",
  336. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  337. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1075.0\u001b[0m\n",
  338. "\u001b[1m}\u001b[0m\n"
  339. ]
  340. },
  341. "metadata": {},
  342. "output_type": "display_data"
  343. },
  344. {
  345. "data": {
  346. "text/html": [
  347. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  348. "</pre>\n"
  349. ],
  350. "text/plain": [
  351. "\n"
  352. ]
  353. },
  354. "metadata": {},
  355. "output_type": "display_data"
  356. },
  357. {
  358. "data": {
  359. "text/html": [
  360. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">120</span> ----------------------------\n",
  361. "</pre>\n"
  362. ],
  363. "text/plain": [
  364. "---------------------------- Eval. results on Epoch:\u001b[1;36m0\u001b[0m, Batch:\u001b[1;36m120\u001b[0m ----------------------------\n"
  365. ]
  366. },
  367. "metadata": {},
  368. "output_type": "display_data"
  369. },
  370. {
  371. "data": {
  372. "text/html": [
  373. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  374. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.8975</span>,\n",
  375. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  376. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1077.0</span>\n",
  377. "<span style=\"font-weight: bold\">}</span>\n",
  378. "</pre>\n"
  379. ],
  380. "text/plain": [
  381. "\u001b[1m{\u001b[0m\n",
  382. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.8975\u001b[0m,\n",
  383. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  384. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1077.0\u001b[0m\n",
  385. "\u001b[1m}\u001b[0m\n"
  386. ]
  387. },
  388. "metadata": {},
  389. "output_type": "display_data"
  390. },
  391. {
  392. "data": {
  393. "text/html": [
  394. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  395. "</pre>\n"
  396. ],
  397. "text/plain": [
  398. "\n"
  399. ]
  400. },
  401. "metadata": {},
  402. "output_type": "display_data"
  403. },
  404. {
  405. "data": {
  406. "text/html": [
  407. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">180</span> ----------------------------\n",
  408. "</pre>\n"
  409. ],
  410. "text/plain": [
  411. "---------------------------- Eval. results on Epoch:\u001b[1;36m0\u001b[0m, Batch:\u001b[1;36m180\u001b[0m ----------------------------\n"
  412. ]
  413. },
  414. "metadata": {},
  415. "output_type": "display_data"
  416. },
  417. {
  418. "data": {
  419. "text/html": [
  420. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  421. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.911667</span>,\n",
  422. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  423. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1094.0</span>\n",
  424. "<span style=\"font-weight: bold\">}</span>\n",
  425. "</pre>\n"
  426. ],
  427. "text/plain": [
  428. "\u001b[1m{\u001b[0m\n",
  429. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.911667\u001b[0m,\n",
  430. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  431. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1094.0\u001b[0m\n",
  432. "\u001b[1m}\u001b[0m\n"
  433. ]
  434. },
  435. "metadata": {},
  436. "output_type": "display_data"
  437. },
  438. {
  439. "data": {
  440. "text/html": [
  441. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  442. "</pre>\n"
  443. ],
  444. "text/plain": [
  445. "\n"
  446. ]
  447. },
  448. "metadata": {},
  449. "output_type": "display_data"
  450. },
  451. {
  452. "data": {
  453. "text/html": [
  454. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">240</span> ----------------------------\n",
  455. "</pre>\n"
  456. ],
  457. "text/plain": [
  458. "---------------------------- Eval. results on Epoch:\u001b[1;36m0\u001b[0m, Batch:\u001b[1;36m240\u001b[0m ----------------------------\n"
  459. ]
  460. },
  461. "metadata": {},
  462. "output_type": "display_data"
  463. },
  464. {
  465. "data": {
  466. "text/html": [
  467. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  468. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.9225</span>,\n",
  469. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  470. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1107.0</span>\n",
  471. "<span style=\"font-weight: bold\">}</span>\n",
  472. "</pre>\n"
  473. ],
  474. "text/plain": [
  475. "\u001b[1m{\u001b[0m\n",
  476. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.9225\u001b[0m,\n",
  477. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  478. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1107.0\u001b[0m\n",
  479. "\u001b[1m}\u001b[0m\n"
  480. ]
  481. },
  482. "metadata": {},
  483. "output_type": "display_data"
  484. },
  485. {
  486. "data": {
  487. "text/html": [
  488. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  489. "</pre>\n"
  490. ],
  491. "text/plain": [
  492. "\n"
  493. ]
  494. },
  495. "metadata": {},
  496. "output_type": "display_data"
  497. },
  498. {
  499. "data": {
  500. "text/html": [
  501. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">300</span> ----------------------------\n",
  502. "</pre>\n"
  503. ],
  504. "text/plain": [
  505. "---------------------------- Eval. results on Epoch:\u001b[1;36m0\u001b[0m, Batch:\u001b[1;36m300\u001b[0m ----------------------------\n"
  506. ]
  507. },
  508. "metadata": {},
  509. "output_type": "display_data"
  510. },
  511. {
  512. "data": {
  513. "text/html": [
  514. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  515. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.9275</span>,\n",
  516. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  517. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1113.0</span>\n",
  518. "<span style=\"font-weight: bold\">}</span>\n",
  519. "</pre>\n"
  520. ],
  521. "text/plain": [
  522. "\u001b[1m{\u001b[0m\n",
  523. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.9275\u001b[0m,\n",
  524. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  525. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1113.0\u001b[0m\n",
  526. "\u001b[1m}\u001b[0m\n"
  527. ]
  528. },
  529. "metadata": {},
  530. "output_type": "display_data"
  531. },
  532. {
  533. "data": {
  534. "text/html": [
  535. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  536. "</pre>\n"
  537. ],
  538. "text/plain": [
  539. "\n"
  540. ]
  541. },
  542. "metadata": {},
  543. "output_type": "display_data"
  544. },
  545. {
  546. "data": {
  547. "text/html": [
  548. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">60</span> -----------------------------\n",
  549. "</pre>\n"
  550. ],
  551. "text/plain": [
  552. "---------------------------- Eval. results on Epoch:\u001b[1;36m1\u001b[0m, Batch:\u001b[1;36m60\u001b[0m -----------------------------\n"
  553. ]
  554. },
  555. "metadata": {},
  556. "output_type": "display_data"
  557. },
  558. {
  559. "data": {
  560. "text/html": [
  561. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  562. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.930833</span>,\n",
  563. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  564. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1117.0</span>\n",
  565. "<span style=\"font-weight: bold\">}</span>\n",
  566. "</pre>\n"
  567. ],
  568. "text/plain": [
  569. "\u001b[1m{\u001b[0m\n",
  570. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.930833\u001b[0m,\n",
  571. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  572. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1117.0\u001b[0m\n",
  573. "\u001b[1m}\u001b[0m\n"
  574. ]
  575. },
  576. "metadata": {},
  577. "output_type": "display_data"
  578. },
  579. {
  580. "data": {
  581. "text/html": [
  582. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  583. "</pre>\n"
  584. ],
  585. "text/plain": [
  586. "\n"
  587. ]
  588. },
  589. "metadata": {},
  590. "output_type": "display_data"
  591. },
  592. {
  593. "data": {
  594. "text/html": [
  595. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">120</span> ----------------------------\n",
  596. "</pre>\n"
  597. ],
  598. "text/plain": [
  599. "---------------------------- Eval. results on Epoch:\u001b[1;36m1\u001b[0m, Batch:\u001b[1;36m120\u001b[0m ----------------------------\n"
  600. ]
  601. },
  602. "metadata": {},
  603. "output_type": "display_data"
  604. },
  605. {
  606. "data": {
  607. "text/html": [
  608. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  609. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.935833</span>,\n",
  610. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  611. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1123.0</span>\n",
  612. "<span style=\"font-weight: bold\">}</span>\n",
  613. "</pre>\n"
  614. ],
  615. "text/plain": [
  616. "\u001b[1m{\u001b[0m\n",
  617. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.935833\u001b[0m,\n",
  618. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  619. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1123.0\u001b[0m\n",
  620. "\u001b[1m}\u001b[0m\n"
  621. ]
  622. },
  623. "metadata": {},
  624. "output_type": "display_data"
  625. },
  626. {
  627. "data": {
  628. "text/html": [
  629. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  630. "</pre>\n"
  631. ],
  632. "text/plain": [
  633. "\n"
  634. ]
  635. },
  636. "metadata": {},
  637. "output_type": "display_data"
  638. },
  639. {
  640. "data": {
  641. "text/html": [
  642. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">180</span> ----------------------------\n",
  643. "</pre>\n"
  644. ],
  645. "text/plain": [
  646. "---------------------------- Eval. results on Epoch:\u001b[1;36m1\u001b[0m, Batch:\u001b[1;36m180\u001b[0m ----------------------------\n"
  647. ]
  648. },
  649. "metadata": {},
  650. "output_type": "display_data"
  651. },
  652. {
  653. "data": {
  654. "text/html": [
  655. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  656. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.935833</span>,\n",
  657. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  658. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1123.0</span>\n",
  659. "<span style=\"font-weight: bold\">}</span>\n",
  660. "</pre>\n"
  661. ],
  662. "text/plain": [
  663. "\u001b[1m{\u001b[0m\n",
  664. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.935833\u001b[0m,\n",
  665. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  666. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1123.0\u001b[0m\n",
  667. "\u001b[1m}\u001b[0m\n"
  668. ]
  669. },
  670. "metadata": {},
  671. "output_type": "display_data"
  672. },
  673. {
  674. "data": {
  675. "text/html": [
  676. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  677. "</pre>\n"
  678. ],
  679. "text/plain": [
  680. "\n"
  681. ]
  682. },
  683. "metadata": {},
  684. "output_type": "display_data"
  685. },
  686. {
  687. "data": {
  688. "text/html": [
  689. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">240</span> ----------------------------\n",
  690. "</pre>\n"
  691. ],
  692. "text/plain": [
  693. "---------------------------- Eval. results on Epoch:\u001b[1;36m1\u001b[0m, Batch:\u001b[1;36m240\u001b[0m ----------------------------\n"
  694. ]
  695. },
  696. "metadata": {},
  697. "output_type": "display_data"
  698. },
  699. {
  700. "data": {
  701. "text/html": [
  702. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  703. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.9375</span>,\n",
  704. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  705. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1125.0</span>\n",
  706. "<span style=\"font-weight: bold\">}</span>\n",
  707. "</pre>\n"
  708. ],
  709. "text/plain": [
  710. "\u001b[1m{\u001b[0m\n",
  711. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.9375\u001b[0m,\n",
  712. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  713. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1125.0\u001b[0m\n",
  714. "\u001b[1m}\u001b[0m\n"
  715. ]
  716. },
  717. "metadata": {},
  718. "output_type": "display_data"
  719. },
  720. {
  721. "data": {
  722. "text/html": [
  723. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  724. "</pre>\n"
  725. ],
  726. "text/plain": [
  727. "\n"
  728. ]
  729. },
  730. "metadata": {},
  731. "output_type": "display_data"
  732. },
  733. {
  734. "data": {
  735. "text/html": [
  736. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">---------------------------- Eval. results on Epoch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>, Batch:<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">300</span> ----------------------------\n",
  737. "</pre>\n"
  738. ],
  739. "text/plain": [
  740. "---------------------------- Eval. results on Epoch:\u001b[1;36m1\u001b[0m, Batch:\u001b[1;36m300\u001b[0m ----------------------------\n"
  741. ]
  742. },
  743. "metadata": {},
  744. "output_type": "display_data"
  745. },
  746. {
  747. "data": {
  748. "text/html": [
  749. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">{</span>\n",
  750. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"acc#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.941667</span>,\n",
  751. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"total#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1200.0</span>,\n",
  752. " <span style=\"color: #000080; text-decoration-color: #000080; font-weight: bold\">\"correct#accuracy\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1130.0</span>\n",
  753. "<span style=\"font-weight: bold\">}</span>\n",
  754. "</pre>\n"
  755. ],
  756. "text/plain": [
  757. "\u001b[1m{\u001b[0m\n",
  758. " \u001b[1;34m\"acc#accuracy\"\u001b[0m: \u001b[1;36m0.941667\u001b[0m,\n",
  759. " \u001b[1;34m\"total#accuracy\"\u001b[0m: \u001b[1;36m1200.0\u001b[0m,\n",
  760. " \u001b[1;34m\"correct#accuracy\"\u001b[0m: \u001b[1;36m1130.0\u001b[0m\n",
  761. "\u001b[1m}\u001b[0m\n"
  762. ]
  763. },
  764. "metadata": {},
  765. "output_type": "display_data"
  766. },
  767. {
  768. "data": {
  769. "text/html": [
  770. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">[21:34:28] </span><span style=\"color: #000080; text-decoration-color: #000080\">INFO </span> Loading best model from fnlp-ernie/<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2022</span>-<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span> <a href=\"file://../fastNLP/core/callbacks/load_best_model_callback.py\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">load_best_model_callback.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file://../fastNLP/core/callbacks/load_best_model_callback.py#111\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">111</span></a>\n",
  771. "<span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\"> </span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">6</span>-<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>-21_29_12_898095/best_so_far with <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>\n",
  772. "<span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\"> </span> acc#accuracy: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.941667</span><span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>\n",
  773. "</pre>\n"
  774. ],
  775. "text/plain": [
  776. "\u001b[2;36m[21:34:28]\u001b[0m\u001b[2;36m \u001b[0m\u001b[34mINFO \u001b[0m Loading best model from fnlp-ernie/\u001b[1;36m2022\u001b[0m-\u001b[1;36m0\u001b[0m \u001b]8;id=340364;file://../fastNLP/core/callbacks/load_best_model_callback.py\u001b\\\u001b[2mload_best_model_callback.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=763898;file://../fastNLP/core/callbacks/load_best_model_callback.py#111\u001b\\\u001b[2m111\u001b[0m\u001b]8;;\u001b\\\n",
  777. "\u001b[2;36m \u001b[0m \u001b[1;36m6\u001b[0m-\u001b[1;36m22\u001b[0m-21_29_12_898095/best_so_far with \u001b[2m \u001b[0m\n",
  778. "\u001b[2;36m \u001b[0m acc#accuracy: \u001b[1;36m0.941667\u001b[0m\u001b[33m...\u001b[0m \u001b[2m \u001b[0m\n"
  779. ]
  780. },
  781. "metadata": {},
  782. "output_type": "display_data"
  783. },
  784. {
  785. "data": {
  786. "text/html": [
  787. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">[21:34:34] </span><span style=\"color: #000080; text-decoration-color: #000080\">INFO </span> Deleting fnlp-ernie/<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2022</span>-<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">06</span>-<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>-21_29_12_8 <a href=\"file://../fastNLP/core/callbacks/load_best_model_callback.py\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">load_best_model_callback.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file://../fastNLP/core/callbacks/load_best_model_callback.py#131\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">131</span></a>\n",
  788. "<span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\"> </span> 98095/best_so_far<span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>\n",
  789. "</pre>\n"
  790. ],
  791. "text/plain": [
  792. "\u001b[2;36m[21:34:34]\u001b[0m\u001b[2;36m \u001b[0m\u001b[34mINFO \u001b[0m Deleting fnlp-ernie/\u001b[1;36m2022\u001b[0m-\u001b[1;36m06\u001b[0m-\u001b[1;36m22\u001b[0m-21_29_12_8 \u001b]8;id=430330;file://../fastNLP/core/callbacks/load_best_model_callback.py\u001b\\\u001b[2mload_best_model_callback.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=508566;file://../fastNLP/core/callbacks/load_best_model_callback.py#131\u001b\\\u001b[2m131\u001b[0m\u001b]8;;\u001b\\\n",
  793. "\u001b[2;36m \u001b[0m 98095/best_so_far\u001b[33m...\u001b[0m \u001b[2m \u001b[0m\n"
  794. ]
  795. },
  796. "metadata": {},
  797. "output_type": "display_data"
  798. },
  799. {
  800. "data": {
  801. "text/html": [
  802. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
  803. ],
  804. "text/plain": []
  805. },
  806. "metadata": {},
  807. "output_type": "display_data"
  808. },
  809. {
  810. "data": {
  811. "text/html": [
  812. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
  813. "</pre>\n"
  814. ],
  815. "text/plain": [
  816. "\n"
  817. ]
  818. },
  819. "metadata": {},
  820. "output_type": "display_data"
  821. }
  822. ],
  823. "source": [
  824. "from fastNLP import LRSchedCallback, LoadBestModelCallback\n",
  825. "from fastNLP import Trainer, Accuracy\n",
  826. "from paddlenlp.transformers import LinearDecayWithWarmup\n",
  827. "\n",
  828. "n_epochs = 2\n",
  829. "num_training_steps = len(train_dataloader) * n_epochs\n",
  830. "lr_scheduler = LinearDecayWithWarmup(5e-5, num_training_steps, 0.1)\n",
  831. "optimizer = paddle.optimizer.AdamW(\n",
  832. " learning_rate=lr_scheduler,\n",
  833. " parameters=model.parameters(),\n",
  834. ")\n",
  835. "callbacks = [\n",
  836. " LRSchedCallback(lr_scheduler, step_on=\"batch\"),\n",
  837. " LoadBestModelCallback(\"acc#accuracy\", larger_better=True, save_folder=\"fnlp-ernie\"),\n",
  838. "]\n",
  839. "trainer = Trainer(\n",
  840. " model=model,\n",
  841. " driver=\"paddle\",\n",
  842. " optimizers=optimizer,\n",
  843. " device=0,\n",
  844. " n_epochs=n_epochs,\n",
  845. " train_dataloader=train_dataloader,\n",
  846. " evaluate_dataloaders=val_dataloader,\n",
  847. " evaluate_every=60,\n",
  848. " metrics={\"accuracy\": Accuracy()},\n",
  849. " callbacks=callbacks,\n",
  850. ")\n",
  851. "trainer.run()"
  852. ]
  853. },
  854. {
  855. "cell_type": "markdown",
  856. "metadata": {},
  857. "source": [
  858. "#### 3.3 测试和评估\n",
  859. "\n",
  860. "现在我们已经得到了一个表现良好的 ``ERNIE`` 模型,接下来可以在测试集上测试模型的效果了。``FastNLP.Evaluator`` 提供了定制函数的功能。我们以 ``test_dataloader`` 初始化一个 ``Evaluator``,然后将写好的测试函数 ``test_batch_step_fn`` 传给参数 ``evaluate_batch_step_fn``,``Evaluate`` 在对每个 batch 进行评估时就会调用我们自定义的 ``test_batch_step_fn`` 函数而不是 ``evaluate_step`` 函数。在这里,我们仅测试 5 条数据并输出文本和对应的标签。"
  861. ]
  862. },
  863. {
  864. "cell_type": "code",
  865. "execution_count": 14,
  866. "metadata": {},
  867. "outputs": [
  868. {
  869. "data": {
  870. "text/html": [
  871. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">text: ['这个宾馆比较陈旧了,特价的房间也很一般。总体来说一般']\n",
  872. "</pre>\n"
  873. ],
  874. "text/plain": [
  875. "text: ['这个宾馆比较陈旧了,特价的房间也很一般。总体来说一般']\n"
  876. ]
  877. },
  878. "metadata": {},
  879. "output_type": "display_data"
  880. },
  881. {
  882. "data": {
  883. "text/html": [
  884. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">labels: 0\n",
  885. "</pre>\n"
  886. ],
  887. "text/plain": [
  888. "labels: 0\n"
  889. ]
  890. },
  891. "metadata": {},
  892. "output_type": "display_data"
  893. },
  894. {
  895. "data": {
  896. "text/html": [
  897. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">text: ['怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片!开始\n",
  898. "还怀疑是不是赠送的个别现象,可是后来发现每张DVD后面都有!真不知道生产商怎么想的,我想看的是猫\n",
  899. "和老鼠,不是米老鼠!如果厂家是想赠送的话,那就全套米老鼠和唐老鸭都赠送,只在每张DVD后面添加一\n",
  900. "集算什么??简直是画蛇添足!!']\n",
  901. "</pre>\n"
  902. ],
  903. "text/plain": [
  904. "text: ['怀着十分激动的心情放映,可是看着看着发现,在放映完毕后,出现一集米老鼠的动画片!开始\n",
  905. "还怀疑是不是赠送的个别现象,可是后来发现每张DVD后面都有!真不知道生产商怎么想的,我想看的是猫\n",
  906. "和老鼠,不是米老鼠!如果厂家是想赠送的话,那就全套米老鼠和唐老鸭都赠送,只在每张DVD后面添加一\n",
  907. "集算什么??简直是画蛇添足!!']\n"
  908. ]
  909. },
  910. "metadata": {},
  911. "output_type": "display_data"
  912. },
  913. {
  914. "data": {
  915. "text/html": [
  916. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">labels: 0\n",
  917. "</pre>\n"
  918. ],
  919. "text/plain": [
  920. "labels: 0\n"
  921. ]
  922. },
  923. "metadata": {},
  924. "output_type": "display_data"
  925. },
  926. {
  927. "data": {
  928. "text/html": [
  929. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">text: ['还稍微重了点,可能是硬盘大的原故,还要再轻半斤就好了。其他要进一步验证。贴的几种膜气\n",
  930. "泡较多,用不了多久就要更换了,屏幕膜稍好点,但比没有要强多了。建议配赠几张膜让用用户自己贴。'\n",
  931. "]\n",
  932. "</pre>\n"
  933. ],
  934. "text/plain": [
  935. "text: ['还稍微重了点,可能是硬盘大的原故,还要再轻半斤就好了。其他要进一步验证。贴的几种膜气\n",
  936. "泡较多,用不了多久就要更换了,屏幕膜稍好点,但比没有要强多了。建议配赠几张膜让用用户自己贴。'\n",
  937. "]\n"
  938. ]
  939. },
  940. "metadata": {},
  941. "output_type": "display_data"
  942. },
  943. {
  944. "data": {
  945. "text/html": [
  946. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">labels: 0\n",
  947. "</pre>\n"
  948. ],
  949. "text/plain": [
  950. "labels: 0\n"
  951. ]
  952. },
  953. "metadata": {},
  954. "output_type": "display_data"
  955. },
  956. {
  957. "data": {
  958. "text/html": [
  959. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">text: ['交通方便;环境很好;服务态度很好 房间较小']\n",
  960. "</pre>\n"
  961. ],
  962. "text/plain": [
  963. "text: ['交通方便;环境很好;服务态度很好 房间较小']\n"
  964. ]
  965. },
  966. "metadata": {},
  967. "output_type": "display_data"
  968. },
  969. {
  970. "data": {
  971. "text/html": [
  972. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">labels: 1\n",
  973. "</pre>\n"
  974. ],
  975. "text/plain": [
  976. "labels: 1\n"
  977. ]
  978. },
  979. "metadata": {},
  980. "output_type": "display_data"
  981. },
  982. {
  983. "data": {
  984. "text/html": [
  985. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">text: ['不错,作者的观点很颠覆目前中国父母的教育方式,其实古人们对于教育已经有了很系统的体系\n",
  986. "了,可是现在的父母以及祖父母们更多的娇惯纵容孩子,放眼看去自私的孩子是大多数,父母觉得自己的\n",
  987. "孩子在外面只要不吃亏就是好事,完全把古人几千年总结的教育古训抛在的九霄云外。所以推荐准妈妈们\n",
  988. "可以在等待宝宝降临的时候,好好学习一下,怎么把孩子教育成一个有爱心、有责任心、宽容、大度的人\n",
  989. "。']\n",
  990. "</pre>\n"
  991. ],
  992. "text/plain": [
  993. "text: ['不错,作者的观点很颠覆目前中国父母的教育方式,其实古人们对于教育已经有了很系统的体系\n",
  994. "了,可是现在的父母以及祖父母们更多的娇惯纵容孩子,放眼看去自私的孩子是大多数,父母觉得自己的\n",
  995. "孩子在外面只要不吃亏就是好事,完全把古人几千年总结的教育古训抛在的九霄云外。所以推荐准妈妈们\n",
  996. "可以在等待宝宝降临的时候,好好学习一下,怎么把孩子教育成一个有爱心、有责任心、宽容、大度的人\n",
  997. "。']\n"
  998. ]
  999. },
  1000. "metadata": {},
  1001. "output_type": "display_data"
  1002. },
  1003. {
  1004. "data": {
  1005. "text/html": [
  1006. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">labels: 1\n",
  1007. "</pre>\n"
  1008. ],
  1009. "text/plain": [
  1010. "labels: 1\n"
  1011. ]
  1012. },
  1013. "metadata": {},
  1014. "output_type": "display_data"
  1015. },
  1016. {
  1017. "data": {
  1018. "text/html": [
  1019. "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
  1020. ],
  1021. "text/plain": []
  1022. },
  1023. "metadata": {},
  1024. "output_type": "display_data"
  1025. },
  1026. {
  1027. "data": {
  1028. "text/plain": [
  1029. "{}"
  1030. ]
  1031. },
  1032. "execution_count": 14,
  1033. "metadata": {},
  1034. "output_type": "execute_result"
  1035. }
  1036. ],
  1037. "source": [
  1038. "from fastNLP import Evaluator\n",
  1039. "def test_batch_step_fn(evaluator, batch):\n",
  1040. " input_ids = batch[\"input_ids\"]\n",
  1041. " attention_mask = batch[\"attention_mask\"]\n",
  1042. " token_type_ids = batch[\"token_type_ids\"]\n",
  1043. " logits = model(input_ids, attention_mask, token_type_ids)\n",
  1044. " predict = logits.argmax().item()\n",
  1045. " print(\"text:\", batch['text'])\n",
  1046. " print(\"labels:\", predict)\n",
  1047. "\n",
  1048. "evaluator = Evaluator(\n",
  1049. " model=model,\n",
  1050. " dataloaders=test_dataloader,\n",
  1051. " driver=\"paddle\",\n",
  1052. " device=0,\n",
  1053. " evaluate_batch_step_fn=test_batch_step_fn,\n",
  1054. ")\n",
  1055. "evaluator.run(5) "
  1056. ]
  1057. }
  1058. ],
  1059. "metadata": {
  1060. "kernelspec": {
  1061. "display_name": "Python 3.7.13 ('fnlp-paddle')",
  1062. "language": "python",
  1063. "name": "python3"
  1064. },
  1065. "language_info": {
  1066. "codemirror_mode": {
  1067. "name": "ipython",
  1068. "version": 3
  1069. },
  1070. "file_extension": ".py",
  1071. "mimetype": "text/x-python",
  1072. "name": "python",
  1073. "nbconvert_exporter": "python",
  1074. "pygments_lexer": "ipython3",
  1075. "version": "3.7.13"
  1076. },
  1077. "orig_nbformat": 4,
  1078. "vscode": {
  1079. "interpreter": {
  1080. "hash": "31f2d9d3efc23c441973d7c4273acfea8b132b6a578f002629b6b44b8f65e720"
  1081. }
  1082. }
  1083. },
  1084. "nbformat": 4,
  1085. "nbformat_minor": 2
  1086. }