Prompt engineering is the practice of designing and modifying input text to influence a language model’s behavior. A prompt constrains the task by specifying goals, detail, tone, or output format, much like giving a computer precise plain-language instructions. section 5.1
Prompt engineering can support several practical uses:
- Ask for structured outputs, such as comma-separated values for copying into Excel. section 5.1
- Summarize free-form survey responses into themes or roleplay a car salesperson. section 5.1
- Rewrite a user’s question before searching to potentially improve retrieval results. section 5.5.1
- Treat prompt changes as experiments rather than guarantees: updates to a model can make previously useful prompts stop working. section 5.5.1
Adding instructions around retrieved information
A retrieval-augmented generation workflow can place “Answer the question:” before a question and “Using the following information:” before retrieved documents. Extra instructions may improve relevance, but the result still depends on the model and prompt wording. section 5.5.1
Figure 5.11 On the left, we show the normal use of an LLM of a user asking about how to write JSON. LLMs naturally have the chance of producing errant outputs, which we want to minimize. On the right, we show the RAG approach. By using a search engine, we can find documents that are relevant to a query and combine them into a new prompt, giving the LLM more information and context to produce a better answer.
Compare ordinary prompting with retrieval-augmented generation: retrieved documents add information and context intended to reduce errant outputs. section 5.5.1





































