Lion Cipher Lab
Build a local chatbot and wrap it in safety guardrails
- AI Security
- Intermediate
- ~60 min
- Free · no account required
Why it matters
Reading about guardrails and building one are different kinds of understanding, and only the second one sticks. This lab gives you the smallest real thing worth protecting — a chatbot: a program that holds a back-and-forth conversation by sending your messages to a language model and showing you its replies — running entirely on your own machine with Ollama, so there is no bill, no API key, and no data leaving your computer. Then you wrap it in layers, one at a time, and watch each one change the app's behavior. First a system prompt (the model's standing instructions, set by you rather than…
What you'll learn
- running a large language model locally with Ollama
- writing a minimal chat loop against a local model in Python
- using a system prompt to set a chatbot's role and refusal policy
- writing an input guard to block obvious prompt injection and off-scope requests
- writing an output guard to catch PII and secret leakage before it is shown
- adding logging and a human-escalation path to an AI app
- testing an app with benign and adversarial input
- reasoning about defense in depth, least privilege, and human oversight for AI systems
Steps in this lab
- What you're building, in one breath
- Install Ollama and pull a small model
- The minimal chat loop (no guardrails yet)
- Layer 1 — a system prompt that sets role and refusal policy
- Layer 2 — an input guard against injection and off-scope requests
- Layer 3 — an output guard for leaks and refusal patterns
- Layer 4 — logging and a human-escalation path
- Test it — benign first, then adversarial
- Layers reduce risk — they are not a guarantee