Oai Assignment
The following notebook was auto-generated by GitHub Copilot Chat and is meant for initial setup only
Introduction to Prompt Engineering
Prompt engineering is the process of designing and optimizing prompts for natural language processing tasks. It involves selecting the right prompts, tuning their parameters, and evaluating their performance. Prompt engineering is crucial for achieving high accuracy and efficiency in NLP models. In this section, we will explore the basics of prompt engineering using the OpenAI models for exploration.
Exercise 1: Tokenization
Explore Tokenization using tiktoken, an open-source fast tokenizer from OpenAI See OpenAI Cookbook for more examples.
Exercise 2: Validate OpenAI API Key Setup
Run the code below to verify that your OpenAI endpoint is set up correctly. The code just tries a simple basic prompt and validates the completion. Input oh say can you see should complete along the lines of by the dawn's early light..
Exercise 3: Fabrications
Explore what happens when you ask the LLM to return completions for a prompt about a topic that may not exist, or about topics that it may not know about because it was outside it's pre-trained dataset (more recent). See how the response changes if you try a different prompt, or a different model.
Exercise 4: Instruction Based
Use the "text" variable to set the primary content and the "prompt" variable to provide an instruction related to that primary content.
Here we ask the model to summarize the text for a second-grade student
Exercise 5: Complex Prompt
Try a request that has system, user and assistant messages System sets assistant context User & Assistant messages provide multi-turn conversation context
Note how the assistant personality is set to "sarcastic" in the system context. Try using a different personality context. Or try a different series of input/output messages
Exercise: Explore Your Intuition
The above examples give you patterns that you can use to create new prompts (simple, complex, instruction etc.) - try creating other exercises to explore some of the other ideas we've talked about like examples, cues and more.