# डिज़ाइन से Safety: परतें — AI Safety, Evaluation और Cost Control

Source: https://www.geekswithgeeks.com/hi/ai-safety/found-layers

> Input जाँच, सावधान prompts, grounded डेटा, सीमित tools, output जाँच और इंसानी निगरानी को जोड़ें।

## कोई एक filter काफ़ी नहीं

हर safeguard में कमियाँ हैं, इसलिए उन्हें परतों में रखें। Model से **पहले**: input जाँचें, दुरुपयोग पहचानें, व्यक्तिगत डेटा हटाएँ या छिपाएँ। Model call **में**: स्पष्ट निर्देश, retrieved प्रमाण, और काम के लिए ज़रूरी tools ही। Model के **बाद**: दिखाने से पहले output जाँचें (moderation, format, grounding)। उसके **आसपास**: rate limits, logging, उच्च-जोखिम कर्मों के लिए इंसानी review, और users के लिए समस्या बताने का तरीक़ा।

## सुरक्षित अनुरोध pipeline

हर step अनुरोध को अस्वीकार या नया आकार दे सकता है। Function नाम आपके अपने कोड के प्रतीक हैं।

```python
def handle(user_msg, user):
    if not rate_limiter.allow(user):          return refuse("Too many requests")
    msg = scrub_pii(user_msg)                 # mask personal data
    if moderation(msg).flagged:               return refuse("Cannot help with that")
    context = retrieve_documents(msg)         # ground the answer
    draft = call_model(msg, context, tools=SAFE_TOOLS)
    if not grounded(draft, context):          return fallback("I could not find that in our documents.")
    if moderation(draft).flagged:             return refuse("Cannot share that")
    log(user, msg, draft)
    return draft
```

## चुपचाप नहीं, सुरक्षित रूप से विफल हों

जाँच विफल हो तो बिना जाँचा draft या ख़ाली error देने की जगह मददगार सुरक्षित उत्तर ("मैं इसकी पुष्टि नहीं कर सका") दें। Users उन systems पर भरोसा करते हैं जो अपनी सीमाएँ मानते हैं।

**Quiz:** एक पर निर्भर रहने की जगह कई safeguards क्यों रखें?

- [ ] यह testing की ज़रूरत हटाता है
- [ ] एक safeguard अवैध है
- [ ] परतें model को तेज़ बनाती हैं
- [x] हर एक में कमियाँ हैं, इसलिए परतें वह पकड़ती हैं जो बाक़ी चूकती हैं

*Answer:* हर एक में कमियाँ हैं, इसलिए परतें वह पकड़ती हैं जो बाक़ी चूकती हैं. स्वतंत्र परतें इसकी संभावना घटाती हैं कि एक चूक नुक़सान बन जाए।
