
Examples of Prompts 📝
Explore various real-world examples of how to use prompts for tasks like summarization, extraction, classification, and code generation.
This content is adapted from Prompting Guide: Examples of Prompts. It has been curated and organized for educational purposes on this portfolio. No copyright infringement is intended.
Learning through Examples
The best way to master prompt engineering is by exploring how different prompts lead to different model behaviors. This section provides concrete examples of common tasks and how to structure your prompts for them.
1. Text Summarization
LLMs are exceptionally good at distilling long paragraphs into concise summaries.
Prompt
Antibiotics are a type of medication used to treat bacterial infections... [Long Paragraph] ...
Explain the above in one sentence:Output
Antibiotics are medications used to treat bacterial infections by either killing the bacteria or stopping them from reproducing, but they are not effective against viruses and overuse can lead to antibiotic resistance.2. Information Extraction
You can use prompts to pull specific data points out of unstructured text.
Prompt
[Research Paper Paragraph] ... Mention the large language model based product mentioned in the paragraph above:Output
The large language model based product mentioned in the paragraph above is ChatGPT.3. Question Answering
By providing context and specific instructions, you can improve the factual accuracy of the model's responses.
Prompt
Answer the question based on the context below. Keep the answer short and concise. Respond "Unsure about answer" if not sure.
Context: [Technical details about Teplizumab]
Question: What was OKT3 originally sourced from?
Answer:Output
Mice.4. Text Classification
You can guide the model to use specific labels and formats by providing examples (few-shot prompting).
Prompt
Classify the text into neutral, negative or positive.
Text: I think the vacation is okay.
Sentiment: neutral
Text: I think the food was okay.
Sentiment:Output
neutral5. Conversation & Role Prompting
One of the most powerful techniques is telling the LLM how to behave by assigning it a role.
| Role | Instruction | Result |
|---|---|---|
| Technical | "You are an AI research assistant. Your tone is technical and scientific." | Responses will be precise, data-heavy, and formal. |
| Simple | "You are a teacher. Explain concepts as if to a primary school student." | Responses will use simple analogies and basic vocabulary. |
6. Code Generation
LLMs can generate everything from simple scripts to complex database queries.
MySQL Query Generation:
"""
Table departments, columns = [DepartmentId, DepartmentName]
Table students, columns = [DepartmentId, StudentId, StudentName]
Create a MySQL query for all students in the Computer Science Department
"""Output:
SELECT StudentId, StudentName
FROM students
WHERE DepartmentId IN (
SELECT DepartmentId
FROM departments
WHERE DepartmentName = 'Computer Science'
);Conclusion
As you've seen, LLMs can perform a vast range of tasks simply through clever instruction. In the next guide, we will dive into Prompting Techniques like Zero-Shot and Few-Shot prompting to further enhance these capabilities.