Guardrails: System Prompt, İçerik Filtreleri, Allow/Deny Listeleri
Pratik guardrail kütüphaneleri (Guardrails AI, NeMo, Llama Guard). Allow/deny listeleri, content moderation API'leri.
Şükrü Yusuf KAYA
10 min read
AdvancedGuardrails: Pratik Araçlar
Açık kaynak, deklaratif:
from guardrails import Guard from guardrails.hub import ( DetectPII, ToxicLanguage, CompetitorCheck ) guard = Guard().use_many( DetectPII(pii_entities=["EMAIL", "PHONE"]), ToxicLanguage(threshold=0.8), CompetitorCheck(competitors=["X", "Y"]), ) result = guard(llm_call, prompt=user_input) if result.validation_passed: print(result.validated_output)
Allow/Deny List Pattern#
python
# Domain-spesifik whitelistALLOWED_TOPICS = ["product info", "order status", "refund policy"]DENIED_TOPICS = ["legal advice", "medical advice", "competitor comparison"] # LLM-judge ile sınıflandırdef is_topic_allowed(query: str) -> bool: judge_prompt = f"""Kullanıcı sorgusunu sınıflandır:ALLOWED: {ALLOWED_TOPICS}DENIED: {DENIED_TOPICS} Query: "{query}"Tek kelime: ALLOWED veya DENIED.""" return judge_call(judge_prompt) == "ALLOWED"Allow/deny list
Layered approach: Vendor moderation (cheap) → Custom guardrails (specific) → LLM judge (nuanced) → Audit log (post-hoc). Hiçbiri %100 değil ama 4'ü birlikte %99.9.
Yorumlar & Soru-Cevap
(0)Yorum yazmak için giriş yap.
Yorumlar yükleniyor...
Related Content
1. Temeller — Yapay Zekâ ve LLM'lere Giriş
Bu Eğitim Hakkında ve Verimli Çalışma Yöntemi
Start Learning1. Temeller — Yapay Zekâ ve LLM'lere Giriş
Yapay Zekâ → Üretken AI → LLM: Bağlamsal Harita
Start Learning1. Temeller — Yapay Zekâ ve LLM'lere Giriş