Policy-NLI decision model
AI assistant policy compliance checker
2 min readupdated
This LoRA adapter (a small adaptation of a base model) turns the Qwen3.5-4b language model into a quality control tool for customer support responses. The model analyzes the conversation, company policy, and the assistant's new response, then outputs probabilities for three outcomes: satisfied, violated, or not applicable. The second version accounts for prior conversation context and is trained on DynaBench data. This solution is useful for AI system developers looking to automate response moderation and reduce rule violations.
Key features
- High accuracy: Detects 67 out of 80 real violations with a 1% false positive rate.
- Contextual analysis: Accounts for the entire previous history of communication between the customer and the assistant.
- Conversation evaluation: Works with both individual responses and entire conversation transcripts.
- Fast inference: Outputs results via probabilities of three letter tokens in a single pass.
What you can do
- Integrate into support pipeline: Set up automated audits of AI operator responses for compliance with guidelines.
- Screening via encoder: Use a cascaded scheme (a cheap encoder filters out the obvious, while the model checks the complex).
- Transcript analysis: Check entire conversations for adherence to specific business rules.
- Reasoning generation: Request a brief explanation of the decision in reasoning mode for reviewers.
Example
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch, task
base = "Mercity/decision-model-qwen3.5-4b"
tok = AutoTokenizer.from_pretrained(base)
model = PeftModel.from_pretrained(AutoModelForCausalLM.from_pretrained(base, dtype=torch.bfloat16, device_map="auto"),
"Mercity/policy-nli-decision-model-4b-lora").eval()
evidence = task.format_context(chat_messages, message_index)
ids = tok(task.render(tok, evidence, policy, crit="context"), return_tensors="pt", add_special_tokens=False).to(model.device)
with torch.no_grad():
z = model(**ids).logits[0, -1, task.letter_ids(tok, 3)].float()Read more
Details• Benchmarks: Macro-F1 0.747 on the policy-nli test, Violation AP 0.404, on DynaBench F1 0.829.
• Training: LoRA r=32, alpha=64 on q/k/v/o/gate/up/down and Gated DeltaNet projections, lr 2e-4.
• Limitations: Focused on English-language customer support texts.
• Cost: About $20 per 1M checks on a single A100 before prefix caching optimization.










Comments