Spaces:
Runtime error
Runtime error
File size: 17,591 Bytes
3370a4e |
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 |
# import streamlit as st
#
# # @st.cache_resource
# # def init_PE():
# # data = {"Persona Pattern":{"Intuition":"","Format":2,"Examples":3 },
# # "Question Refinement":{"Intuition":,"Format":,"Examples": },
# # "Cognitive Verifier":{"Intuition":,"Format":,"Examples": },
# # "Audience Persona":{"Intuition":,"Format":,"Examples": },
# # "Flipped Interaction":{"Intuition":,"Format":,"Examples": },
# # "Few-Shot Prompting":{"Intuition":,"Format":,"Examples": },
# # "Chain-Of-Thought":{"Intuition":,"Format":,"Examples": },
# # "Reason+Act Prompting":{"Intuition":,"Format":,"Examples": },
# # "Gameplay Pattern":{"Intuition":,"Format":,"Examples": },
# # "Template Pattern":{"Intuition":,"Format":,"Examples": },
# # "Meta Language":{"Intuition":,"Format":,"Examples": },
# # "Alternative Approach":{"Intuition":,"Format":,"Examples": },
# # "Outline Expansion":{"Intuition":,"Format":,"Examples": }}
# st.title("Prompt Engineering Techniques")
# st.markdown(
# """
# Welcome to the prompt engineering section! Here
# we aim to introduce some common techniques used to generate
# consistent outputs from large language models like GPT and LlaMA.
# """
# )
# PE_options = st.multiselect("Select which Prompt Engineering options you are interested in",["Persona Pattern","Question Refinement","Cognitive Verifier",
# "Audience Persona","Flipped Interaction", "Few-Shot Prompting","Chain-Of-Thought",
# "Reason+Act Prompting","Gameplay Pattern","Template Prompting",
# "Meta Language Creation","Recipe Prompting","Alternative Approach",
# "Outline Expansion"])
# c11,c21 = st.columns([1,1])
# with c11:
# st.markdown(
# """
# ### Persona Pattern
# """
# )
# with st.expander("View Explanation and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**
# <span style="color: lightgray;">Tell the LLM to act as a specific person,object or entity and then
# provide them with a relevant task.</span>
# **<span style="color: #AEC6CF;">2. Format </span>**
# <span style="color: lightgray;">"Act as entity X, perform task Y."</span>
# **<span style="color: #AEC6CF;">3. Example</span>**
# <span style="color: lightgray;">"Act as a expert AI Engineer, explain to me how back-propagation works."</span>
# """,
# unsafe_allow_html=True
# )
#
# with c21:
# st.markdown(
# """
# ### Question Refinement
# """
# )
# with st.expander("View Explanation and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">To ensure that the LLM can suggest
# potentially better or more refined questions for the user to ask.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">"Whenever I ask a question, suggest a
# better question and ask me if I would like to use it instead.</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">Just enter this prompt into the chat before asking your question</span><br>
# """,
# unsafe_allow_html=True
#
# )
# c21,c22 = st.columns([1,1])
# with c21:
# st.markdown(
# """
# ### Cognitive Verifier
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**
# <span style="color: lightgray;">To force the LLM to subdivide the original question
# into multiple questions and use the answers to all those questions to fit into the final answer</span>
# **<span style="color: #AEC6CF;">2. Format </span>**
# <span style="color: lightgray;">"When you are asked a question,follow these rules:<br>Generate a number of additional questions that would help more accurately answer the question.<br>
# Combine the answers to the individual questions to produce the final answer to the overall question."</span>
# **<span style="color: #AEC6CF;">3. Example</span>**
# <span style="color: lightgray;">Just enter this prompt into the chat before asking your question.</span>
# """,
# unsafe_allow_html=True
# )
#
# with c22:
# st.markdown(
# """
# ### Audience Persona
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">Intuition is for the LLM to know your level of
# expertise so that it can better tailor it's answers to your needs</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">"Explain X to me. Assume I am persona Y."</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"Explain the self-attention mechanism to me.
# Assume I am a beginner with 0 knowledge."</span>
# """,
# unsafe_allow_html=True
# )
#
# c31,c32 = st.columns([1,1])
# with c31:
# st.markdown(
# """
# ### Flipped Interaction
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">For the LLM to be like a diagnoser and ask the
# user questions until a result is met.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">"I would like you to ask me questions to help me
# achieve X."</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"I would like you to ask me questions to help me create variations of my marketing materials. You should ask questions until you have sufficient information about my
# current draft messages, audience, and goals. Ask me the first question."</span><br>
# """,
# unsafe_allow_html=True
# )
#
# with c32:
# st.markdown(
# """
# ### Few-Shot Prompting
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">To give the LLM some input and output
# pairs and hopefully it can learn and generate the expected output
# from given input. Very similar to conventional training paradigm minus
# weight updates.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">"Input:X, Output: Y"(Simple)<br>
# "Situation:X, Think_1:Y,Action_1:Z,Think_2: A, Action_2: B"(Step by step)</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"1. Review: "The film was absolutely fantastic, with a gripping storyline and excellent acting."
# Classification: Positive <br> 2. Review: "I found the movie to be a complete waste of time, with poor plot development and bad acting."
# Classification: Negative"</span><br>
# """,
# unsafe_allow_html=True
# )
#
# c41,c42 = st.columns([1,1])
#
# with c41:
# st.markdown(
# """
# ### Chain-Of-Thought
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">Similar to few-shot prompting except
# now we provide reasoning for the output as well.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">"Question, step by step solution and then solution"</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"Solve the following problem step-by-step:
#
# Problem: What is the result of 8 multiplied by 7 plus 6?
#
# Step-by-step solution:
# 1. First, calculate the multiplication: 8 * 7 = 56
# 2. Then, add 6 to the result: 56 + 6 = 62
#
# Answer: 62"</span><br>
# """,
# unsafe_allow_html=True
# )
#
# with c42:
# st.markdown(
# """
# ### Reason+Act Prompting
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">Very similar to Chain-Of-Thought except now
# we also teach the LLM to use external tools to get information.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">"Question,Think,Action,Result"</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"**Question:** Aside from the apple remote, what other
# device can control the program apple remote? <br>
# **Task:** I need to find out search Apple Remote and find out the devices it was originally programmed to interact with<br>
# **Action:** Search [Apple Remote](https://en.wikipedia.org/wiki/Apple_Remote_Desktop)<br>
# **Result:** Apple Remote Desktop (ARD) is a Macintosh application produced by Apple Inc., first released on March 14, 2002, that replaced a similar product called Apple Network Assistant"</span><br>
# """,
# unsafe_allow_html=True
# )
#
# c51,c52 = st.columns([1,1])
# with c51:
# st.markdown(
# """
# ### Gameplay Pattern
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">Imagine you want to learn about a new topic
# , you can format it as a game and play with the LLM.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">Create a game about X topic. Describe the rules.</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"Create a game about prompt engineering. Ask me a series of questions
# about prompt engineering and see how many I get right. If I get it wrong correct me."</span><br>
# """,
# unsafe_allow_html=True
# )
#
# with c52:
# st.markdown(
# """
# ### Template Prompting
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">Basically give a template of the output that you want the
# LLM to follow. </span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">Task, template </span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"Create a random strength workout for me today with complementary exercises. I am going to provide a template for your output . CAPITALIZED WORDS are my placeholders for content. Try to fit the output into one or more of the placeholders that I list.
# Please preserve the formatting and overall template that I provide.
# This is the template: NAME, REPS @ SETS, MUSCLE GROUPS WORKED, DIFFICULTY SCALE 1-5, FORM NOTES"</span><br>
# """,
# unsafe_allow_html=True
# )
#
# c61,c62 = st.columns([1,1])
#
# with c61:
# st.markdown(
# """
# ### Meta Language Creation
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">Basically teaching the LLM your own
# secret language like when you say X you mean Y.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">"When I say X, I mean Y (or would like you to do Y)"</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"When I say "variations of companies", I mean give me ten different variations of tech companies"</span><br>
# """
# )
#
# with c62:
# st.markdown(
# """
# ### Recipe Prompting
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">Asking a question to the LLM and also
# letting it know that there exists intermediate steps required.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">I would like to achieve X.
# I know that I need to perform steps A,B,C. Please provide me with the
# necessary steps as well as any missing steps.</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"I would like to drive to MBS from Jurong. I know that I want to go through AYR and I don't want to drive more than 300 miles per day.
# Provide a complete sequence of steps for me. Fill in any missing steps."</span><br>
# """,
# unsafe_allow_html=True
# )
#
# c71,c72 = st.columns([1,1])
#
# with c71:
# st.markdown(
# """
# ### Alternative Approach
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">To allow the LLM to return users
# alternative approaches to solve a problem.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;"></span>"If there are alternative ways to accomplish a task X that I give you, list the best alternate approaches "<br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">Just input the above prompt before asking your question or task.</span><br>
# """,
# unsafe_allow_html=True
# )
#
# with c72:
# st.markdown(
# """
# ### Outline Expansion
# """
# )
# with st.expander("View Explanations and Examples"):
# st.markdown(
# """
# **<span style="color: #AEC6CF;">1. Intuition </span>**<br>
# <span style="color: lightgray;">Give the LLM a topic to provide
# an outline on and then proceed to ask it to expand on a certain part.</span><br>
# **<span style="color: #AEC6CF;">2. Format </span>**<br>
# <span style="color: lightgray;">"Act as an outline expander.
# Generate a bullet point outline based on the input that I give you and then ask me for which bullet point you should expand on.
# Create a new outline for the bullet point that I select.
# At the end, ask me for what bullet point to expand next."</span><br>
# **<span style="color: #AEC6CF;">3. Example</span>**<br>
# <span style="color: lightgray;">"Act as an outline expander. Generate a bullet point outline based on the input that I give you and then ask me for which bullet point you should expand on. Each bullet can have at most 3-5 sub bullets. The bullets should be numbered using the pattern [A-Z].[i-v].[* through ****]. Create a new outline for the bullet point that I select. At the end, ask me for what bullet point to expand next. Ask me for what to outline."</span><br>
# """,
# unsafe_allow_html=True
# )
#
|