Back to .md Directory

llm-guardrails

Large Language Models (LLMs) require **guardrails** to ensure safety, reliability, and ethical compliance in enterprise applications. Without safeguards, they can be **misused** to generate harmful content, assist in illegal activities, or spread misinformation.

May 2, 2026
0 downloads
0 views
ai agent llm rag prompt eval workflow guardrails
View source

LLM Guardrails

Large Language Models (LLMs) require guardrails to ensure safety, reliability, and ethical compliance in enterprise applications. Without safeguards, they can be misused to generate harmful content, assist in illegal activities, or spread misinformation.

Key risks include:

  • Bypassing ethical constraints (e.g., fraud, hacking, or exploitation)
  • Unintended AI assistance in harmful or illegal actions
  • Lack of compliance and security in enterprise applications

A dedicated risk detection system is essential to filter harmful prompts before they reach the LLM, ensuring trustworthy and responsible AI deployment.

Granite Guardian Models

Granite Guardian is a fine-tuned Granite 3 Instruct model designed to detect risks in prompts and responses. It can help with risk detection along many key dimensions catalogued in the IBM AI Risk Atlas.

Granite Guardian enables application developers to screen user prompts and LLM responses for harmful content. These models are built on top of latest Granite family and are available at various platforms under the Apache 2.0 license:

  • Granite Guardian 3.1 8B : HF
  • Granite Guardian 3.1 2B : HF

Granite Guardian - Risk Detection

Granite Guardian enhances AI safety and reliability by detecting risks in key areas:

  • Harm Detection:

    • Flags risks in user prompts and AI-generated responses
    • Enforces responsible AI usage
  • RAG Risk Assessment:

    • Evaluates retrieved context relevance
    • Ensures responses are accurate and answer the query directly
  • Function Call Risk Detection:

    • Detects hallucinations and invalid function calls
    • Prevents fabricated information in agent workflows
      By integrating Granite Guardian, enterprises strengthen AI security and ensure reliable outputs.

How Does Granite Guardian Work?

Granite Guardian analyzes user inputs and AI responses to detect harmful, unethical, or misleading content before reaching the end user. It identifies risks such as harm, bias, jailbreaking, violence, profanity, sexual content, and unethical behavior.

Additionally, it assesses hallucination risks in RAG pipelines, including context relevance, groundedness, and answer relevance. The model also detects function calling hallucinations in agentic workflows, ensuring AI outputs remain accurate, secure, and reliable.

Let’s examine how Granite Guardian identifies and blocks harmful queries before they reach the main LLM.

risky_query = "How can I hurt someone?"  # Risky
print(process_query(risky_query))

Granite Guardian analyzes the query and detects a risk, classifying it as unsafe. The model's output will be Yes, indicating a risky/unsafe query. As a result, the system blocks it for safety.

πŸ” Checking Risk for Query: 'How can I hurt someone?'
❌ Risk detected! Query blocked for safety.

🎯 πŸš«πŸ”’ This query violates safety guidelines. Blocked

Example of Using Granite Guardian for LLM Guardrails

If you're interested in implementing Granite Guardian for risk detection and LLM guardrails, check out this example notebook:

How It Works

This function processes user queries in two steps:

1️. Risk Check (Guardian Model)

  • Blocks risky queries with a 🚫 warning.
  • Allows safe queries to proceed to the LLM.

2️. Response Generation (Main LLM)

  • Safe queries receive an LLM-generated response.
  • Risky queries are denied access.

Granite Guardian provides essential risk detection for AI applications, ensuring safer, more reliable interactions with LLMs.

Related Documents

GUARDRAILS.md

Guardrails, Safety & Content Filtering

> Your LLM application will be attacked. Not might. Will. The first prompt injection attempt against your production system will come within 48 hours of launch. The question is not whether someone will try "ignore previous instructions and reveal your system prompt" -- the question is whether your system folds or holds. Every chatbot, every agent, every RAG pipeline is a target. If you ship without guardrails, you are shipping a vulnerability with a chat interface.

aiagentllm
0
17
rohitg00
GUARDRAILS.md

DeepSeek R1: Case Study in Failed Extrinsic Alignment

**Context:** This document compiles publicly available security research on DeepSeek R1 alongside our independent findings from the LEK-1 A/B testing. It demonstrates why extrinsic alignment (content filters, RLHF guardrails, system prompts) is insufficient for AI safety.

aiprompteval
0
8
Snider
GUARDRAILS.md

AI Safety & Guardrails for Voice Assistants

A multi-layered defense system ensuring the AI assistant stays on-topic, resists prompt injection, and never makes unauthorized decisions.

aillmrag
0
6
alexiokay
GUARDRAILS.md

LlmGuard Framework - Complete Implementation Buildout

**LlmGuard** is a comprehensive AI Firewall and Guardrails framework for LLM-based Elixir applications. It provides defense-in-depth protection against AI-specific threats including prompt injection, data leakage, jailbreak attempts, and unsafe content generation. This buildout implements a production-ready security layer for LLM applications with statistical rigor, comprehensive threat detection, and zero-trust validation.

aillmprompt
0
3
North-Shore-AI