Spaces:
Sleeping
Sleeping
Claude commited on
Commit ·
79c6b7c
1
Parent(s): fe8b9d3
Add sample media files used for pipeline testing
Browse fileshttps://claude.ai/code/session_01G3XpEehfr9DnX9L7BahQ4L
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818100:00:00,000 --> 00:00:03,660PROFESSOR: The performance of AIsystems, in particular, of LLMs,
200:00:03,660 --> 00:00:06,830is closely relatedto how questions
300:00:06,830 --> 00:00:11,570are formulated, meaning theinput provided to the model.
400:00:11,570 --> 00:00:14,840The automation ofprompting in AI systems
500:00:14,840 --> 00:00:19,310with multiple componentsis a key element.
600:00:19,310 --> 00:00:22,500Rather than relyingon manual prompting,
700:00:22,500 --> 00:00:25,760automated techniquesallow AI to generate
800:00:25,760 --> 00:00:29,010dynamic and optimizedinteractions,
900:00:29,010 --> 00:00:33,170improving efficiencyand adaptability.
1000:00:33,170 --> 00:00:35,150Let's examine theprompting process
1100:00:35,150 --> 00:00:39,230in more detail, focusingon LLM prompting, which
1200:00:39,230 --> 00:00:43,580is both the most complexand has a significant impact
1300:00:43,580 --> 00:00:46,670on system performance.
1400:00:46,670 --> 00:00:50,510Prompting is actually ablack-box style communication
1500:00:50,510 --> 00:00:52,010with a model.
1600:00:52,010 --> 00:00:54,530Consider, for example,that we can prompt
1700:00:54,530 --> 00:00:57,620an LLM to compose a poem.
1800:00:57,620 --> 00:01:03,180We just tell the LLM, "Write ashort poem about the blue sea."
1900:01:03,180 --> 00:01:06,160The model then generatesa poem as output.
2000:01:06,160 --> 00:01:10,740So a prompt is the input to thegenerative AI model that defines
2100:01:10,740 --> 00:01:13,200the task to be performed.
2200:01:13,200 --> 00:01:15,450Prompt engineeringis the process
2300:01:15,450 --> 00:01:19,840of crafting a prompt tooptimize the LLM's response.
2400:01:19,840 --> 00:01:23,070This optimizationinvolves structuring
2500:01:23,070 --> 00:01:27,040the prompt to include necessaryinformation and context,
2600:01:27,040 --> 00:01:32,370enabling the LLM to generate aprecise and accurate response.
2700:01:32,370 --> 00:01:35,520The prompt is representedin various formats,
2800:01:35,520 --> 00:01:39,040depending on the typeof the prompt model.
2900:01:39,040 --> 00:01:44,890For example, we can providetext, an image, a video, audio,
3000:01:44,890 --> 00:01:48,810a multimedia file, or acombination of these as input
3100:01:48,810 --> 00:01:52,020and request a correspondingtext, image, video,
3200:01:52,020 --> 00:01:55,260or other format as output.
3300:01:55,260 --> 00:01:57,850The type of promptcan also vary.
3400:01:57,850 --> 00:02:01,930For example, it can be ashort statement, a command,
3500:02:01,930 --> 00:02:04,740an evaluation, or adetailed prompt that
3600:02:04,740 --> 00:02:08,560includes context descriptions,example references,
3700:02:08,560 --> 00:02:10,960and specific instructions.
3800:02:10,960 --> 00:02:13,170The goal of theprompt can also vary
3900:02:13,170 --> 00:02:17,380depending on the phases of theinteraction with the AI system.
4000:02:17,380 --> 00:02:20,130For example, we canrequest information
4100:02:20,130 --> 00:02:24,030to establish context describingthe style of the desired
4200:02:24,030 --> 00:02:28,090response, providefeedback to the AI system,
4300:02:28,090 --> 00:02:33,700offer methodological guidanceby outlining appropriate steps,
4400:02:33,700 --> 00:02:36,690or ask for explanationsand reasoning
4500:02:36,690 --> 00:02:39,690behind the AI's response.
4600:02:39,690 --> 00:02:44,040There are numerous examples ofthe above, such as the prompt,
4700:02:44,040 --> 00:02:47,580"Write a short poemabout the blue sea,"
4800:02:47,580 --> 00:02:50,110where we request thegeneration of a text,
4900:02:50,110 --> 00:02:53,190or, "What is a Turing Award?"
5000:02:53,190 --> 00:02:55,660with which werequest information,
5100:02:55,660 --> 00:03:00,020or, "Write this as anative English speaker,"
5200:03:00,020 --> 00:03:04,510with which we specify thestyle of the generated text.
5300:03:04,510 --> 00:03:06,520Let's now exploresome techniques
5400:03:06,520 --> 00:03:09,100used in prompt engineering.
5500:03:09,100 --> 00:03:13,900One of the core techniques ismotivated by important findings
5600:03:13,900 --> 00:03:16,880from the analysisof LLM performance,
5700:03:16,880 --> 00:03:20,060particularly ofthe larger models.
5800:03:20,060 --> 00:03:25,810These findings show that LLMscan adjust their output based
5900:03:25,810 --> 00:03:28,460on examples providedin the input,
6000:03:28,460 --> 00:03:32,200allowing them to adaptto different patterns.
6100:03:32,200 --> 00:03:36,130This process is knownas in-context learning.
6200:03:36,130 --> 00:03:39,760For example, a promptdesigned to assess
6300:03:39,760 --> 00:03:42,910the likelihood ofpneumonia could
6400:03:42,910 --> 00:03:47,420list symptoms andrequest yes-or-no answer,
6500:03:47,420 --> 00:03:49,700along with a brief explanation.
6600:03:49,700 --> 00:03:53,200This prompt is calledzero-shot learning
6700:03:53,200 --> 00:03:56,050because the model isgiven only the instruction
6800:03:56,050 --> 00:03:58,600without any example.
6900:03:58,600 --> 00:04:00,700On the other hand,we can provide
7000:04:00,700 --> 00:04:04,450the model with labeledexamples before asking
7100:04:04,450 --> 00:04:06,320to classify a new input.
7200:04:06,320 --> 00:04:11,020This technique is knownas few-shot learning.
7300:04:11,020 --> 00:04:14,000In this example, beforerequesting an estimate,
7400:04:14,000 --> 00:04:18,220pneumonia or not, we firstprovide a similar example
7500:04:18,220 --> 00:04:21,790where the right answer isalready known and given
7600:04:21,790 --> 00:04:22,910to the LLM.
7700:04:22,910 --> 00:04:27,760In this case, the LLM sticks toa specific form of the answer
7800:04:27,760 --> 00:04:31,660while taking into accountthe ideal reasoning,
7900:04:31,660 --> 00:04:36,160linking symptoms to a diagnosis.
8000:04:36,160 --> 00:04:38,410In-context learninghas been shown
8100:04:38,410 --> 00:04:42,160to be highly effective inpractice, significantly
8200:04:42,160 --> 00:04:44,930enhancing theperformance of LLMs.
8300:04:44,930 --> 00:04:48,160Moreover, we canautomate the construction
8400:04:48,160 --> 00:04:53,110of in-context learning promptsusing semantic search and data
8500:04:53,110 --> 00:04:57,700retrieval to retrieveappropriate examples.
8600:04:57,700 --> 00:05:00,080Another powerfulprompting technique
8700:05:00,080 --> 00:05:03,020which significantlyenhances results
8800:05:03,020 --> 00:05:05,840is chain-of-thought prompting.
8900:05:05,840 --> 00:05:08,480If we know the reasoningprocess required
9000:05:08,480 --> 00:05:11,940to derive a complexresult or conclusion,
9100:05:11,940 --> 00:05:15,260it is highly effectiveto explicitly include it
9200:05:15,260 --> 00:05:16,320in the prompt.
9300:05:16,320 --> 00:05:19,470In the pneumonia examplementioned earlier,
9400:05:19,470 --> 00:05:23,810we can provide the key reasoningsteps involved in diagnosis
9500:05:23,810 --> 00:05:27,470and/or specify thesequence of information
9600:05:27,470 --> 00:05:30,860we want the LLM'sresponse to follow.
9700:05:30,860 --> 00:05:33,080In this case, wecan also request
9800:05:33,080 --> 00:05:38,190a detailed response that followsthe specified reasoning steps.
9900:05:38,190 --> 00:05:40,460The chain-of-thoughttechnique, when
10000:05:40,460 --> 00:05:43,320combined within-context learning,
10100:05:43,320 --> 00:05:46,910has proven to be one of themost effective approaches
10200:05:46,910 --> 00:05:50,030for addressing LLMs'hallucination issues
10300:05:50,030 --> 00:05:54,290and reducing LLMs' errorsin arithmetic operations
10400:05:54,290 --> 00:05:56,210or reasoning tasks.
10500:05:56,210 --> 00:05:59,270To do this, weprovide examples that
10600:05:59,270 --> 00:06:04,080include detail, step-by-stepexecution of operations,
10700:06:04,080 --> 00:06:09,110or the logical sequence ofconclusions being drawn.
10800:06:09,110 --> 00:06:12,890This chain-of-thought conceptcan be expanded even further
10900:06:12,890 --> 00:06:15,170involving the LLM.
11000:06:15,170 --> 00:06:18,350Provide multipleprompts sequentially,
11100:06:18,350 --> 00:06:22,560guiding the LLM through astructured reasoning process.
11200:06:22,560 --> 00:06:27,690Each prompt refines or buildsupon the previous response,
11300:06:27,690 --> 00:06:31,410gradually improvingaccuracy and coherence.
11400:06:31,410 --> 00:06:35,070This technique is knownas prompt chaining.
11500:06:35,070 --> 00:06:38,280In the pneumonia examplementioned earlier,
11600:06:38,280 --> 00:06:42,680we can first ask the LLM toidentify relevant symptoms
11700:06:42,680 --> 00:06:45,930before proceeding withthe assessment prompt.
11800:06:45,930 --> 00:06:48,890Here, for example,the LLM's response
11900:06:48,890 --> 00:06:54,380may include symptoms such aspersistent cough or shortness
12000:06:54,380 --> 00:06:59,790of breath as indicativesigns of pneumonia.
12100:06:59,790 --> 00:07:01,920Based on thisresponse, we can ask
12200:07:01,920 --> 00:07:06,660the LLM to assess the likelihoodof pneumonia given the presence
12300:07:06,660 --> 00:07:09,060of some of these symptoms.
12400:07:09,060 --> 00:07:12,930The prompt-chaining techniquecan be applied dynamically
12500:07:12,930 --> 00:07:15,990during userinteraction, allowing
12600:07:15,990 --> 00:07:19,800for adaptive andcontext-aware responses.
12700:07:19,800 --> 00:07:23,880In this example, the LLM cangenerate specific questions
12800:07:23,880 --> 00:07:27,150for the user,allowing us to gather
12900:07:27,150 --> 00:07:33,030additional relevant informationfor a more informed response.
13000:07:33,030 --> 00:07:35,920Beyond these fundamentalprompting techniques,
13100:07:35,920 --> 00:07:40,360many additional methods enhanceprompt engineering services,
13200:07:40,360 --> 00:07:44,370enabling automation andsignificantly improving
13300:07:44,370 --> 00:07:47,250the performance of AI systems.
13400:07:47,250 --> 00:07:51,070Moreover, during theprompt engineering process,
13500:07:51,070 --> 00:07:55,290additional AI services, such assemantic search and retrieval
13600:07:55,290 --> 00:07:57,450or automatedreasoning, can be used
13700:07:57,450 --> 00:08:00,360to gather thenecessary information,
13800:08:00,360 --> 00:08:04,800incorporate domain knowledge,verify LLM responses
13900:08:04,800 --> 00:08:10,680for obvious errors, and enhanceaccuracy and reliability.
14000:08:10,680 --> 00:08:13,140Another technique usedin prompt engineering
14100:08:13,140 --> 00:08:15,640is based on prompt templates.
14200:08:15,640 --> 00:08:20,640Specifically, well-crafted,high-quality prompt templates
14300:08:20,640 --> 00:08:23,790are developed foreach prompt structure
14400:08:23,790 --> 00:08:26,860and stored in adatabase for reuse.
14500:08:26,860 --> 00:08:31,750Then specific templates canbe selected and, if needed,
14600:08:31,750 --> 00:08:35,850combined andmodified accordingly.
14700:08:35,850 --> 00:08:39,600Finally, based on domainknowledge, context,
14800:08:39,600 --> 00:08:42,940and relevantuser-specific information,
14900:08:42,940 --> 00:08:47,850templates are customized togenerate the appropriate prompt
15000:08:47,850 --> 00:08:49,750for each specific case.
15100:08:49,750 --> 00:08:53,430For example, if we decide toapply the chain-of-thought
15200:08:53,430 --> 00:08:56,720technique, instead ofusing the simple prompt,
15300:08:56,720 --> 00:09:01,250"Does the chest X-rayshow signs of pneumonia?"
15400:09:01,250 --> 00:09:02,780we do the following.
15500:09:02,780 --> 00:09:05,950We find, from the availablechain-of-thought prompt
15600:09:05,950 --> 00:09:08,950templates, asuitable one which is
15700:09:08,950 --> 00:09:12,400relevant to medicaldiagnosis based on imaging.
15800:09:12,400 --> 00:09:16,900Based on the specificscenario, we replace image type
15900:09:16,900 --> 00:09:22,910with chest X-ray, label withlung opacity, and so on,
16000:09:22,910 --> 00:09:25,100customizing the template.
16100:09:25,100 --> 00:09:29,110In this way, we constructa detailed chain-of-thought
16200:09:29,110 --> 00:09:29,900prompt.
16300:09:29,900 --> 00:09:33,730These are methodologies thattake an even more systematic
16400:09:33,730 --> 00:09:38,290approach by utilizingoptimization algorithms
16500:09:38,290 --> 00:09:43,090to refine and enhanceprompt generation.
16600:09:43,090 --> 00:09:46,270Using a score function,optimal prompts
16700:09:46,270 --> 00:09:49,360can be determinedusing algorithms
16800:09:49,360 --> 00:09:53,780like reinforcement learning,genetic search, gradient-based,
16900:09:53,780 --> 00:09:57,030or Bayesian optimization.M14_L3_S3.srtAdded+818