Few-Shot Prompting Explained

Elvis Saravia
26 Jun 202410:43

Summary

TLDRفي هذا الفيديو، نستعرض مفهوم الـ 'Few-shot prompting' وكيف يمكن استخدامه لتحسين أداء وجودة المخرجات من النماذج اللغوية الكبيرة. تم تغطية مفهوم 'zero-shot prompting' سابقًا، والذي يعتمد على إعطاء النموذج تعليمات بدون أمثلة. ومع ذلك، يتيح 'few-shot prompting' تقديم أمثلة للنموذج لتوضيح المهمة المطلوبة، مما يزيد من دقة وموثوقية النتائج. يُظهر الفيديو كيفية استخدام هذه التقنية لتحسين النماذج، مع تقديم أمثلة توضيحية من ورقة بحثية سابقة. في النهاية، يتم التطرق لإمكانية استخدام هذه الطريقة في تطبيقات مختلفة.

Takeaways

  • 🤖 مفهوم 'few-shot prompting' يشير إلى تحسين أداء النماذج اللغوية الكبيرة عن طريق إعطائها أمثلة على كيفية تنفيذ المهام.
  • 📜 تم التطرق إلى 'zero-shot prompting' حيث يتم إعطاء النموذج تعليمات مباشرة دون أمثلة مسبقة.
  • 📝 عند استخدام 'zero-shot prompting' يمكن للنموذج تصنيف النصوص بناءً على تعليمات بسيطة مثل تصنيف النصوص إلى إيجابية أو سلبية.
  • ⚙️ 'few-shot prompting' يكون مفيداً عند مواجهة مهام معقدة أو غير مألوفة للنموذج، حيث يمكن للأمثلة أن تساعد النموذج على فهم المهمة بشكل أفضل.
  • 🎓 يتم استخدام أمثلة توضيحية في 'few-shot prompting' لتحديد المدخلات والمخرجات المتوقعة من النموذج.
  • 🧠 يتم استخدام أمثلة من ورقة بحثية لتوضيح فعالية 'few-shot prompting' في تحسين دقة النموذج.
  • 💡 'few-shot prompting' يمكن أن يكون مفيدًا في ضبط نغمة رسائل البريد الإلكتروني أو توليد عناوين لمقالات معينة.
  • ⚠️ يتم التأكيد على أهمية تصميم التعليمات بعناية واختيار الأمثلة المناسبة لتحقيق أفضل نتائج من النماذج اللغوية.
  • 🔄 يمكن تعديل هيكل التعليمات والأمثلة لتناسب المهمة المحددة وتوجيه النموذج بشكل أكثر دقة.
  • 📚 سيتم تناول تقنية 'Chain of Thought prompting' في الفيديو التالي كمثال آخر على تحسين استجابة النماذج اللغوية.

Q & A

  • ما هو مفهوم 'F Shot Prompting' الذي يتم التحدث عنه في الفيديو؟

    -مفهوم 'F Shot Prompting' يشير إلى استخدام أمثلة أو تقديم نماذج للمهام التي تريد من النموذج اللغوي تنفيذها، مما يساعد النموذج على فهم المهمة بشكل أفضل وتقديم إجابات أكثر دقة وجودة.

  • ما الفرق بين 'Zero Shot Prompting' و'F Shot Prompting'؟

    -'Zero Shot Prompting' يعني إعطاء النموذج تعليمات دون تقديم أي أمثلة، بينما في 'F Shot Prompting' يتم تزويد النموذج بأمثلة توضيحية للمهمة مما يساعده على تحسين الأداء وفهم المهمة بشكل أعمق.

  • لماذا يمكن أن يكون 'F Shot Prompting' مفيدًا في بعض الحالات؟

    -'F Shot Prompting' يكون مفيدًا في الحالات التي لا يمتلك فيها النموذج بيانات كافية أو فهمًا كافيًا للمهمة المعقدة، حيث تساعد الأمثلة المقدمة النموذج على تحسين دقة الإجابات.

  • كيف يساعد تقديم الأمثلة في 'F Shot Prompting' النموذج اللغوي؟

    -تقديم الأمثلة في 'F Shot Prompting' يساعد النموذج على فهم التوقعات المطلوبة من المهمة وتحديد السياق المناسب للإجابة بشكل صحيح، مما يؤدي إلى تحسين جودة المخرجات.

  • ما هي خطوات إعداد نموذج لغوي باستخدام 'F Shot Prompting'؟

    -الخطوات تشمل تقديم رسالة نظام توضح المهمة، متبوعة بتقديم أمثلة تحتوي على المدخلات والمخرجات المتوقعة، ثم يتم تشغيل النموذج لتقديم الإجابات بناءً على الأمثلة المقدمة.

  • هل يجب دائمًا تقديم أمثلة المدخلات والمخرجات في 'F Shot Prompting'؟

    -ليس دائمًا، بعض المهام يمكن أن تكتفي بتقديم المخرجات فقط دون الحاجة إلى تقديم المدخلات، حسب طبيعة المهمة والهدف المطلوب.

  • ما هو التحدي المحتمل عند استخدام 'F Shot Prompting' مع النماذج اللغوية؟

    -أحد التحديات هو أن النموذج قد يكون له انحياز نحو نوع معين من المخرجات (مثل تفضيل الإجابات الإيجابية) إذا لم يتم تزويده بأمثلة كافية ومتوازنة.

  • كيف يمكن تحسين نموذج لغوي إذا لم يقدم أداءً جيدًا في 'F Shot Prompting'؟

    -يمكن تحسين أداء النموذج بتزويده بمزيد من الأمثلة المناسبة التي تغطي الحالات التي يواجه فيها صعوبة، مما يساعده على التعلم وتقديم إجابات أكثر دقة.

  • ما هي الفائدة من استخدام نموذج لغوي لتوليد كلمات جديدة وتكوين جمل باستخدام هذه الكلمات؟

    -الفائدة تكمن في قدرة النموذج على توليد جمل منطقية باستخدام كلمات لم تكن موجودة مسبقًا، مما يظهر مرونته وفهمه للسياق اللغوي بطريقة مبتكرة.

  • ما هو الفيديو القادم الذي سيتم تقديمه بعد هذا الفيديو وفقًا للمحتوى؟

    -الفيديو القادم سيغطي موضوع 'Chain of Thought Prompting'، وهو طريقة قوية أخرى لتحفيز النماذج اللغوية.

Outlines

00:00

🤖 Introduction to Few-Shot Prompting in LLMs

This paragraph introduces the concept of Few-Shot Prompting, a technique used to improve the performance and reliability of large language models (LLMs). The speaker compares it to Zero-Shot Prompting, where the model is asked to perform a task with just an instruction. However, Zero-Shot Prompting may not always yield accurate results, especially for complex tasks or tasks the model isn't familiar with. Few-Shot Prompting addresses this by providing examples or demonstrations, enabling the model to better understand the task and deliver higher quality and more reliable outputs.

05:01

📝 Example of Few-Shot Prompting with OpenAI Models

This paragraph explains a practical example of Few-Shot Prompting using OpenAI's GPT-3.5 model. The speaker demonstrates how to structure prompts in the OpenAI Playground, including providing a system message and user input. The example given involves making up a word and asking the model to use it in a sentence, which showcases the model's ability to generalize and generate appropriate responses without requiring fine-tuning. The speaker emphasizes that Few-Shot Prompting can be customized depending on the task, such as setting expectations for the model's output in terms of tone, style, or specific content.

10:01

🔍 Detailed Demonstration and Structuring of Prompts

In this paragraph, the speaker continues the demonstration of Few-Shot Prompting by structuring a sentiment classification task. The task involves classifying text as either negative or positive, and the speaker discusses different ways to format and input examples for the model. They highlight that while input-output examples are often used, in some cases, providing just the output might be sufficient. The speaker also points out the importance of giving models the right examples, especially when the model may favor certain outputs based on its training data. The paragraph concludes with a discussion on the flexibility of Few-Shot Prompting and how it can be adapted for various tasks.

📚 Conclusion and Upcoming Topics

The final paragraph wraps up the video, summarizing the key points about Few-Shot Prompting. The speaker encourages viewers to further explore the topic by reading additional materials and understanding the limitations of this prompting method. The paragraph ends with a teaser for the next video, which will cover Chain of Thought Prompting, another powerful technique for improving the performance of large language models.

Mindmap

Keywords

💡التلقين الصفري

التلقين الصفري هو طريقة للتفاعل مع النماذج اللغوية الكبيرة حيث يتم تقديم مهمة أو تعليمات للنموذج دون إعطائه أمثلة محددة. في الفيديو، يتم شرح كيف يمكن للنموذج تصنيف النص دون إعطائه أمثلة مسبقة، مما يظهر قدرته على فهم المهام بناءً على المعرفة الضمنية.

💡التلقين الشفهي

التلقين الشفهي يشير إلى تزويد النموذج اللغوي بأمثلة أو تعليمات مفصلة لتوضيح كيفية أداء مهمة معينة. الفيديو يشرح كيف يمكن تحسين دقة وجودة مخرجات النماذج من خلال تقديم أمثلة توضيحية قبل طلب تنفيذ المهمة، مما يساعد النموذج على فهم التوقعات بشكل أفضل.

💡نماذج اللغة الكبيرة

نماذج اللغة الكبيرة هي أنظمة تعتمد على الذكاء الاصطناعي لتوليد النصوص وتحليلها بناءً على كميات هائلة من البيانات. الفيديو يوضح كيفية استخدام هذه النماذج لأداء مهام معقدة مثل التصنيف وإنشاء الجمل بناءً على توجيهات المستخدم.

💡الأنظمة النموذجية

الأنظمة النموذجية تشير إلى الطريقة التي يتم بها هيكلة أو تقديم التعليمات للنموذج. في الفيديو، يتم مناقشة دور الرسائل النظامية وكيفية تقسيم التلقين بين رسالة النظام ورسالة المستخدم للحصول على نتائج أفضل من النموذج.

💡المدخلات والمخرجات

المدخلات والمخرجات هي المعلومات التي يتم تقديمها للنموذج والنتائج التي ينتجها بناءً على تلك المعلومات. الفيديو يشرح كيف يمكن تحسين دقة النموذج من خلال تزويده بمخرجات متوقعة كنماذج ليعمل على أساسها.

💡تقنية استرجاع الكلمات

تقنية استرجاع الكلمات تُستخدم في سياق التلقين الشفهي لطلب من النموذج توليد جمل تحتوي على كلمات معينة. الفيديو يشرح كيف يمكن للنموذج استخدام هذه التقنية لإنشاء جمل حتى باستخدام كلمات غير موجودة مسبقًا في معجم معين.

💡التصنيف

التصنيف هو عملية تحديد الفئة أو الفئة الفرعية التي ينتمي إليها نص معين بناءً على محتواه. الفيديو يناقش كيفية استخدام النماذج اللغوية الكبيرة لتصنيف النصوص إلى إيجابية أو سلبية استنادًا إلى تلقين شفهي.

💡الأمثلة التوضيحية

الأمثلة التوضيحية هي الأمثلة التي يتم تقديمها للنموذج كجزء من التلقين الشفهي لتعريفه بالمهمة المطلوبة. الفيديو يوضح أهمية هذه الأمثلة في تحسين أداء النموذج وتمكينه من توليد مخرجات دقيقة وموثوقة.

💡الأسلوب والنبرة

الأسلوب والنبرة هما الطريقة التي يتم بها صياغة النصوص من حيث الشكل والمحتوى. في الفيديو، يُشرح كيف يمكن للتلقين الشفهي مساعدة النموذج على اتباع أسلوب معين أو نبرة محددة عند توليد النصوص، مما يجعل المخرجات متوافقة مع توقعات المستخدم.

💡القيود والحدود

القيود والحدود تشير إلى العوائق أو الصعوبات التي قد تواجه النموذج أثناء توليد المخرجات. الفيديو يناقش كيف يمكن للتلقين الشفهي توضيح هذه القيود والحدود للنموذج لتجنب الحصول على نتائج غير مرغوب فيها.

Highlights

شرح مفهوم التوجيه باللقطات (F-shot prompting) كوسيلة شائعة لتحسين أداء وثبات نتائج النماذج اللغوية الكبيرة.

التوجيه الصفري (Zero-shot prompting) يتم بإعطاء النموذج تعليمات مباشرة دون أمثلة.

يُعتبر التوجيه باللقطات ضرورياً للمهمات التي لم يرَ النموذج بيانات كافية عنها أو تلك المعقدة التي يصعب فهمها.

في التوجيه باللقطات، يتم تقديم أمثلة أو عروض توضيحية للنموذج لتحسين فهمه للمهمة المطلوبة.

النموذج يمكنه إنتاج جمل باستخدام كلمات مُختلقة بدون الحاجة لتدريب إضافي.

يمكن استخدام التوجيه باللقطات لتحسين أسلوب النماذج في كتابة رسائل البريد الإلكتروني أو اقتراح العناوين.

تجربة النماذج مع التوجيه باللقطات توضح قدرتها على تقديم نتائج دقيقة وثابتة عند إعطائها أمثلة توضيحية.

النموذج المستخدم في العرض هو GPT-3.5 من OpenAI.

إعداد الرسالة النظامية في Playground للنماذج من OpenAI يعتبر جزءاً أساسياً من التوجيه.

النماذج يمكنها تصنيف النصوص إلى إيجابية أو سلبية باستخدام أمثلة توضيحية.

التوجيه باللقطات يساعد في تحسين فهم النماذج للمهمات وتصحيح التحيزات المحتملة في النتائج.

يمكن تصميم التوجيه باللقطات بطرق مختلفة باستخدام أدوار النظام والمستخدم والمساعد.

إضافة التعليمات إلى رسالة النظام تساعد في تحسين فهم النموذج للمهمة.

توضيح كيفية استخدام المؤشرات الإضافية أو العناوين الفرعية في تحسين التوجيه باللقطات.

التوجيه باللقطات يمكن استخدامه في المهام المعقدة مثل تصنيف المشاعر في النصوص.

Transcripts

play00:00

in this video we are going to go over

play00:02

the concept of f shot prompting so F

play00:05

shot prompting is one of the more

play00:07

popular ways of prompting large language

play00:10

models to be able to improve performance

play00:12

and reliability in terms of the results

play00:15

and output quality that we would like

play00:18

from these

play00:19

llms in the previous guide we covered

play00:22

the idea of zero shot prompting and we

play00:25

have a video for it here if you're

play00:26

interested in what that concept is but

play00:29

basically what we do with zero shot is

play00:32

call a model or perform a task by just

play00:34

giving the model an instruction so an

play00:36

instruction can be classify the text

play00:38

into neutral negative or positive then

play00:42

you gave the model the input which is

play00:44

going to be this text I think the

play00:45

vacation is okay and then this output

play00:49

indicator here is telling the model that

play00:52

we're expecting an output which will be

play00:54

one of these labels and so this you can

play00:56

consider a classification task is also

play00:59

considered uh zero shot prompting

play01:02

because we're not adding examples right

play01:05

we're not giving the model examples of

play01:07

how to perform this task we are making

play01:09

an assumption that the model has some

play01:11

internal understanding of what this task

play01:14

is and obviously this is a pattern

play01:17

recognition system that

play01:20

can understand what the task is and what

play01:23

the intent is and be able to provide the

play01:26

right answers in this case the

play01:28

levels now this is a good first way of

play01:32

experimenting with large language models

play01:34

but these models lack capabilities in a

play01:37

lot of areas and that would be for areas

play01:40

where maybe they haven't seen enough

play01:42

data they don't understand really the

play01:44

task right it could be also a very

play01:46

complex task that the model has very

play01:48

little understanding of or very little

play01:50

knowledge of and in those cases you may

play01:54

want to experiment with something called

play01:55

f shot prompting and this is what we're

play01:57

going to cover now and F shot prompting

play01:59

the a would be to add examples or give

play02:02

the model demonstrations right you show

play02:04

it how to perform the task and then by

play02:07

showing it the M can understand better

play02:10

what that task is about and be able to

play02:12

give you more reliable and higher

play02:15

quality answers so there are various

play02:17

reasons why you may want to use f shot

play02:19

prompting and we will get into those and

play02:22

also cover an example so let's go back

play02:23

to fot prompting here which is the next

play02:26

guide after zero shot prompting so what

play02:28

we'll do is we'll start with this simple

play02:30

example and then we we'll move on to a

play02:33

more interesting example so this one is

play02:36

from the bral paper this is the GPD Tre

play02:39

paper if I'm not mistaken and this is

play02:42

directly copy pasted from that paper and

play02:44

this basically tells you shows you the

play02:46

idea of this few shot prompting

play02:49

technique so we're going to copy this

play02:51

and we're going to move it over to the

play02:52

playground again the playground that I'm

play02:55

using here is from open ey because we're

play02:57

using the open ey models and in

play02:58

particular I'm using GPD 3.5 but you

play03:01

could use any of the other models that

play03:03

you see available here in the playground

play03:05

what I'm going to do now is I'm going to

play03:06

use the system message so I can need to

play03:09

provide a system message here that's

play03:11

absolutely required now in the

play03:13

playground so what I can do is I can

play03:16

copy paste this for now but because this

play03:19

requires a system message before I input

play03:22

a user message what I can do is I can

play03:25

actually divide this into two parts so

play03:27

there are many ways how you can design

play03:29

design The Prompt itself right with the

play03:32

different roles like system role user

play03:34

role and also the assistant role but in

play03:38

this case what we want is we want to

play03:39

perform this particular task and we

play03:42

don't really want to add too many

play03:43

instructions what we just want to do is

play03:45

we just want to give them all the

play03:47

examples which in this case you can see

play03:49

in the examples it's making up a word

play03:52

right and it's defining the word and

play03:54

then it's instructing the model to come

play03:57

up with an example of a sentence that

play03:59

uses the word but before it does that it

play04:01

gives it a demonstration on how to

play04:04

perform that task so you set the

play04:06

expectation basically for the model so

play04:08

you can see that this particular

play04:10

demonstration shows what is the input

play04:13

which will be the word and what will be

play04:15

the expected output which is the

play04:16

sentence where that word is used that

play04:19

made of word again these are made of

play04:21

word so it's remarkable that this model

play04:23

can come up with a sentence right on the

play04:25

Fly about this particular word without

play04:28

us having to find tune that model or us

play04:31

having to tune the weights of that model

play04:33

to tell it what this is about so that's

play04:36

really the power of fot prompting so

play04:39

what I'm going to do here to make this

play04:41

work I can actually just go here to keep

play04:45

it really simple and I'll add this as

play04:48

part of user

play04:50

rle so what I can do is I can just uh

play04:53

add this and then now I have the system

play04:56

message so this is the demonstration and

play04:58

then I have this which will be the input

play05:00

that makes sense for me to compose it

play05:02

this way there are many other ways how

play05:04

you can go about doing this you could

play05:06

have also taken this and put it right

play05:08

there just leave it there where I had it

play05:10

and then maybe add something in the user

play05:12

role some other additional instruction

play05:14

uh there are different ways but I find

play05:16

that this is the best way to do it uh

play05:18

with these models and using these roles

play05:20

so once I have that I can now run this

play05:23

so you can see here it says uh let's

play05:26

read the input message first to do a far

play05:28

dle means to jump up and Dong really

play05:31

fast an example of a sentence that uses

play05:33

the word for doodle is and then from the

play05:36

model we get the response which is I

play05:37

couldn't contain my excitement when I

play05:39

found out I won the race so I started to

play05:41

fle right there on the spot so I think

play05:45

it's properly using the word in a

play05:47

sentence and that's great to see right

play05:50

because that's what we wanted with this

play05:52

particular task now this is a very

play05:53

simple task we actually got this from

play05:55

the paper and it was exciting at the

play05:57

time when we showed that we could do

play05:59

this with large language models because

play06:02

this generalizes right now you can use

play06:04

this uh here in this case is a toy

play06:07

example but you can use this for okay if

play06:09

you want a specific tone in an email you

play06:11

can provide demonstrations of those

play06:13

emails if you want to have certain

play06:16

headlines or you want to use them all to

play06:18

come up with headline suggestions for or

play06:22

heading suggestions for your essays or

play06:25

something like that then you can give

play06:26

them all some examples of maybe previous

play06:29

essay

play06:30

that you think have the style that you

play06:31

want and then the model should be able

play06:34

to follow that to some extent right

play06:36

that's the idea of f prompting you're

play06:37

basically telling the model or

play06:39

demonstrating to the model what you

play06:41

expect in terms of the type of output

play06:43

the quality of the output right the tone

play06:45

perhaps as well the style of it it could

play06:47

also be in this case defining of words

play06:49

giving it knowledge about certain

play06:50

Concepts as well there are different

play06:52

ways how you can use fuchia promp this

play06:54

is a basic toy example now I'm going to

play06:56

delete this so let me just delete this

play06:58

part here

play07:00

and then what I'm going to do is I'm

play07:01

going to copy over the second example we

play07:03

have a second example here in the guide

play07:05

it'll be recommended for you to read the

play07:08

guide there there are also some

play07:10

additional readings if you're interested

play07:12

in going into more details but I'm

play07:14

trying to give you more less a recap of

play07:16

what the idea is so what I'm going to do

play07:18

is I'm going to copy this over and I'm

play07:20

going to paste it right here so the way

play07:22

I can structure this right for every

play07:25

task will be a little bit different now

play07:27

I know this is uh classification task so

play07:30

what I can do here is I can tell it your

play07:32

task is to perform

play07:37

uh sentiment

play07:40

classification on the provided

play07:46

inputs you will

play07:49

classify the text input into either

play07:56

negative or positive so that's my task I

play08:00

could have improved this a bit better

play08:01

but for now we will keep it as is the

play08:05

instructions usually go in the system

play08:06

message so I have it in the system

play08:08

message already and what I can do is I

play08:10

can provide it the examples here and I

play08:12

could use something like this as well

play08:14

that's totally fine I see a lot of

play08:15

people actually use this these type of

play08:18

indicators here or what we call as

play08:21

delimiters or you can call it like

play08:22

subheadings or whatever you may want to

play08:24

call it and that's totally fine I think

play08:26

that's something that the model should

play08:28

be able to Leverage as well to better

play08:30

understand the task and better

play08:32

understand okay this part is going to be

play08:33

about examples notice that I have the

play08:36

examples here right so I have the input

play08:38

and I have the output here right input

play08:40

text and output of that input and output

play08:43

of that you could also design this a

play08:44

little bit different now I wanted to

play08:46

take a shortcut here because the way how

play08:48

I'm inputting this information is going

play08:49

to be with this you know

play08:52

additional uh indicator here right the

play08:55

additional characters but I could also

play08:57

use something like input text and then

play09:00

output right so I could I could change

play09:02

the way I'm formatting these examples

play09:05

and then I will have to carry that over

play09:07

to my final input that I'm providing for

play09:09

the model to classify so here I'm just

play09:12

going to classify this and so we got

play09:14

negative from the model which is exactly

play09:16

the classification we expected now even

play09:19

this is a very simple task but as soon

play09:22

as you start to scale on tasks like this

play09:26

this model does tend to favor a certain

play09:30

label here or a certain category like

play09:32

maybe would favor positive or negative

play09:35

because it has seen potentially more

play09:37

positive right type of content in its

play09:40

training data so our task now is to sort

play09:43

of figure out what is the best strategy

play09:46

to provide these models the examples

play09:49

maybe the model is lacking the ability

play09:52

to perform a specific classification

play09:55

then in that case we can give it more

play09:57

examples of those so that it gets it

play09:58

right now this case you saw that I give

play10:00

it an input output that's not always

play10:02

required you don't always have to give

play10:04

it input output you can also give it

play10:06

output some Tas for instance where maybe

play10:08

you want a specific type of email right

play10:11

in a specific tone in that case you can

play10:13

just give it the email right you don't

play10:14

really need to give it an input in that

play10:16

case so some task would require input

play10:18

output but some you know you can just

play10:20

get away with just giving it the output

play10:22

that'll be it for this demo and

play10:24

hopefully it's more clear what this is

play10:26

about um feel free to read here again

play10:29

understand also the limitations in the

play10:32

next video we are also going to cover

play10:33

Chain of Thought prompting which is

play10:34

another really powerful way of prompting

play10:37

these models that will be it for this

play10:39

particular video thanks for watching and

play10:42

catch you in the next one

Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
نموذج لغةتقنيات F-shotتعلم الآلةذكاء اصطناعيتحسين الأداءجودة النتائجأمثلة توضيحيةتصنيف النصوصتوليد الجملنظام الأدوار