Beginner1h42m

Safe and reliable AI via guardrails

Instructor: Shreya Rajpal

GuardrailsAI logo

Earn an accomplishment with PRO · Updated Oct 7, 2025

  • Beginner
  • 1h42m
  • 10 Video Lessons
  • 7 Code Examples
  • 1 Graded Assignment PRO
  • Earn an accomplishment with PRO
  • Updated Oct 7, 2025
  • Instructor: Shreya Rajpal
  • GuardrailsAIGuardrailsAI
  • Learn more aboutMembership PRO Plan

What you'll learn

  • Learn the common failure modes of LLM-powered applications that guardrails can help mitigate, including hallucinations and revealing sensitive information.

  • Understand how AI guardrails validate and verify your applications with input and output guards, ensuring reliable and controlled interactions.

  • Add guardrails to a RAG-powered customer service chatbot to create a new layer of control of the applications behavior.

Course recap

PRO

This course teaches how to build guardrails for LLM applications to prevent hallucinations, enforce output structure, and ensure safety. It uses the Guardrails AI framework to create validators that wrap around LLM calls, with a focus on a pizza shop chatbot RAG application as the running example.

Concept map

Concepts in Safe and reliable AI via guardrails and the courses that connect to themSafe and Reliable AI via GuardrailsSafe and Reliable AI via…GuardrailsNatural Language Inference (NLI)Natural Language Inferenc…Hallucination detectionValidatorsGuardsRetrieval-Augmented GenerationRetrieval-Augmented Gener…Pydantic for LLM WorkflowsRetrieval Augmented GenerationRetrieval Augmented Gener…Practical Multi AI Agents and Advanced Use Cases with CrewAIPractical Multi AI Agents…Advanced Retrieval for AIAgent Memory: Building Memory-Aware AgentsAgent Memory: Building Me…Concepts in Safe and reliable AI via guardrails and the courses that connect to themSafe and Reliable AI via GuardrailsSafe and Reliab…GuardrailsNatural Language Inference (NLI)Natural Languag…Hallucination detectionHallucination d…ValidatorsGuardsRetrieval-Augmented GenerationRetrieval-Augme…

Key concepts

  • GuardrailsValidation layers that intercept LLM inputs/outputs to enforce constraints (banned words, format, groundedness)
  • Natural Language Inference (NLI)Classifier that determines if a hypothesis is entailed by, contradicts, or is neutral to a premise
  • Hallucination detectionUsing NLI to verify each sentence of LLM output is entailed by retrieved source documents
  • ValidatorsCustom classes with validate methods that return pass/fail results; composable into Guards
  • GuardsWrappers around LLM calls that run validators on inputs/outputs and can trigger retries on failure
  • Retrieval-Augmented GenerationPizza shop chatbot RAG system used as the application context

Lesson highlights

  1. 1.Introduction — Overview of guardrails need; pizza shop chatbot example showing hallucination
  2. 2.Guardrails Basics — Building simple validators (banned words); Guard class wrapping LLM calls
  3. 3.Checking for Hallucinations with NLI — NLI model setup; sentence splitting; source retrieval; entailment checking
  4. 4.Hallucination Guard Integration — Wrapping NLI validator in a Guard for the chatbot
  5. 5.Output Structure Validation — Enforcing JSON schema and format constraints
  6. 6.Input Validation — Checking user inputs before sending to LLM
  7. 7.Custom Validators — Building domain-specific validators
  8. 8.Composing Guardrails — Combining multiple validators into a pipeline
  9. 9.Production Considerations — Performance, latency, and reliability tradeoffs
  10. 10.Conclusion

About this course

Join our new short course, Safe and Reliable AI via Guardrails, and learn how to build production-ready applications with Shreya Rajpal, co-founder & CEO of GuardrailsAI.

The output of LLMs is fundamentally probabilistic, making it impossible to know in advance, or to guarantee the same response twice. This makes it difficult to put LLM-powered applications into production for industries with strict regulations or clients who require high consistency in application behavior.

Fortunately, installing guardrails on your system gives you an additional layer of control in creating safe and reliable applications. Guardrails are safety mechanisms and validation tools built into AI applications, acting as a protective framework that prevents your application from revealing incorrect, irrelevant, or sensitive information.

This course will show you how to build robust guardrails from scratch that mitigate common failure modes of LLM-powered applications like hallucinations or revealing personally identifiable information (PII). You’ll also learn how to access a variety of pre-built guardrails on the GuardrailsAI hub and are ready to integrate into your projects.

You’ll implement these guardrails in the context of a RAG-powered customer service chatbot for a small pizzeria.

In detail, you’ll:

  • Explore the common failure modes of LLM-powered applications including hallucinations, going off-topic, revealing sensitive information, and generating responses that can harm your reputation.
  • Learn to mitigate these failure modes with input and output guards that validate and verify your application’s responses.
  • Create a guardrail to prevent the chatbot from discussing sensitive topics, such as a confidential project at the pizza shop.
  • Develop a guardrail to detect hallucinations using a Natural Language Inference (NLI) model, ensuring responses are grounded in the truth of your trusted documents.
  • Add a Personal Identifiable Information (PII) guardrail to detect and redact sensitive information in user prompts and LLM outputs using tools from the Guardrails hub.
  • Set up a guardrail to limit the chatbot’s responses to topics relevant to the pizza shop, keeping interactions focused and appropriate.
  • Configure a guardrail that prevents your chatbot from mentioning any competitors using a name detection pipeline consisting of conditional logic that routes to an exact match or a threshold check with a named entity recognition.

The tools in this course will unlock more opportunities for you to build and deploy safe, reliable LLM-powered applications ready for real-world use.

Who should join?

Anyone who has basic Python knowledge looking to enhance the safety and reliability of LLM-powered applications with practical, hands-on guardrail techniques.

Course Outline

10 Lessons・7 Code Examples
Unlock certificates

Elevate your learning experience with Pro

Upgrade to Pro and gain unlimited accomplishments on your resume

Learn More

Instructor

Shreya Rajpal

Shreya Rajpal

Course access is free for a limited time during the DeepLearning.AI learning platform beta!

Want to learn more about Generative AI?

Keep learning with updates on curated AI news, courses, and events, as well as Andrew’s thoughts from DeepLearning.AI!