parent
summarization
Related:
Overview:
There are many ways to get the OpenAI API to generate labels. It can get some out of the bag with no prompts, others it can get with a bit of prompting. Some of the current difficulties with keywords involve named entity recognition and terms that the API has not seen before (e.g. recent news events). Providing context in the prompt can improve performance.
[EOP] indicates the end of prompt
Zero Shot Labels
List of known zero shot labels:
- Keywords
- Theme
- State
Keywords Label
Just appending "Keywords:" after a sentence will result in keywords.
Sentence: "The rain in Spain falls mainly on the plain"
Keywords:[EOP] "rain" and "Spain"
Theme Label
Just appending "Theme:" after a sentence will result in a theme.
Sentence: "The rain in Spain falls mainly on the plain"
Theme:[EOP] The weather in Spain
Few Shot: More complicated labeling
Places
Let's say we want to label places instead. Just trying 0 shot won't work. For instance, trying "places" gets the whole sentence back.
Sentence: "The rain in Spain falls mainly on the plain"
Places:[EOP] "The rain in Spain falls mainly on the plain"
Giving an example can fix that.
Sentence: "The king of France lives in Paris"
Places: "France", "Paris"
Sentence: "The rain in Spain falls mainly on the plain"
Places:[EOP] "Spain", "plain"
Multiple Labels
OpenAI API can be primed to apply multiple labels to text. For instance, it can be trained to provide both people and places.
Sentence: "Humpty Dumpty had a great fall"
People: Mr. Dumpty; Actions: Fall
Sentence: "The itsy bitsy spider crawled up the water spout"
People:[EOP] Spider; Actions: Crawl
Contextual Information
Let's say there's novel or ambiguous information the model doesn't have. For instance, suppose we have a jaguar car but OpenAI doesn't know.
Sentence: "I love Taco Bell"
Category: Food
Sentence: "I love my jaguar"
Category:[EOP] Animals
Adding additional prompts with that information can prime the API to return the correct category. For instance, we can include relevant information that we replaced our Toyota Corolla.
Sentence: "I love Taco Bell"
Category: Food
Sentence: "I upgraded my old Toyota last week"
Category:Shopping
Sentence: "I love my jaguar"
Category:[EOP] Cars
You can use the API's Search functionality to automate finding contextual primes.
Additional Resources:
There's probably other resources here, maybe can make children or something.