There are three fundamental techniques you can use when prompting LLMs. Understanding when and how to use each will help you craft more effective prompts.Documentation Index
Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
Use this file to discover all available pages before exploring further.
Zero-shot Prompting
Zero-shot prompting means asking the model to perform a task without providing any examples. Since these models have been trained on massive datasets, their internal knowledge makes them capable of performing a large number of tasks without demonstrations. Think of it like: Asking a guitar player to play the piano, even though they’ve never played piano before. They’d apply their previous knowledge about music and instruments to figure it out. Example: Prompt:Few-shot Prompting
Few-shot prompting means providing demonstrations of how to perform a task. Instead of relying only on the AI model’s general training, you give specific examples that guide the model to perform your exact task with higher quality. Think of it like: Showing a guitarist a few piano pieces before asking them to play piano for the first time. Example: Prompt:- Complex or nuanced tasks where format matters
- When you need consistent output structure
- 3-4 examples typically work best
Chain-of-Thought Prompting
Chain-of-thought prompting improves reasoning quality by forcing the model to externalize its thinking process, essentially making it “show its work.” This is especially useful for complex or edge-case problems where the model might otherwise hallucinate or produce logically inconsistent results. Three proven techniques:1. Direct Step-by-Step Instructions
Add “Think step by step” to your prompt. This simple phrase triggers the model to break down complex problems into logical components rather than jumping to conclusions.2. Provide a Logical Framework
Instead of hoping the model figures out the right approach, give it the exact framework to follow. This reduces reasoning errors by constraining the solution path. Example: Vague prompt:3. XML Tags for Process Separation
Use<thinking></thinking> and <answer></answer> tags to separate reasoning from final output. This prevents the model from mixing its working process with the polished result, especially useful for complex multi-step problems. Learn more about XML tags here.
Quick Comparison
| Technique | Best For | Complexity |
|---|---|---|
| Zero-shot | General tasks, classification, translation | Simple |
| Few-shot | Tasks requiring specific format or nuanced output | Medium |
| Chain-of-thought | Complex reasoning, multi-step problems | Advanced |
Combining Techniques
You can combine these techniques for even better results:- Use few-shot examples with chain-of-thought instructions for complex reasoning tasks
- Apply chain-of-thought principles to zero-shot prompts when dealing with edge cases
- Structure few-shot examples using chain-of-thought frameworks for consistent reasoning