-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompt_eng_07_expanding_v3.srt
537 lines (425 loc) · 10.2 KB
/
prompt_eng_07_expanding_v3.srt
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
1
00:00:05,033 --> 00:00:07,966
Expanding as a torso, taking a shorter
piece of text
2
00:00:08,266 --> 00:00:10,933
such as a set of instructions
or a list of topics,
3
00:00:11,166 --> 00:00:14,200
and having the large language model
generate a longer
4
00:00:14,200 --> 00:00:17,966
piece of text such as an email
or an essay about some topic.
5
00:00:18,433 --> 00:00:21,900
There are some great uses of this, such
as if you use the large language model
6
00:00:22,100 --> 00:00:24,066
as a brainstorming partner.
7
00:00:24,066 --> 00:00:27,933
But I just also want acknowledge
that there's some problematic use cases
8
00:00:27,933 --> 00:00:32,200
of this, such as if someone with a user
to generate a large amount of spam.
9
00:00:32,666 --> 00:00:35,900
So when you use these capabilities
of a large language model,
10
00:00:36,100 --> 00:00:40,866
please use it only in a responsible way
and in a way that helps people.
11
00:00:41,633 --> 00:00:45,933
In this video, we'll go through an example
of how you can use a language model
12
00:00:45,933 --> 00:00:50,100
to generate a personalized email
based on some information.
13
00:00:50,100 --> 00:00:53,166
The email is kind of self
proclaimed to be from an AI bot,
14
00:00:53,166 --> 00:00:55,800
which as I mentioned, is very important.
15
00:00:56,266 --> 00:00:57,800
What else are you going to use?
16
00:00:57,800 --> 00:01:01,066
Another one of the models
input parameters called temperature,
17
00:01:01,200 --> 00:01:05,666
and this kind of allows you to vary
the kind of degree of exploration
18
00:01:05,666 --> 00:01:08,533
and variety
in the kind of models responses.
19
00:01:08,800 --> 00:01:11,333
So let's get into it.
20
00:01:11,333 --> 00:01:15,166
So before we get started,
we're going to kind of do the usual setup.
21
00:01:15,166 --> 00:01:19,166
So set up the open Python package
and then also define our helper
22
00:01:19,166 --> 00:01:20,433
function, get completion.
23
00:01:22,266 --> 00:01:22,733
And now we're
24
00:01:22,733 --> 00:01:25,500
going to write a custom
email response to a customer review.
25
00:01:25,900 --> 00:01:29,366
And so given a customer view
and the sentiment,
26
00:01:29,366 --> 00:01:31,633
we're going to generate a custom response.
27
00:01:32,366 --> 00:01:35,100
Now we're going to use the language model
28
00:01:35,100 --> 00:01:38,633
to generate a custom email to a customer
29
00:01:39,066 --> 00:01:42,633
based on a customer review
and the sentiment of the review.
30
00:01:43,033 --> 00:01:46,233
So we've already extracted the sentiment
using
31
00:01:46,666 --> 00:01:50,066
the kind of prompts that we saw
in the empowering video.
32
00:01:51,066 --> 00:01:55,900
And then this is the customer
review for a blunder.
33
00:01:55,900 --> 00:01:59,733
And now we're going to customize
the reply based on the sentiment.
34
00:02:01,266 --> 00:02:03,166
And so here the instruction is
35
00:02:03,166 --> 00:02:06,066
your you are our customer
service assistant.
36
00:02:06,266 --> 00:02:08,966
Your task is to send an email reply
to a valued customer.
37
00:02:09,266 --> 00:02:12,900
Given the customer
email is limited by three back to generate
38
00:02:12,900 --> 00:02:14,900
a reply
to thank the customer for that review.
39
00:02:14,900 --> 00:02:18,133
If the sentiment is positive or neutral,
thank them for that review.
40
00:02:18,466 --> 00:02:21,800
If the sentiment is negative, apologize
and suggest that they can reach out
41
00:02:21,800 --> 00:02:23,333
to customer service.
42
00:02:23,333 --> 00:02:25,500
Make sure to use specific details
from the review.
43
00:02:25,800 --> 00:02:30,000
Write in a concise and professional tone
and sign the email as a customer agent.
44
00:02:30,300 --> 00:02:34,500
And when you're using a language model
to generate text that you're going to show
45
00:02:34,500 --> 00:02:38,666
to a user, it's very important
to have this kind of transparency
46
00:02:38,733 --> 00:02:44,033
and let the user know that
the text they're seeing was generated by,
47
00:02:44,033 --> 00:02:47,166
and then we'll just input the customer
review and the review sentiment.
48
00:02:47,366 --> 00:02:50,766
And also note
that this isn't necessarily important
49
00:02:50,766 --> 00:02:54,700
because we could actually use this prompt
to also extract the review sentiment.
50
00:02:54,700 --> 00:02:57,033
And then in a follow up
step, write the email.
51
00:02:57,033 --> 00:02:59,000
But just for the sake of the example,
well,
52
00:02:59,000 --> 00:03:01,166
we've already extracted the
sentiment from the review.
53
00:03:02,366 --> 00:03:03,333
And so
54
00:03:03,333 --> 00:03:07,200
here we have a response
to the customer addresses,
55
00:03:07,200 --> 00:03:10,233
details that the customer mentioned
in their review
56
00:03:10,966 --> 00:03:15,233
and kind of, as we instructed suggest
that they reach out to customer service
57
00:03:15,233 --> 00:03:20,866
because this is just an air customer
service agent.
58
00:03:20,866 --> 00:03:25,233
Next, we're going to use a parameter
of the language
59
00:03:25,233 --> 00:03:28,300
model called temperature
that will allow us to
60
00:03:29,566 --> 00:03:32,433
change the kind of variety
of the model's responses
61
00:03:32,700 --> 00:03:34,466
so you can kind of think of temperature
62
00:03:34,466 --> 00:03:39,600
as the degree of expiration
or kind of randomness of the model.
63
00:03:39,600 --> 00:03:43,400
And so for this particular phrase,
my favorite food is
64
00:03:43,800 --> 00:03:47,833
the kind of most likely next word
that the model predicts is pizza
65
00:03:48,000 --> 00:03:51,800
and the kind of next to most likely
suggests are sushi and tacos.
66
00:03:51,966 --> 00:03:55,033
And so at a temperature of zero,
the model will always choose
67
00:03:55,033 --> 00:03:57,466
the most likely next word,
which in this case is pizza.
68
00:03:57,633 --> 00:04:01,800
And at a higher temperature, it will also
choose one of the less likely words
69
00:04:01,800 --> 00:04:05,400
and even at an even higher temperature,
it might even choose tacos,
70
00:04:05,400 --> 00:04:09,400
which only kind of has
a 5% chance of being chosen.
71
00:04:10,533 --> 00:04:11,700
And you can imagine that kind
72
00:04:11,700 --> 00:04:15,600
of as the model continues,
this final response.
73
00:04:15,600 --> 00:04:19,233
So my favorite food is pizza, and it kind
of continues to generate more words.
74
00:04:19,466 --> 00:04:22,433
This response will kind of diverge
from the response.
75
00:04:22,800 --> 00:04:25,166
The first response,
which is my favorite food, is tacos.
76
00:04:25,300 --> 00:04:27,166
And so as a kind of model continues,
77
00:04:27,166 --> 00:04:29,466
these two responses will become more
and more different.
78
00:04:30,566 --> 00:04:33,500
In general, when building applications
where you want
79
00:04:33,500 --> 00:04:38,000
a predictable response,
I would recommend using temperature zero.
80
00:04:38,000 --> 00:04:41,433
Throughout all of these videos,
we've been using temperature zero.
81
00:04:41,466 --> 00:04:43,733
And I think that if you're trying
to build a system
82
00:04:43,733 --> 00:04:47,033
that is reliable and predictable,
you should go with this.
83
00:04:47,333 --> 00:04:50,600
If you're trying to use the model
in a more creative way
84
00:04:50,600 --> 00:04:54,166
where you might want a kind of wider
variety of different outputs,
85
00:04:54,366 --> 00:04:56,466
you might want to use
a higher temperature.
86
00:04:57,366 --> 00:05:01,433
So now let's take this same prompt
that we just used
87
00:05:01,866 --> 00:05:05,933
and let's try generating an email,
but let's use a higher temperature.
88
00:05:06,433 --> 00:05:09,000
So in our get completion function
89
00:05:09,500 --> 00:05:11,933
that we've been using
throughout the videos,
90
00:05:11,933 --> 00:05:15,166
we have kind of specified a model
and then also a temperature,
91
00:05:15,166 --> 00:05:16,566
but we've kind of set them to default.
92
00:05:16,566 --> 00:05:21,233
So now let's try burying the temperature.
93
00:05:21,233 --> 00:05:23,600
So we use the prompt and then
94
00:05:27,533 --> 00:05:27,966
let's try a
95
00:05:27,966 --> 00:05:33,666
temperature 0.7.
96
00:05:33,666 --> 00:05:37,333
And so with temperature zero,
every time you execute the same prompt,
97
00:05:37,333 --> 00:05:40,400
you should expect the same completion.
98
00:05:40,633 --> 00:05:44,633
Whereas with the temperature 0.7, you will
get a different output every time.
99
00:05:45,133 --> 00:05:47,766
So here we have
100
00:05:47,766 --> 00:05:49,900
email and as you can see, it's different
101
00:05:49,900 --> 00:05:54,600
to the email that we kind of received
previously and let's just execute it again
102
00:05:54,966 --> 00:05:57,533
to show
that we'll get a different email again.
103
00:05:59,066 --> 00:06:01,200
And here we have another different email.
104
00:06:01,700 --> 00:06:06,300
So I recommend that you kind of play
around with temperature yourself.
105
00:06:06,666 --> 00:06:10,566
Maybe you could pause the video now
and try this prompt
106
00:06:10,566 --> 00:06:14,066
with a variety of different temperatures
just to see how the outputs vary.
107
00:06:15,566 --> 00:06:17,200
So to summarize
108
00:06:17,200 --> 00:06:21,300
at higher temperatures, the outputs from
the model are kind of more random.
109
00:06:21,466 --> 00:06:24,233
You can almost think of it
as at higher temperatures.
110
00:06:24,233 --> 00:06:27,833
The assistant is more distractible
but maybe more creative.
111
00:06:29,433 --> 00:06:29,933
In the next
112
00:06:29,933 --> 00:06:34,200
video, we're going to talk more
about the chart completions and format
113
00:06:34,300 --> 00:06:37,466
and how you can create a custom
chat bot using this format.