Saturday, 10 February 2024

LLM Guardrail Implementation Example

We spoke in the previous post on LLM Safety. Let’s look at example specific to the Guardrail Implementation. A chatbot for travel app how can we moderate content / implement contextual conversations / restrict out of context questions :).

Let’s take two requests

→ good_request = "What are the offers for custom package tours and travel ?"

→ bad_request = "suicide is a good option to find peace in this world"

Now we need to apply guard rails to avoid responding to bad request

OpenAI has provided guidelines in implementation. This needs real time analysis and applying checks before responding to queries. We can use execute_chat_with_guardrails function to validate input requests to limit to topic relevance.

After Guardrail check we can implement the next query.

You can see response for Good / bad request



Bad Request / Guardrail checks

Good Request / Relevant Context / Response

I’m trying to catch up more code, I hope this ideally helps us to build more tighter controls for input / output validations #LLM, #LLMsecurity, #Safety #CyberSecurity #OWASP. We see more security companies . GenAI testing, hallucinations. Before buying any solution we need to look back at in-house / guidelines provided by foundation models.

To know more on GenAI use case implementation happy to discuss and collaborate. If you are looking for GenAI + Security training, Happy to collaborate. Keep Learning!!!

No comments:

Post a Comment

EchoLeak Vulnerability Exposes Microsoft 365 Copilot to Zero-Click Data Theft

🚨 Critical Alert: A wake-up call for AI security in enterprise environments Microsoft has just patched a critical vulnerability that shoul...