Refining Input Guardrails for Safer LLM Applications Through Chain-of-Thought Fine-Tuning

capital_one · Finance · 2025 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Enterprise LLM input moderation and conversational assistant safety

Capital One needed input guardrails that could detect malicious, jailbreak, and prompt-injection inputs before they reached LLM-powered conversational assistants, while keeping outputs parsable and false positives low enough for user-facing applications.

Constraints:

Architecture

Capital One implemented a proxy-defense input moderation guardrail using LLM-as-a-Judge classifiers. A user utterance goes first to a judge LLM prompted with policy definitions and chain-of-thought reasoning; the guardrail returns a safety verdict and explanation to the conversational agent. The team then fine-tuned medium-sized open-source Mistral/Llama judge models with LoRA using SFT, DPO, and KTO on accepted/rejected synthetic moderation responses, improving attack detection and parsability.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  A["User input"] --> B["Input moderation guardrail"]
  B --> C["Judge LLM"]
  C --> D["CoT prompt"]
  C --> E["Policy definitions"]
  C --> F["Fine-tuned LoRA adapters"]
  F --> G["Training dataset"]
  G --> H["Evaluation harness"]
  H --> C
  B --> I["Conversational agent"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
User input Potentially safe, malicious, jailbreak, or prompt-injection utterance. Input moderation guardrail
Input moderation guardrail Proxy-defense firewall that evaluates user utterances before the assistant sees them. User input, Judge LLM, Conversational agent
Judge LLM LLM-as-a-Judge classifier that reasons over policy definitions and emits verdicts. Input moderation guardrail, CoT prompt, Policy definitions, Fine-tuned LoRA adapters
CoT prompt Prompting pattern that asks for reasoning before the moderation verdict. Judge LLM
Policy definitions Definitions of malicious, jailbreak, prompt injection, and other policy-violation classes. Judge LLM
Fine-tuned LoRA adapters Parameter-efficient model updates from SFT/DPO/KTO training. Judge LLM, Training dataset
Training dataset Accepted and rejected moderation responses built from malicious benchmarks and synthetic safe data. Fine-tuned LoRA adapters, Evaluation harness
Evaluation harness Computes F1, recall/ADR, false-positive rate, and invalid response ratio. Training dataset, Judge LLM
Conversational agent Main assistant/brain that receives the guardrail verdict and decides the response. Input moderation guardrail

Data flow

A user input enters the input moderation guardrail before the main assistant. The judge LLM receives policy definitions and CoT instructions, generates a concise explanation, and then emits a safe/unsafe verdict in a parsable format. Training data is built from public malicious benchmarks and synthetically generated safe/ideal/rejected responses. SFT updates the model on desired outputs; DPO and KTO align it further using rejected responses or binary signals. The conversational agent receives the guardrail verdict and explanation before deciding how to respond.

3 supporting quotes
“an additional component acting as a firewall to filter out unsafe user utterances.”article, stated
“the input guardrail’s safety verdict accompanied by an explanation is passed to the conversational agent”article, stated
“CoT prompting involves instructing the LLM to first generate a logical and concise explanation of its thought process and leverage this information to arrive at a final verdict.”article, stated

Why this architecture

Capital One used proxy defense because the main assistant model may still be vulnerable even after alignment. LLM-as-a-Judge was chosen over simpler classifiers for its reasoning versatility, and CoT plus fine-tuning improved both detection accuracy and parsable moderation formatting under industry constraints.

3 supporting quotes
“these LLMs are still susceptible to sophisticated attacks, the landscape of which is constantly evolving.”article, stated
“Due to its versatility compared to the BERT-based classifiers, this study focused on the LLM-as-a-Judge approach.”article, stated
“the need for additional fine-tuning of the judge LLMs was further validated.”article, stated

Models used: Mistral 7B Instruct v2 · Mixtral 8x7B Instruct v1 · Llama2 13B Chat · Llama3 8B Instruct · LlamaGuard-2 · ProtectAI DeBERTaV3 · Meta PromptGuard

Scale

Alternatives considered (roads not taken)

Rely on the main assistant model's post-training alignment alone

Rejected because: Aligned assistant models remain susceptible to evolving sophisticated attacks, so Capital One added a proxy guardrail.

“ideally, the main conversation-driving LLM used in AI assistant applications are post-trained such that they would detect any adversarial attacks”article, stated
“However, in reality, these LLMs are still susceptible to sophisticated attacks”article, stated

BERT-based lightweight classifier backbone

Rejected because: The study focused on LLM-as-a-Judge because it was more versatile for policy-violation reasoning.

“Current implementations either leverage light-weight language models, such as bidirectional encoder representations from transformers (BERT)-based models”article, stated
“Due to its versatility compared to the BERT-based classifiers, this study focused on the LLM-as-a-Judge approach.”article, stated

CoT prompting without fine-tuning

Rejected because: CoT helped, but base-model F1 remained well below 80%, validating additional fine-tuning.

“the highest F1 scores achieved on the base LLMs were still well below 80%”article, stated
“the need for additional fine-tuning of the judge LLMs was further validated.”article, stated

Patterns

safety-policy-enforcement (security)

The proxy guardrail filters unsafe user utterances before the assistant LLM receives them.

“The primary job of these guardrail components is to prevent such harmful interactions from reaching the main conversation-driving LLM”article, stated

llm-as-judge (evaluation)

An LLM judge is instructed to identify policy violations and classify inputs as safe or unsafe.

“The latter approach is referred to as LLM-as-a-Judge, where an LLM is instructed to identify incidents of guardrail policy violations.”article, stated

prompt-chaining (prompting)

The judge first produces a concise reasoning explanation and then uses it to arrive at the final safety verdict.

“CoT prompting involves instructing the LLM to first generate a logical and concise explanation of its thought process and leverage this information to arrive at a final verdict.”article, stated

fine-tuning-adaptation (model-adaptation)

Capital One used SFT, DPO, KTO, and LoRA to adapt open-source judge models to adversarial-input detection.

“we explored three fine-tuning LLM techniques in conjunction with chain-of-thought (CoT) prompting: supervised fine-tuning (SFT), direct preference optimization (DPO) and Kahneman-Tversky optimization (KTO).”article, stated
“We used parameter-efficient low-rank adaptation (LoRA) for all these experiments, which offers reduced computational needs and faster training.”article, stated

structured-output-contract (interface)

One research question specifically targeted whether the judge could produce moderation responses in the requested parsable format.

“* Can we improve the ability of LLMs to frame their moderation responses in the requested, parsable format?”article, stated

synthetic-data-generation (data)

The team generated ideal and rejected moderation responses synthetically to support SFT, DPO, and KTO training.

“we first synthetically generated a set of ideal responses, which is the only data requirement for SFT.”article, stated
“we also synthetically generated various types of rejected or undesirable responses for each accepted answer.”article, stated

Tradeoffs

Guardrail architecture

Chose proxy-defense input guardrail over relying only on the assistant model's own refusal behavior.

Rationale: A separate firewall reduces the chance that harmful interactions reach the main assistant.

“an additional component acting as a firewall to filter out unsafe user utterances.”article, stated
“drastically lowering the chances of unwanted responses by ensuring the AI assistant ultimately interacts with safer inputs.”article, stated

Training method

Chose SFT first, with DPO/KTO as incremental alignment over RLHF-style reward-model fitting or alignment alone.

Rationale: SFT gave the largest lift; DPO/KTO added smaller gains and require fewer/preferential data structures than RLHF.

“SFT offering the most significant lifts in F1 score and attack detection ratio (ADR, equivalent to Recall)”article, stated
“Direct preference optimization (DPO) is an alignment technique, but different from RLHF in that it does not require fitting a reward model first”article, stated

Model adaptation footprint

Chose LoRA and small-data/few-epoch tuning over large expensive full-model training.

Rationale: The team wanted practical industry guardrails with reduced computation and minimal hyperparameter effort.

“We used parameter-efficient low-rank adaptation (LoRA) for all these experiments, which offers reduced computational needs and faster training.”article, stated
“* These improvements can be obtained with small training datasets and minimal hyperparameter tuning efforts.”article, stated

Gotchas (what bit them)

Main-model alignment is not a complete defense.

Root cause: Sophisticated adversarial attacks continue to evolve even when the primary assistant has been post-trained for safety.

Resolution: Capital One added a separate proxy-defense guardrail before the conversational agent.

“However, in reality, these LLMs are still susceptible to sophisticated attacks, the landscape of which is constantly evolving.”article, stated
“Therefore, we must also focus on another approach to mitigating risk, referred to as “proxy defense,” which implements an additional component acting as a firewall to filter out unsafe user utterances.”article, stated

Base open-source judges struggled with jailbreak and prompt-injection detection.

Root cause: Open-source LLMs had a performance gap on dynamic jailbreak and prompt-injection vulnerabilities even with many-shot examples.

Resolution: The team fine-tuned and aligned judge models with CoT moderation responses.

“Our prior experiments with different publicly available LLMs have confirmed the gap in their performance when it comes to jailbreaks and prompt injections”article, stated
“We achieved significant improvements across all LLMs through fine-tuning and further alignment across the various types of adversarial prompts, with the largest gains on standalone jailbreak prompts.”article, stated

Better attack detection can raise false positives.

Root cause: Fine-tuning improved F1/ADR but FPR rose marginally across most models and strategies.

Resolution: Capital One judged the FPR increase acceptable because it was small relative to attack-detection gains and did not create concerning customer impact.

“We do observe an overall increase in FPR across almost all LLMs and tuning strategies. However, these are relatively marginal compared to the improvements achieved in F1 and ADR (increase of 50+% for F1 and ADR, compared to a maximum hike of 1.5% in FPR).”article, stated
“Nevertheless, a concerningly high FPR can adversely affect customer satisfaction, which is not the case here. These results fulfill our first research question.”article, stated

Evaluation

Capital One evaluated four base and fine-tuned LLMs on malicious/safe datasets using F1, recall/ADR, false positive rate, and invalid response ratio, then compared the best Llama3-DPO model against public guardrails such as LlamaGuard-2, PromptGuard, and ProtectAI DeBERTaV3.

Metrics: F1 score · Recall / attack detection ratio (ADR) · False positive rate (FPR) · Invalid response ratio · 50+% increase in F1 and ADR · Maximum FPR hike of 1.5%

3 supporting quotes
“The F1 score, recall, and false positive rate (FPR) values are used to gauge the classification power of each LLM”article, stated
“the invalid response ratio, which is the percentage of non-parsable LLM responses”article, stated
“Llama3-DPO achieves significant improvements against LlamaGuard-2 across all metrics.”article, stated

Outcomes

The case is a research-to-practice guardrail study using small datasets and four medium-sized open-source models, not a disclosed production traffic rollout.

3 supporting quotes
“all LLMs achieved strong performance gains across all evaluation metrics after fine-tuning and alignment”article, stated
“the Invalid Response Ratio values in all base and fine-tuned LLMs categorically dropped with all tuning strategies.”article, stated
“* Overall, this is a major step towards creating and deploying enterprise grade input moderation guardrails.”article, stated