subtitles/en/69_what-to-do-when-you-get-an-error.srt (208 lines of code) (raw):
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
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
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
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 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
while trying to execute
the function "check_tasks,"
25
00:01:02,520 --> 00:01:05,103
which then raised the
KeyError we see displayed.
26
00:01:06,630 --> 00:01:08,580
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
If you're running your code on Colab
32
00:01:21,870 --> 00:01:23,820
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
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
The difference is that
it's spelled "distilbert"
58
00:02:21,720 --> 00:02:24,240
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
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.