AI Hints
Home›LangChain Tutorial›Project Review and Good Habits
LangChain · Lesson 108 of 120

Prompt Habits

What works.

⏱ 2 min read▶ Video at 2:03:07🎓 Free
Watch this lesson in the LangChain courseWatch on YouTube ↗Full LangChain course

After building many chains and agents, a few prompt habits stand out. They're simple, and they make a big difference to quality.

Prompt Habits
From the video: Prompt Habits
  • A few habits
  • Simple
  • Big difference

Habits that work

Be specific about the task, and the format of the answer. Give the model a role. Show an example or two of good answers. Put untrusted text in clear tags. And tell the model what to do when it doesn't know.

keyvalue
Specifictask and format
Rolewho it is
Examplesone or two
Tagsaround untrusted text
Fallbackwhen it doesn't know

Vague vs specific

Compare these two prompts. The vague one says, help the customer. The specific one says who the bot is, what it may use, the length of the answer, and what to do when the answer is missing. The specific prompt gives far more consistent answers.

Vague

  • Help the customer.No roleNo formatNo fallback

Specific

  • Riverside Books assistantUse only the policiesOne or two sentencesElse offer a human

Summary

Be specific, give a role and examples, mark untrusted text, and plan for unknowns. Then measure with a test set. Next, a new section, starting with images as input.

Key takeaways
  • Be specific
  • Examples and tags
  • Measure it
Next up: Multimodal Input — images too