1
00:00:00,380 --> 00:00:02,463
（呼呼）
(whoosh)

2
00:00:05,550 --> 00:00:07,590
- 在本视频中，我们将学习第一件事
- In this video we'll learn the first things to

3
00:00:07,590 --> 00:00:09,330
当你得到一个错误时做。
do when you get an error.

4
00:00:09,330 --> 00:00:11,930
这不是将笔记本电脑扔出窗外。
This is not throwing your laptop through the window.

5
00:00:13,320 --> 00:00:15,450
假设我们要使用问答管道
Let's say we want to use the question answering pipeline

6
00:00:15,450 --> 00:00:19,470
在特定型号上，我们收到以下错误。
on a particular model and we get the following error.

7
00:00:19,470 --> 00:00:21,750
Python 中的错误可能看起来势不可挡
Errors in Python can appear overwhelming

8
00:00:21,750 --> 00:00:24,390
因为你得到了很多信息打印出来
because you get so much information printed out

9
00:00:24,390 --> 00:00:26,610
但那是因为 Python 试图帮助你
but that's because Python is trying to help you

10
00:00:26,610 --> 00:00:29,070
尽其所能解决你的问题。
the best it can to solve your problem.

11
00:00:29,070 --> 00:00:31,260
在本视频中，我们将了解如何解读
In this video, we'll see how to interpret

12
00:00:31,260 --> 00:00:32,460
我们得到的错误报告。
the error report we get.

13
00:00:33,510 --> 00:00:35,700
首先要注意的是顶部
The first thing to notice at the very top

14
00:00:35,700 --> 00:00:38,070
是 Python 给你显示了一个清晰的箭头
is that Python shows you with a clear arrow

15
00:00:38,070 --> 00:00:40,320
触发错误的代码行
the line of code that triggers the error

16
00:00:40,320 --> 00:00:42,210
所以你不必摆弄你的代码
so you don't have to fiddle with your code

17
00:00:42,210 --> 00:00:43,800
并删除随机线以找出
and remove random lines to figure out

18
00:00:43,800 --> 00:00:45,540
错误来自哪里。
where the error comes from.

19
00:00:45,540 --> 00:00:47,890
答案就在你面前。
You have the answer in front of you right here.

20
00:00:49,140 --> 00:00:51,360
你在下面看到的错误是代码的一部分
The errors you see below are a part of the code

21
00:00:51,360 --> 00:00:54,930
Python 试图在运行指令时执行。
Python tried to execute while running the instruction.

22
00:00:54,930 --> 00:00:57,750
我们在管道函数中
Here we are inside the pipeline function

23
00:00:57,750 --> 00:00:59,490
零出现在这条线上
and zero came on this line

24
00:00:59,490 --> 00:01:02,520
在尝试执行函数 “check_tasks” 时，
while trying to execute the function "check_tasks,"

25
00:01:02,520 --> 00:01:05,103
然后引发了我们看到的 KeyError 显示。
which then raised the KeyError we see displayed.

26
00:01:06,630 --> 00:01:08,580
请注意，Python 会准确地告诉你
Note that Python tells you exactly

27
00:01:08,580 --> 00:01:11,190
它正在执行的功能所在的位置，
where the function it's executing lives,

28
00:01:11,190 --> 00:01:12,810
所以如果你喜欢冒险
so if you feel adventurous

29
00:01:12,810 --> 00:01:14,810
你甚至可以去检查源代码。
you can even go inspect the source code.

30
00:01:15,900 --> 00:01:18,447
这整件事被称为 “追溯”。
This whole thing is called the "Traceback."

31
00:01:20,010 --> 00:01:21,870
如果你在 Colab 上运行代码
If you're running your code on Colab

32
00:01:21,870 --> 00:01:23,820
Traceback 自动最小化，
the Traceback is automatically minimized,

33
00:01:23,820 --> 00:01:25,833
所以你必须点击展开它。
so you have to click to expand it.

34
00:01:26,820 --> 00:01:28,530
在回溯的最后
At the very end of the Traceback

35
00:01:28,530 --> 00:01:31,890
你终于得到了实际的错误信息。
you finally get the actual error message.

36
00:01:31,890 --> 00:01:33,660
遇到你应该做的第一件事
The first thing you should do when encountering

37
00:01:33,660 --> 00:01:36,480
错误是阅读该错误消息。
an error is to read that error message.

38
00:01:36,480 --> 00:01:38,640
它告诉我们它不知道
Here it's telling us it doesn't know

39
00:01:38,640 --> 00:01:40,230
问答任务
the question answering task

40
00:01:40,230 --> 00:01:41,760
并帮助我们列出了清单
and helpfully gives us the list

41
00:01:41,760 --> 00:01:44,850
我们可以看到支持的任务
of supported tasks in which we can see

42
00:01:44,850 --> 00:01:47,520
那个 “问答” 实际上是。
that "question-answering" actually is.

43
00:01:47,520 --> 00:01:49,200
仔细一看，
Looking more closely though,

44
00:01:49,200 --> 00:01:52,020
我们用下划线来惊奇这两个词
we used an underscore to surprise the two words

45
00:01:52,020 --> 00:01:54,300
当任务写有减号时，
when the task is written with a minus,

46
00:01:54,300 --> 00:01:55,413
所以我们应该解决这个问题。
so we should fix that.

47
00:01:57,510 --> 00:02:00,360
现在让我们用正确编写的标签重试我们的代码
Now let's retry our code with the tags properly written

48
00:02:00,360 --> 00:02:01,920
今天发生了什么？
and what is happening today?

49
00:02:01,920 --> 00:02:03,210
另一个错误。
Another error.

50
00:02:03,210 --> 00:02:05,670
正如我们之前所说，我们去看看底部
As we said before, we go look at the bottom

51
00:02:05,670 --> 00:02:07,560
阅读实际的错误信息。
to read the actual error message.

52
00:02:07,560 --> 00:02:09,000
它告诉我们应该检查
It's telling us that we should check

53
00:02:09,000 --> 00:02:11,340
我们的模型是正确的模型标识符，
our model is a correct model identifier,

54
00:02:11,340 --> 00:02:14,760
所以让我们跳到 hf.co/models。
so let's hop onto hf.co/models.

55
00:02:14,760 --> 00:02:16,440
我们可以看到我们的模型列在那里
We can see our model listed there

56
00:02:16,440 --> 00:02:19,440
在可用于问答的那些。
in the ones available for question answering.

57
00:02:19,440 --> 00:02:21,720
不同之处在于它拼写为 “distilbert”
The difference is that it's spelled "distilbert"

58
00:02:21,720 --> 00:02:24,240
用一个 L，我们用两个，
with one L, and we use two,

59
00:02:24,240 --> 00:02:25,650
所以让我们解决这个问题。
so let's fix that.

60
00:02:25,650 --> 00:02:27,570
我们终于得到了结果。
We finally get our results.

61
00:02:27,570 --> 00:02:29,160
如果我们的错误更复杂，
If our error is more complex,

62
00:02:29,160 --> 00:02:31,290
你可能需要使用 Python 调试器。
you might need to use the Python debugger.

63
00:02:31,290 --> 00:02:33,483
查看下面的视频以了解操作方法。
Check out the videos below to learn how.

