Answer Only From the Text
Part of the Prompting Techniques section of Coddy's AI Prompts journey. Lesson 7 of 24.
Give the AI a text and ask a question the text does not answer, and a small model rarely says so. We gave the model in this course only a gym's opening hours (6 am to 10 pm on weekdays, 8 am to 8 pm on weekends) and asked Does the gym have a pool? It answered: Yes, Sunrise Gym does have a pool. Nothing in the text says that.
Tell it to stay inside the text, and give it an exact way out:
Answer only from the text in <info> tags. If the answer is not in the text, reply only NOT_FOUND.
<info>Sunrise Gym is open 6 am to 10 pm on weekdays and 8 am to 8 pm on weekends.</info>
Question: Does the gym have a pool?NOT_FOUND
Ask When does the gym open on Saturday? with the same prompt and it answers from the text: The gym opens on Saturday from 8 am to 8 pm. The fixed word NOT_FOUND matters: an app can spot it and show we don't know instead of a made-up answer.
Challenge
EasyA bike rental shop gave you this notice:
Bike rental: open 9 am to 6 pm every day. Helmets are free. Bikes must be back by 6 pm.
A customer asks: Can I rent an electric bike? The notice does not say. Get the AI to admit that instead of guessing.
The AI's response must:
- Be only the word
NOT_FOUND
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Prompting Techniques
2Structure Your Prompt
Wrap Text in DelimitersAnswer Only From the TextThe Prompt RecipeLet the AI Ask FirstRecap: Structure Your Prompt