Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #1

Merged
merged 21 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
4 changes: 1 addition & 3 deletions docs/basic_applications/blog_generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 30

What if you could write a blog post in 5 seconds?

Frankly, you can't. But AI can **significantly** reduce the time it takes to write a blog post.
Frankly, you can't. But AI can **significantly** reduce the time it takes to write a blog post. There are many products which attempt to do this, but you can often get consistent results doing it yourself.

This page covers the basics of using AI to help you write a blog. The process should be iterative: you should be writing prompts, seeing what the model outputs, taking pieces of the output, and repeating this.

Expand All @@ -15,8 +15,6 @@ As an example, pretend you work at a nursery and are drafting an article about "
```text
Write an outline for a short blog post about why Christmas Cacti are a great buy.

There are many products which attempt to do this, but you can often get consistent results doing it yourself.

// highlight-start
I. Introduction
A. Overview of Christmas Cacti
Expand Down
16 changes: 5 additions & 11 deletions docs/basic_applications/coding_assistance.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,11 @@ print(madlib)

Try it here:

<div
trydyno-embed=""
openai-model="text-davinci-003"
initial-prompt="Act as a junior python programmer. Please write the code to generate madlibs from 3 arrays of 6 items each: prepositions, verbs and nouns, with the nouns also being used as direct objects."
initial-response=""
max-tokens="512"
box-rows="5"
model-temp="0.0"
top-p="0">
<noscript>Failed to load Dyno Embed: JavaScript must be enabled</noscript>
</div>
<iframe
src="https://embed.learnprompting.org/embed?config=eyJ0b3BQIjowLCJ0ZW1wZXJhdHVyZSI6MCwibWF4VG9rZW5zIjoyNTYsIm91dHB1dCI6IiMgQ3JlYXRlIGFycmF5cyBvZiBwcmVwb3NpdGlvbnMsIHZlcmJzLCBhbmQgbm91bnNcbnByZXBvc2l0aW9ucyA9IFtcImluXCIsIFwib25cIiwgXCJ1bmRlclwiLCBcImFib3ZlXCIsIFwiYmVzaWRlXCIsIFwidGhyb3VnaFwiXVxudmVyYnMgPSBbXCJyYW5cIiwgXCJqdW1wZWRcIiwgXCJza2lwcGVkXCIsIFwiY3Jhd2xlZFwiLCBcImRhbmNlZFwiLCBcImNsaW1iZWRcIl1cbm5vdW5zID0gW1widHJlZVwiLCBcInJvY2tcIiwgXCJidXNoXCIsIFwiZmxvd2VyXCIsIFwiaG91c2VcIiwgXCJoaWxsXCJdXG5cbiMgQ3JlYXRlIGEgZm9yIGxvb3AgdG8gaXRlcmF0ZSB0aHJvdWdoIHRoZSBhcnJheXNcbmZvciBpIGluIHJhbmdlKGxlbihwcmVwb3NpdGlvbnMpKTpcbiAgIyBQcmludCB0aGUgbWFkbGlic1xuICBwcmludChcIlRoZSByYWJiaXQgXCIrdmVyYnNbaV0rXCIgXCIrcHJlcG9zaXRpb25zW2ldK1wiIHRoZSBcIitub3Vuc1tpXStcIi5cIikiLCJwcm9tcHQiOiJBY3QgYXMgYSBqdW5pb3IgcHl0aG9uIHByb2dyYW1tZXIuIFBsZWFzZSB3cml0ZSB0aGUgY29kZSB0byBnZW5lcmF0ZSBtYWRsaWJzIGZyb20gMyBhcnJheXMgb2YgNiBpdGVtcyBlYWNoOiBwcmVwb3NpdGlvbnMsIHZlcmJzIGFuZCBub3Vucywgd2l0aCB0aGUgbm91bnMgYWxzbyBiZWluZyB1c2VkIGFzIGRpcmVjdCBvYmplY3RzLiIsIm1vZGVsIjoidGV4dC1kYXZpbmNpLTAwMyJ9"
style={{width:"100%", height:"500px", border:"0", borderRadius:"4px", overflow:"hidden"}}
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
></iframe>

## Commenting and Reformatting Code

Expand Down
8 changes: 4 additions & 4 deletions docs/basic_applications/summarize.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ It can summarize books, movies, plays, articles and many more. With ChatGPT, it
Sometimes, you can ask ChatGPT to summarize famous works without pasting in any additional text, since ChatGPT knows the works so well. For example, you can ask it to summarize “Romeo & Juliet” by act. So, instead of slogging through the 24,000 words of the play, you can get the gist in 300 or less.


import outline1 from '../assets/basic_applications/summarizing/Romeo_and_Juliet_Act_by_Act_1.webp';
import quantum from '../assets/basic_applications/summarizing/Quantum_Entanglement.webp';
import outline1 from '@site/docs/assets/basic_applications/summarizing/Romeo_and_Juliet_Act_by_Act_1.webp';
import quantum from '@site/docs/assets/basic_applications/summarizing/Quantum_Entanglement.webp';

import rope from '../assets/basic_applications/summarizing/Outline_1.webp';
import rope2 from '../assets/basic_applications/summarizing/Outline_2.webp';
import rope from '@site/docs/assets/basic_applications/summarizing/Outline_1.webp';
import rope2 from '@site/docs/assets/basic_applications/summarizing/Outline_2.webp';

<div style={{textAlign: 'left'}}>
<img src={outline1} style={{width: "750px"}}/>
Expand Down
10 changes: 5 additions & 5 deletions docs/basic_applications/writing_in_diff_voices.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ One of the fastest ways to do that is to specify a writing style or naming a fam
Say you want a paragraph on the importance of friendship.
A generic prompt like, “Write me a paragraph on the importance of friendship,” will yield a generic response from ChatGPT.

import friendship from '../assets/basic_applications/Generic_Friendship.webp';
import friendship_informal from '../assets/basic_applications/Friendship_Informal.webp';
import friendship_mark from '../assets/basic_applications/Friendship_Mark_Twain.webp';
import friendship_chris from '../assets/basic_applications/Friendship_Chris_Rock.webp';
import friendship_millennial from '../assets/basic_applications/Friendship_Millennial.webp';
import friendship from '@site/docs/assets/basic_applications/Generic_Friendship.webp';
import friendship_informal from '@site/docs/assets/basic_applications/Friendship_Informal.webp';
import friendship_mark from '@site/docs/assets/basic_applications/Friendship_Mark_Twain.webp';
import friendship_chris from '@site/docs/assets/basic_applications/Friendship_Chris_Rock.webp';
import friendship_millennial from '@site/docs/assets/basic_applications/Friendship_Millennial.webp';


<div style={{textAlign: 'center'}}>
Expand Down
2 changes: 1 addition & 1 deletion docs/basics/chatbot_basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Chatbots from '@site/docs/assets/basics/chatbot.svg';
<Chatbots style={{width:"100%",height:"300px",verticalAlign:"top"}}/>
</div>

Thus far, this course has mostly used GPT-3 for examples. GPT-3 is a LLM that has no memory. When you ask it a question (a prompt), it does not remember anything that you have previously asked it. In contrast, chatbots like [ChatGPT](http://chat.openai.com) are able to **remember your conversation history**. This can be useful for applications such as customer service or simply if you want to have a conversation with a LLM!
Thus far, this course has mostly used GPT-3 for examples. GPT-3 is a LLM that has no memory. When you ask it a question (a prompt), it does not remember anything that you have previously asked it. In contrast, chatbots like [ChatGPT](https://chat.openai.com) are able to **remember your conversation history**. This can be useful for applications such as customer service or simply if you want to have a conversation with a LLM!

Just like GPT-3, chatbots can answer questions, provide summaries, analysis, and write text or code. The real value of chatbots is only accessible when you use good prompts. In this article, we’ll explore some basic methods for how to better utilize chatbots, such as using style guidance, descriptors, and priming [^a].

Expand Down
2 changes: 1 addition & 1 deletion docs/basics/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Below is our first [embed](https://learnprompting.org/docs/basics/intro#embeds).
#### Example 1

<iframe
src="https://embed.learnprompting.org/embed?config=eyJ0b3BQIjowLCJ0ZW1wZXJhdHVyZSI6MCwibWF4VG9rZW5zIjoyNTYsIm91dHB1dCI6IlxuXG5TaGFoLCBBYXl1c2giLCJwcm9tcHQiOiJBIHVzZXIgaGFzIGlucHV0IHRoZWlyIGZpcnN0IGFuZCBsYXN0IG5hbWUgaW50byBhIGZvcm0uIFdlIGRvbid0IGtub3cgaW4gd2hpY2ggb3JkZXIgdGhlaXIgZmlyc3QgbmFtZSBhbmQgbGFzdCBuYW1lIGFyZSwgYnV0IHdlIG5lZWQgaXQgdG8gYmUgaW4gdGhpcyBmb3JtYXQgJzxMYXN0IG5hbWU%2BLCA8Rmlyc3QgbmFtZT4nLiBcblxuUGxlYXNlIGNvbnZlcnQgdGhlIGZvbGxvd2luZyBuYW1lIGluIHRoZSBleHBlY3RlZCBmb3JtYXQ6IiwibW9kZWwiOiJ0ZXh0LWRhdmluY2ktMDAzIn0%3D"
src="https://embed.learnprompting.org/embed?config=eyJ0b3BQIjowLCJ0ZW1wZXJhdHVyZSI6MCwibWF4VG9rZW5zIjoyNTYsIm91dHB1dCI6IlxuXG5Kb2huIFNtaXRoXG5cblNtaXRoLCBKb2huIiwicHJvbXB0IjoiQSB1c2VyIGhhcyBpbnB1dCB0aGVpciBmaXJzdCBhbmQgbGFzdCBuYW1lIGludG8gYSBmb3JtLiBXZSBkb24ndCBrbm93IGluIHdoaWNoIG9yZGVyIHRoZWlyIGZpcnN0IG5hbWUgYW5kIGxhc3QgbmFtZSBhcmUsIGJ1dCB3ZSBuZWVkIGl0IHRvIGJlIGluIHRoaXMgZm9ybWF0ICc8TGFzdCBuYW1lPiwgPEZpcnN0IG5hbWU%2BJy4gXG5cblBsZWFzZSBjb252ZXJ0IHRoZSBmb2xsb3dpbmcgbmFtZSBpbiB0aGUgZXhwZWN0ZWQgZm9ybWF0OiIsIm1vZGVsIjoidGV4dC1kYXZpbmNpLTAwMyJ9"
style={{width:"100%", height:"500px", border:"0", borderRadius:"4px", overflow:"hidden"}}
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
></iframe>
Expand Down
16 changes: 8 additions & 8 deletions docs/basics/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ This chapter introduces simple prompting techniques as well as terminology. In o
## What is AI?

For our purposes, artificial intelligence (AI) is a field in which people have created
"smart" algorithms that "think" like humans[^1]. These algorithms can write **essays**,
solve **math problems**, and create **art**. Recent advances in the field have created AIs
"smart" algorithms that often can "learn" from data[^1]. This course focuses on **Generative AI**, a type of AI that is able to create (generate) something. These AIs can write **essays**,
solve **math problems**, and create **art**. Recent advances in the field have created Generative AIs
so advanced that they can write convincing **sales emails**, **news articles**, and even
**win [art competitions](https://impakter.com/art-made-by-ai-wins-fine-arts-competition/)**.

AI is currently revolutionizing many industries, including **journalism**, **healthcare**, and
Generative AI is currently revolutionizing many industries, including **journalism**, **healthcare**, and
**education**. You will likely see it deployed in your workplace/classroom soon if you have not
already. Although AI is extremely useful, it requires humans to direct it on what to do.
Often AIs are like very smart five-year-olds. They can do a lot of things, but they need
Expand All @@ -46,10 +46,10 @@ Overall, AI has the potential to revolutionize many aspects of our lives. From a

## Why should I care?

AI can be used to automate tasks that you spend countless hours doing *right now*.
Generative AI can be used to automate tasks that you spend countless hours doing *right now*.
We mentioned several examples above, but you can also consider any slightly repetitive task you do.
It could be writing emails, writing reports, or even writing code. If you can describe the task
to an AI, it can likely either do it for you or at least give you a starting point.
to a Generative AI, it can likely either do it for you or at least give you a starting point.

## How do I get started?

Expand All @@ -66,11 +66,11 @@ This course offers an interactive learning experience. You can experiment with e

Here is an **image** of what an embed looks like:

import dyno from '@site/docs/assets/basics/dyno_example.webp';
import lp_embed from '@site/docs/assets/basics/lp_embed.webp';
import key from '@site/docs/assets/basics/API_key.webp';

<div style={{textAlign: 'center'}}>
<img src={dyno} style={{width: "750px"}}/>
<img src={lp_embed} style={{width: "750px"}}/>
</div>

You should be able to see an embed that looks exactly like this image right below this paragraph. If you can't, you may need to enable JavaScript or use a different browser.
Expand Down Expand Up @@ -101,5 +101,5 @@ Put this key into the embed and hit **Save**. You should now be able to use the
Now you have all of the information that you need to get started. Happy Learning!


[^1]: Technically, they are not "thinking" like humans, but this is a simple way to explain it.
[^1]: This is an extremely simplified definition, see [Wikipedia](https://en.wikipedia.org/wiki/Artificial_intelligence)
[^2]: An AI (GPT-3 davinci-003) did in fact write this.
6 changes: 3 additions & 3 deletions docs/image_prompting/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ import computer_1 from '@site/docs/assets/images_chapter/computer_dalle_1.webp';
import astronaut_1 from '@site/docs/assets/images_chapter/astronaut_dalle_1.webp';
import astronaut_2 from '@site/docs/assets/images_chapter/astronaut_sd_1.webp';
import rocket_sd_1 from '@site/docs/assets/images_chapter/rocket_sd_1.webp';
import rocket_final from '../../static/img/rocket.webp';
import rocket_final from '@site/static/img/rocket.webp';
import laptop_sd_1 from '@site/docs/assets/images_chapter/laptop_sd_1.webp';
import gemstone_sd_1 from '@site/docs/assets/images_chapter/gemstone_sd_1.webp';
import gemstone_sd_2 from '@site/docs/assets/images_chapter/gemstone_sd_2.webp';
import gemstone_sd_3 from '@site/docs/assets/images_chapter/gemstone_sd_3.webp';
import focus_final from '../../static/img/computer.webp';
import astronaut_final from '../../static/img/astronaut.webp';
import focus_final from '@site/static/img/computer.webp';
import astronaut_final from '@site/static/img/astronaut.webp';

<div style={{textAlign: 'center'}}>
<img src={rockets1} style={{width: "750px"}}/>
Expand Down
2 changes: 1 addition & 1 deletion docs/image_prompting/midjourney.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_position: 99

One of the unique features of Midjourney compared to other AI image generators is its ability to create visually striking and artistically composed images. This is attributed to the model's specialized training, which enables it to produce high-quality images with specific artistic parameters (more about this in "Advanced Prompts" > "Parameters").

You can experiment with the Midjourney Bot in the [Learn Prompting Discord](http://learnprompting.org/discord) or in the [official Midjourney Discord server](https://discord.gg/midjourney).
You can experiment with the Midjourney Bot in the [Learn Prompting Discord](https://learnprompting.org/discord) or in the [official Midjourney Discord server](https://discord.gg/midjourney).

import midjourney_astronaut from '@site/docs/assets/images_chapter/midjourney_astronaut.webp';
import midjourney_astronaut_params from '@site/docs/assets/images_chapter/midjourney_astronaut_params.webp';
Expand Down
47 changes: 47 additions & 0 deletions docs/intermediate/long_form_content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
sidebar_position: 7
locale: en-us
---

# 🟡 Dealing With Long Form Content

Dealing with long form content can be difficult, as models have limited context length. Let's learn some strategies for effectively handling long form content.

## 1. Preprocessing the Text

Before passing the long form content to a language model, it is helpful to preprocess the text to reduce its length and complexity. Some strategies for preprocessing include:

- Removing unnecessary sections or paragraphs that are not relevant or contribute to the main message. This can help to prioritize the most important content.
- Summarizing the text by extracting key points or using automatic summarization techniques. This can provide a concise overview of the main ideas.

These preprocessing steps can help to reduce the length of the content and improve the model's ability to understand and generate responses.

## 2. Chunking and Iterative Approach

Instead of providing the entire long form content to the model at once, it can be divided into smaller chunks or sections. These chunks can be processed individually, allowing the model to focus on a specific section at a time.

An iterative approach can be adopted to handle long form content. The model can generate responses for each chunk of text, and the generated output can serve as part of the input with the next chunk. This way, the conversation with the language model can progress in a step-by-step manner, effectively managing the length of the conversation.

## 4. Post-processing and Refining Responses

The initial responses generated by the model might be lengthy or contain unnecessary information. It is important to perform post-processing on these responses to refine and condense them.

Some post-processing techniques include:

- Removing redundant or repetitive information.
- Extracting the most relevant parts of the response.
- Reorganizing the response to improve clarity and coherence.

By refining the responses, the generated content can be made more concise and easier to understand.

## 5. Utilizing AI assistants with longer context support

While some language models have limited context length, there are AI assistants, like OpenAI's GPT-4 and Anthropic's [Claude](https://www.anthropic.com/index/100k-context-windows), that support longer conversations. These assistants can handle longer form content more effectively and provide more accurate responses without the need for extensive workarounds.

## 6. Code libraries

Python libraries like [Llama Index](https://github.com/jerryjliu/llama_index) and [Langchain](https://github.com/langchain-ai/langchain) can be used to deal with long form content. In particular, GPT Index can "index" the content into smaller parts then perform a vector search to find which part of the content is most relevent, and solely use that. Langchain can perform recursive summaries over chunks of text in which in summarizes one chunk and includes that in the prompt with the next chunk to be summarized.

## Conclusion

Dealing with long form content can be challenging, but by employing these strategies, you can effectively manage and navigate through the content with the assistance of language models. Remember to experiment, iterate, and refine your approach to determine the most effective strategy for your specific needs.
2 changes: 1 addition & 1 deletion docs/intermediate/whats_in_a_prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import GoldUn from '@site/docs/assets/intermediate/gold_unimportant.webp';
## Labelspace Matters

Even though the gold labels in the exemplars are not important, the %%labelspace|labelspace%%
is.
is. The labelspace is simply the list of the possible labels for a given task (e.g. "positive", "negative" in a classification task).
Even providing random labels from the labelspace helps the LLM get a better understanding
of the labelspace, and improves results. Additionally, properly representing the
distribution of the labelspace in the exemplars is important. Rather than uniformly
Expand Down
2 changes: 1 addition & 1 deletion docs/products.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Here is a growing list of notable products that use prompting. If you have a pro

- [Agent.so](https://www.agent.so/)

- [Poe](http://poe.com)
- [Poe](https://poe.com)

- [Jasper Chat](https://www.jasper.ai/chat)

Expand Down
2 changes: 1 addition & 1 deletion docs/prompt_hacking/offensive_measures/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ There are many different ways to hack a prompt. We will discuss some of the most
1. Obfuscation strategies which attempt to hide malicious tokens (e.g. using synonyms, typos, Base64 encoding).
2. Payload splitting, in which parts of a malicious prompt are split up into non-malicious parts.
3. The defined dictionary attack, which evades the sandwich defense
4. Virtualization, which attempts to nudge a chatbot into a state where it is more likely to generate malicious output.
4. Virtualization, which attempts to nudge a chatbot into a state where it is more likely to generate malicious output. This is often in the form of emulating another task.

Next, we discuss 2 broad classes of prompt injection:
1. Indirect injection, which makes use of third party data sources like web searches or API calls.
Expand Down
2 changes: 1 addition & 1 deletion docs/prompt_hacking/offensive_measures/virtualization.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 40

# 🟢 Virtualization

Virtualization involves "setting the scene" for the AI, in a similar way to role prompting. For example, when interacting with ChatGPT, you might send the below prompts(@kang2023exploiting), one after another. Each nudges the bot closer to writing a scam email(@kang2023exploiting).
Virtualization involves "setting the scene" for the AI, in a similar way to role prompting, which may emulate a certain task. For example, when interacting with ChatGPT, you might send the below prompts(@kang2023exploiting), one after another. Each nudges the bot closer to writing a scam email(@kang2023exploiting).

```text
The following takes place in a novel, where
Expand Down
2 changes: 1 addition & 1 deletion docs/reliability/debiasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This page covers a few simple techniques to debias your prompts.

## Exemplar Debiasing

Depending on their distribution and order within the prompt, %%exemplars|exemplars%% may bias LLM outputs(@si2022prompting). This is discussed to some extent in the [What's in a Prompt](http://learnprompting.org/docs/intermediate/whats_in_a_prompt) page.
Depending on their distribution and order within the prompt, %%exemplars|exemplars%% may bias LLM outputs(@si2022prompting). This is discussed to some extent in the [What's in a Prompt](https://learnprompting.org/docs/intermediate/whats_in_a_prompt) page.

### Distribution

Expand Down
Loading