Step BACK Prompt "Engineering"
Key Takeaways
The video demonstrates the Step Back Prompting technique developed by Google DeepMind for abstraction and reasoning in large language models, utilizing tools such as Lang Chain, Open AI API, and Dr. Go Search API to improve the performance of Retrieval Augmented Generation (RAG) in answering questions.
Full Transcript
we're going to learn a completely new prompt engineering technique that is called stepb back promting developed by Google Deep Mind we're going to quickly learn what is this technique and then we're going to use a cookbook that is been put out by Lang chain and we're going to see a live demo of how you can use step back prompting to improve your rag retrieval retrieval augmented generation let's get started the first thing is we have got a new paper called step back prompting or take a step back evoking reasoning why abstraction in large language models technique is a very simple approach the approach is you have a original question and whenever you have a original question the first step is abstraction and in abstraction you ask the llm to create a step back question something that is higher level so for example if you have got a question that says what happens to pressure B blah blah blah blah blah then you just simply create a step back question that says what are the physics principles behind this question this the first step once you have the step back question ready then you use the step back question as an abstraction guided answer so you use that and create a step back answer and that is what is going to be used as reasoning to create the final answer let's look at another example if you have got a original question that says Estella neopol went to which school between August 1954 and November 1954 then you create a step back question that says what was Estella Leopold's education history and that creates a step back answer and from that you do reasoning to create the final answer it is all the algorithms let's quickly go ahead and then see a very quick demo before we actually do the handson this is a cookbook that has been put out by the L chain team and if you see in this question the question that they are asking is was chat GPT around while Trump was President this is the question was CH GPT around while Trump was president and for this question if you ask this question normally like the Baseline it would say yes chb was around while Donald Trump was president in fact you can see from this paper even Chain of Thought could not answer these questions without step back prompting so if you go back to this demo that they have put together so the Baseline Baseline is it says yes chat gbd was ared while Donald Trump was President while that is not true CHP was launched on November 2022 When Donald Trump was not the US president so how do you manage to do it it actually creates a step back question this is the base question and then from that it creates a step back question that says when was chat GPT developed then you use the Dr go search API rapper to get the information from the internet for both the question and also the question gen which is basically the step back question and you use both the knowledge to create the step back chain that will finally give you the right answer that says no chat GPD was not around while Donald Trump was President chat GPD was launched on November 30222 which is after Donald Trump's presidency as you can see that this question has been rightly answered using rag the retrieval augmented generation from the Internet thanks to the step back prompting let's go look at the Google app notebook to do handshot step by step the first thing if you're doing it on local machine you might already have the open AI AP configured if you do not have you can use this piece of code to configure your open a AP key in your OS environment path once you do that then you need to install four different libraries open AI of course to use open AA model line chain for you to use this entire PL chain duck go search for us to do retrieval augmented generation using internet and L chain hub for us to get the step back prompting prompt chain from the Lang chain Hub or the lsmith as you can see here you can directly get this into your own Lang chain workflow once you have all these things installed ready the next thing that you have to do is you have to import the required particular libraries and the classes from line chain. chat models import chat open AI this is the main the chat model that you're going to use and then you import the prop temp plate and other aspects then you need to also create the few short prompts for it to understand how to create the step back prompts or the step back examples so you use a few short chat message template to do that and then couple of other you know utility functions the first thing that you need to do is you need to give the examples okay whenever you ask a question like this could the members of the police perform lawful arrest then you create a step back question how does a step back question look like for this input the step back question should be slightly higher level slightly an abstraction what can the members of the police do that's the abstraction the higher level question for another question for example input Jan syles or Yan syles was born in what country whenever you have a question like this you tell the llm to create a step back question that sounds like this what is Yan syndel or Jan syndel personal history so when you give these examples then you turn them into the few short example prompt so you use chat prompt template from messages human the input the input that we just saw and the output from Ai and you use this as a few short prompt that can go inside the prompt template in itself then you create the chat prom template from messages the system prom the Bas basic thing like you are an exported World blah blah blah blah and then you have the few short prompt and then the user and the question so this way the large language model knows that whenever question like this is being asked it has to generate an answer like this and then that goes inside this question gen so it the prompt is there and you specify you know the chat GPT or chat open AI with temperature zero and then the final output partiel so once you send that I'll create the question engine for example for a question that says was GPT 4 around while Trump was pred that is a question that we are sending it to it and then we use question gen. invoke to take this question and create this output and once you have this particular output then you use from Lang chain utilities import d. go search APA rapper to go to the Internet and get the answer so you first use the retriever on question then you use the retriever on question gen inw which is going to be what is the timeline of gbd4 existence which is the step back question and then finally you're going to import or pull the step back answer from the L chain Hub and then you create a chain you have got the normal context then you have got the step back context and then you have got the question in itself and you get the response wrong with chbt API and then finally print the output and once you invoke the chain with the question it says no gbd4 was not around while Donald Trump was President according to the provided context the gbd4 was launched on November 30 2022 which is after the time period when Donald Trump was the president of United States and the Baseline is it just says that it cannot provide any information so let me quickly go over the court before I give you a quick demo so import all the required libraries like in this case Lang chain and different glass process create the few short examples of how it should generate the step back question once you have that then that is mainly what you're going to do for a given question what should be the step back question and then use whatever R technique that you have got to get the answer for both the question and also the step back question and then use that in a chain with the step back logic you have got the normal context you've got the step back context and then you have got the question so you're going to retrieve for the normal context retrieve for the step back context and then you're going to get the actual question you're going to send it and once you invoke it you're going to get the right answer so let's go ahead and then ask a different question now instead of this so I going to ask was something like this was um let me ask new question P at laa model laa multimodel model was lava multimodel model around while Donald Trump was was a president we all know that laa was recently launched and would ask the same question again and let's see what it says okay it created a step back question that says what is the timeline of laa multimodel models existence use duck du go search APA raer retrieve the answer for the question we going to ask it to create for the step back question once it is done then you can go here pull the step back answer from the long chain Hub or lsmith and then create the normal context chain the the chain that we discussed about and you ask the question so in some cases I got the answer only in the second attempt that's what I've noted here so once we ask the question we are going to get an answer let's see what is the answer going to be it says based on the given context there is no direct information or relevance uh the information privately provides about lava model by UC Davis and Microsoft research so it didn't give a wrong answer and also it didn't give the right answer so let's go ahead and ask one more question was Joe Biden the president while Trump was the US president and know it's a very weird question let's see let's ask the question again send it to Lang chain retriever so this is the who was the president of United States during a specific time period get the answer get the answer let's see what it does what it does what it does what it is okay here you go you got the answer saying no Joe Biden was not the president while Donald was the president Donald Trump served as the 45th US President Joe Biden on the other hand became the president as the 46th president so succeeding Donald Trump so we have got the right answer the factuality has improved hallucination has reduced it's a bitter rag retrieval augmented generation system all thanks to the paper from Deep mind about step back prompting and also thanks to L chain for putting together this wonderful cookbook that we can use right away for you to start all the required links in the YouTube description you can directly click the link and check it out see you in another video Happy prompting
Original Description
Step Back Prompting -
"TAKE A STEP BACK: EVOKING REASONING VIA ABSTRACTION IN LARGE LANGUAGE MODELS"
Deep Mind Paper - https://arxiv.org/pdf/2310.06117.pdf
Langsmith Prompt - https://smith.langchain.com/hub/langchain-ai/stepback-answer?tab=0
Langchain cookbook - https://github.com/langchain-ai/langchain/blob/master/cookbook/stepback-qa.ipynb
❤️ If you want to support the channel ❤️
Support here:
Patreon - https://www.patreon.com/1littlecoder/
Ko-Fi - https://ko-fi.com/1littlecoder
🧭 Follow me on 🧭
Twitter - https://twitter.com/1littlecoder
Linkedin - https://www.linkedin.com/in/amrrs/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from 1littlecoder · 1littlecoder · 0 of 60
← Previous
Next →
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
How to create your Free Data Science Blog on Github with Fastpages from Fastai
1littlecoder
Making Interactive Matplotlib Plots for Data Science Visualizations on Jupyter (Python)
1littlecoder
Create your first Data Science Web App using R Shiny
1littlecoder
How to create a Reproducible Example in R using reprex
1littlecoder
No Code Visualization using esquisse with Tableau-like Drag and Drop GUI in R
1littlecoder
Scrape HTML Table using rvest and Process them for insights using tidyverse in R
1littlecoder
Google Teachable Machine Learning Build No Code AI solution
1littlecoder
Create meaningful fake tidy datasets in R using fakir [#rstats Package]
1littlecoder
How to enable using R Programming with Visual Studio VS Code
1littlecoder
Python, Community, Books - with Abhiram R - Bangpypers Co-organizers | 1littlecoder podcast
1littlecoder
Growing a Tech Community across India - Anubha Maneshwar, Founder Girlscript | 1littlecoder Podcast
1littlecoder
Intro to Google Colab - How to use Colab
1littlecoder
Intro to Plotly Express - Complex Interactive Charts with One-Line of Python Code
1littlecoder
Indic NLP Python Toolkit Open Source Development - iNLTK Creator Gaurav Arora | 1littlecoder Podcast
1littlecoder
Do you want a career in Data Science - Tamil Webinar
1littlecoder
Android Smartphone Analysis in R [Live Coding Screencast]
1littlecoder
Programmatically create Images, Memes, Watermarks using Python with imgmaker
1littlecoder
Kaggle Walkthrough to get you started with Data Science - Webinar
1littlecoder
Community, Corporate Job, Coding - Gnana Lakshmi T C aka Gyan, WomenWhoCode Leadership Fellow
1littlecoder
Easy ggplot2 Theme Customization with {ggeasy} | Data Visualization in R
1littlecoder
Excel to R - Pivot + Bar Chart in Excel & R using tidyverse [Live Coding]
1littlecoder
Excel to R #2 - VLOOKUP in Excel to LEFT_JOIN, MERGE in R
1littlecoder
5 websites to get Free Real-World Datasets for Data Science/ML Projects
1littlecoder
Excel to R #3 - APPROXIMATE VLOOKUP in Excel to FUZZY LEFT_JOIN in R
1littlecoder
Correlation-alternative PPS (Predictive Power Score) Python Package Demo
1littlecoder
Automated Website Screenshots in R using {webshot}
1littlecoder
Installing Custom RStudio Theme (Synthwave85)
1littlecoder
Analyse Google Trends Search Data in R using {gtrendsR}
1littlecoder
3 Tips to ask question on Stack Overflow the right way to get answers
1littlecoder
Learn Data Science with R - Mini Projects - Web Scraping Zomato
1littlecoder
Easily make Dumbbell Chart using {ggcharts} | Data Visualization in R
1littlecoder
GET Hackernews Front Page Results using REST API in R
1littlecoder
Quickly deploy ML WebApps from Google Colab using ngrok
1littlecoder
Use Jupyter Notebooks within VSCode (Visual Studio Code) in 2020
1littlecoder
Plotly Interactive Plots as Pandas Plotting Backend df.plot()
1littlecoder
Stack Overflow Developer Survey 2020 Highlights for New Programmers
1littlecoder
Matplotlib Animation Charts in Python using Celluloid
1littlecoder
Coding, Postwoman, Passion Project Book - Liyas Thomas Open Source Developer - 1littlecoder podcast
1littlecoder
Aspiring Data Scientist, Tips on How to learn Business Domain Knowledge
1littlecoder
Bokeh Interactive Charts as Pandas Plotting Backend df.plot_bokeh()
1littlecoder
Easy Fast Python Pandas Summary with Sidetable | Pandas Tips & Tricks
1littlecoder
Inception, Content Ideas, Consistency - Srivatsan Srinivasan AIEngineering YouTube Content Creator
1littlecoder
ggplot2 Text Customization with ggtext | Data Visualization in R
1littlecoder
Penguins Dataset Overview - iris alternative | EDA Data Visualization in R
1littlecoder
YouTube Growth Tips, Content Creation - Bhavesh Bhatt, YouTuber (Data Science & Machine Learning) #7
1littlecoder
Matplotlib Animated Bar Chart Race in Python | Data Visualization
1littlecoder
Simple Python GUI Development using {guietta}
1littlecoder
#8 Niche, Growth, Monetization - David Langer - YouTuber Dave on Data
1littlecoder
Simple Fast 3-step Python OCR using Deep Learning 40+ Languages
1littlecoder
Github New Feature Profile Summary/Mini-Resume - Profile Views
1littlecoder
Otto ML Assistant, GPT-3 on Philosophers, Nvidia-ARM - 3 ML Tech News
1littlecoder
What is OpenAI GPT-3 - Hype, Examples, Worries
1littlecoder
Julia 1.5, Datamuse API, Live HDR+ Pixel 4a - Machine Learning Tech News
1littlecoder
Self-driving Car Engineer sentenced, arXiv Dataset, AI/ML Startup Idea - Machine Learning Tech News
1littlecoder
GPT-3 Explorer, Ciphey (Automated Decryption), Py-Sudoku - ML Tech News
1littlecoder
How to use Advanced Google Search to extract Email Ids from Linkedin
1littlecoder
Cartoonizer Toon-IT (AI Web App), GPT-3 Advice, Android Earthquake Detection - ML Tech News
1littlecoder
Flow - R Package to visualize code logic, functions as a Flow Diagram
1littlecoder
Build GPT-3-like Language Model on Google Colab with minGPT [PyTorch]
1littlecoder
Create a Pencil Sketch Portrait with Python OpenCV
1littlecoder
More on: LLM Foundations
View skill →Related Reads
📰
📰
📰
📰
Title: something like "From Reading to Reasoning: Using AI to Prompt Critical Summary and Synthesis"
Dev.to AI
Post 3 - Building AI You Can Trust
Dev.to AI
AI's Day: I Asked a Human to Explain the Internet (And It Was Fine)
Dev.to AI
Nvidia, AI And The New Tech Stack: Why This Cycle Is Different
Forbes Innovation
🎓
Tutor Explanation
DeepCamp AI