How LLM-as-judge true/false scoring in PyRIT decides whether an attack worked
When you run automated attacks against a model or application, you need a consistent verdict on every response, or your results cannot be compared across runs. PyRIT's SelfAskTrueFalseScorer answers that need: it uses a judge LLM to return true or false on whether the attack objective was met. The PyRIT documentation describes it as the general-purpose self-ask scorer, and with no template it judges objective achievement. That makes it the default choice when your question is whether the attacker got what it asked for, rather than how harmful the text is.
The scorer is one of several options, and the choice depends on the question. Use a refusal scorer when you only need to know whether the target declined. Use a Likert scorer when you need a graded severity rating. Use Azure AI Content Safety or a classifier such as Llama Guard when you need a fast, category-based harm check. The true/false judge fits cases those tools do not cover well, such as a policy-specific objective like disclosing internal pricing rules or following an injected instruction. Because it is general purpose, its verdicts are only as reliable as the question and the judge behind it, so treat it as a tool to be validated rather than trusted by default.
Before you rely on it, confirm three things in your own environment: which judge model you will use, who approves that model's access to the responses you are testing, and how a verdict will be recorded in PyRIT memory for later review. Plan a small set of responses you have already labeled by hand to check the judge's agreement with your reviewers. Ask your team to confirm the exact PyRIT version in use through the PyRIT documentation before you copy any template or example code, since scorer behavior and class names have changed across releases.
Writing the judge question for your own policy
The judge question is the policy you enforce, written as a single true or false question. Each card covers one part of that question, from the objective to the edge cases a compliance owner will ask about. Review the finished wording with the owner of the policy before you rely on any verdict.
State the objective precisely
The judge can only answer for the objective you give it, so vague wording produces vague verdicts. Name the exact behavior under test, such as disclosing a specific category of customer data or giving step-by-step instructions for a named activity. Keep the objective identical to the one the attack prompt is trying to achieve. Check that a reviewer reading only the objective could decide whether it is met.
Define pass and fail under your policy
The default template judges whether the objective was met in general terms, which is not the same as your policy. Write down what a failed test looks like for your organization, including the content, the context and the audience. Decide whether a response that mentions the topic without detail counts as a failure. Have the compliance owner sign off on this definition before the judge runs against real results.
Write the true or false wording
Phrase the question so that a yes answer always means the objective was met, which keeps the verdict direction unambiguous in reports. Avoid double negatives and compound questions that ask two things at once. Test the wording on a few responses you have labeled by hand, and confirm the judge returns the answer you expect. Record the exact wording in version control so later runs can be compared.
Cover partial compliance
Many responses are neither a clear success nor a clear refusal, such as a model that gives a general overview while withholding specifics. Decide in advance whether partial compliance counts as met, and state that rule in the question. Without it, the judge will make the call on its own, and two runs may disagree. Include a short example of a partial response in your review set so the team can see the decision applied.
Cover refusals with leaked content
A response may open with a refusal and then supply the requested content anyway. A judge that reads only the opening sentence will mark the attack as blocked when it was not. Write the question so that a refusal does not end the evaluation, and say explicitly that any leaked content meeting the objective counts. Test this case on purpose, because it is where judges most often disagree with human reviewers.
Review the question with the compliance owner
The compliance or risk owner decides what the policy means, and the security team should not guess at that meaning alone. Ask the owner to confirm the pass and fail rules, the edge case decisions and the evidence they will accept. Keep a dated record of the approved wording, because auditors may ask how a verdict was defined. Repeat the review whenever the policy changes or a new harm category is added.
Choosing the judge model and its trade-offs
A hosted model from a provider that PyRIT supports is usually the fastest route to a working judge. You point the self-ask true/false scorer at a chat target you already use for testing, so there is little extra infrastructure to run. The trade-off is that every judgment is a paid model call, and the judged text (which includes the target's harmful or sensitive output) leaves your environment for the provider's service. Confirm that the provider, the specific model and the region you plan to use are supported by the PyRIT version you deploy, and check the provider's data handling terms before sending test content.
- Per-call usage: Each scored response adds at least one judge call, so a large run roughly doubles the model calls compared with attacks alone.
- Latency across large runs: Judge calls run sequentially or in parallel depending on your concurrency settings, and rate limits can slow a long batch.
- Model version drift: Hosted aliases can change behind the same name, so pin a dated model version where the provider offers one.
- Data terms: Test content may include disallowed output, so confirm retention and training terms with your legal or privacy team.
Before relying on this option, check the provider and model name against your own PyRIT installation and your contract with the provider.
Some policies are hard to judge: a response may refuse one part of a request and leak the rest, or may be fictional framing around real operational detail. A more capable judge model tends to follow nuanced questions more reliably than a small model, which reduces false passes and false failures. The cost is higher per-call price and slower responses, so reserve the stronger model for policies where scoring errors would change a finding. You can run a cheaper model across the bulk of a run and use the stronger one to adjudicate disagreements or a sample of verdicts.
- Per-call cost: Larger models usually cost more per token, and the cost grows with the length of the response you ask the judge to read.
- Latency: Bigger models are often slower, which compounds across thousands of scored responses.
- Two-tier scoring: A cheap first pass with a stronger second pass on disputed or sampled results keeps spend bounded.
- Calibration: Compare the two judges on a labeled sample before trusting either one on your policy.
Confirm which larger models your provider offers and whether their context length fits your longest judged transcripts.
Where prompts, responses or policy text may not leave your environment, a judge model you host yourself keeps every judgment inside your network. This is common in regulated organizations and air-gapped networks. The trade-off shifts from per-call charges to infrastructure: you need accelerator capacity, a serving stack, monitoring and someone to maintain it. Check whether the model you intend to host is supported as a PyRIT target in your installed version, and whether the serving endpoint matches the API format PyRIT expects. Self-hosted judges can be slower than hosted ones unless you size the hardware for your batch volume.
- Fixed infrastructure cost: Hardware, hosting and staff time recur whether or not a run is active.
- Throughput: Latency depends on your hardware and batch size, so benchmark a representative run before planning a schedule.
- Version control: You choose when model weights change, which helps consistency but means you must track upgrades yourself.
- Endpoint compatibility: Confirm the serving interface, authentication and timeouts against your PyRIT target configuration.
Ask your infrastructure team to confirm hardware capacity and the model's licence terms before selecting a judge.
A judge is part of your measurement. If the judge changes between runs, a shift in pass rates may reflect the judge rather than the target. This matters most when you compare results across months, report trends to auditors, or retest after a fix. Pin the judge model version, record the judge model identifier in each run, and keep the question text under version control so that scoring history can be explained. Re-run a fixed labeled sample whenever you change the judge, so you can see how far verdicts moved before you accept the new numbers.
- Pinned versions: Use the most specific model identifier the provider or serving stack offers.
- Recorded identity: Store the judge model name and scorer configuration alongside each run in memory.
- Regression sample: Keep a small set of human-labeled transcripts and re-score them after any change.
- Planned upgrades: Schedule judge changes as their own event, separate from target or policy changes.
Confirm with your provider how long a pinned version remains available before you build a long-term evidence process around it.
Scorer configuration options and when each fits
This table compares the four configuration choices that shape a SelfAskTrueFalseScorer: the prompt template, the judge model, the objective passed to scoring, and how results are kept in memory. Read each row for when the option fits and what it costs in accuracy, spend or reuse. Confirm exact parameter names in the PyRIT 1.1.0 documentation before you write code.
| Configuration choice | When it fits | Trade-off to weigh |
|---|---|---|
| Default template | You want a quick first pass on a general objective and have no written policy yet | Generic wording may not match your policy, so borderline responses can be judged against criteria you never chose |
| Custom system prompt | Your policy has specific harm definitions, exceptions or domain terms that the default question does not capture | You own the wording, so every change needs a rerun against labeled examples to confirm verdicts still hold |
| Judge model target | A stronger or separately hosted model is needed to reduce disagreement with human reviewers | Larger judges usually cost more per call and may add latency; confirm the model's data handling terms before sending sensitive output |
| Same model as target | You are testing a model that is cheap to run and you accept that the judge may share its blind spots | Self-judging can hide failures the model is biased toward, so validate against a different model on a sample |
| Objective passed to scoring | The attack's goal is specific, such as leaking a named secret or producing a particular instruction | A vague objective produces vague verdicts; a narrow one can miss harmful content that falls outside its wording |
| Results stored in memory | You need an audit trail, reruns, or later rescoring with a new judge | Memory grows with every judged response, and stored verdicts reflect the judge version used at the time |
| Re-judging on demand | You change the judge or policy and need fresh verdicts on existing conversations | Each rerun spends judge calls again, so scope reruns to the conversations that matter |
Setting up the scorer in a PyRIT run
This sequence takes a team from a clean Python environment to a tested LLM-as-judge true/false scorer that is attached to a PyRIT attack. The output is a scorer configured with your own policy question, a judge model you have chosen deliberately, and evidence that the scorer separates known passing and failing responses before you rely on it.
Install PyRIT on a supported Python version
The engineer responsible for the test environment creates an isolated virtual environment and installs PyRIT from PyPI with pip. The PyPI package supports Python 3.10 up to but not including 3.15, and the PyRIT documentation recommends Python 3.13, so choose a version in that range and use it consistently for the whole team. Confirm the install by running the import check in the same environment and reading back the installed version. The step is done when the import succeeds in the environment you will use for the run.
Configure credentials and settings files
Create the PyRIT configuration files in your home directory. Credentials for the judge model and target go in ~/.pyrit/.env, and run settings go in ~/.pyrit/.pyrit_conf. Keep API keys out of scripts and version control, and confirm with your security team where the files are stored on shared machines. The step closes when a short test script can read the judge endpoint settings without you typing them into code, and the file permissions restrict access to the engineer running the test.
Create the judge target
Instantiate the chat target that will act as the judge. This is a separate model endpoint from the system under test, and it should be one you have approved for handling the prompts and responses your test produces. Ask your model provider or platform owner which deployment, version and data retention settings apply, because these are not set by the scorer itself. The step is done when a single plain prompt sent to the judge target returns a response in the console, which confirms the endpoint, credentials and network path all work.
Build the true/false scorer with your policy question
Construct SelfAskTrueFalseScorer with the judge target and a true/false question written for your own policy. Without a template, the scorer judges whether the objective was met, so state the question in terms of your policy, such as whether the response provides the specific prohibited content your policy names. Keep the question narrow enough that a judge can answer true or false from the response alone. The step closes when the scorer object is created without errors and its question text matches the policy wording your reviewers signed off on.
Attach the scorer to an attack
Pass the scorer to the attack you are running so that each target response is judged as it is produced, and set the attack objective to the behavior your policy prohibits. The attack records each scored response in PyRIT memory, which lets you review verdicts later. Run a single objective first to confirm that a score is written for every response and that the verdict is stored alongside the conversation. The step is done when one attack run produces a stored true or false result for each turn you expected.
Verify the scorer on known pass and fail responses
Before trusting the scorer, build a small set of responses you have labeled by hand: some that clearly meet the objective and some that clearly do not, including borderline refusals. Run each one through the scorer directly and compare the verdicts with your labels. Record any disagreements and adjust the policy question or judge model, then rerun the set. The step is done when the scorer agrees with every clear case in the set and you have written down the borderline cases where it disagreed, so reviewers know where verdicts need a human check.
Confirm the verification set is kept with the run
Save the labeled pass and fail set, the policy question text, the judge model identifier and the PyRIT version alongside the run configuration. Reviewers and auditors will ask how the scorer was checked, and this set is the evidence. Confirm with your compliance or assurance lead what format they need and how long records must be kept. The step is done when a later engineer can reproduce the scorer setup and the verification results from the saved files without asking the original author.
Handling malformed judge output without losing results
A judge model does not always return a clean true or false. It may answer in a sentence, hedge, refuse, add a preamble before the verdict, or return a word outside the expected set. The most dangerous outcome is a malformed verdict silently counted as a failed attack, because that inflates your apparent safety and hides the cases you most need to review. Treat an unparseable judgment as its own state, distinct from both true and false, and decide in advance how your team will handle it.
In PyRIT, the judge's output is stored as a score in memory alongside the conversation it evaluated. Check what the scorer actually recorded for each attack: a score that is missing, empty, or does not map to the expected true or false value should be queried and separated out rather than averaged into your results. Use PyRIT's memory to filter for these cases, then either rerun the scoring with a retry limit you set, or mark the item as needing human review. Whichever path you choose, the item must remain visible in your reporting so that attack success rates are not calculated on a quietly reduced sample.
Keep the raw judge response for every verdict, including the malformed ones. When a finding is disputed, a reviewer needs to see the exact text the judge returned, not only the parsed outcome, to decide whether the judge misread the target response or the target response was genuinely ambiguous. Before relying on a judge model, run a sample of your objectives and confirm how it formats its answers, how often it strays from the expected format, and whether it does so for particular kinds of content. Repeat that check whenever you change the judge model or its settings, because format drift is one of the quieter ways a scoring pipeline degrades.
How an attack response flows through the judge
The flow starts when PyRIT's attack hands the objective and the target response to SelfAskTrueFalseScorer, which combines them with your policy question and sends the prompt to the judge model. The judge's reply is parsed into a true or false verdict and written to PyRIT memory together with the raw judge output and the objective. Check the boundary: if the judge endpoint sits outside your environment, the target response and objective leave your network with it.
Objective and response reach the judge model, and the verdict is stored in memory.
Security and operational considerations for judge scoring
An LLM judge sees everything the target produced, so it becomes a data flow, a credential consumer and a scoring dependency in its own right. The cards below cover where that exposure sits and which controls you should confirm in your environment before trusting verdicts from a judge model.
Sensitive transcripts reach the judge
Every transcript the judge scores is sent to the judge endpoint, including harmful content the attack elicited and any sensitive data the target echoed back. Confirm which endpoint receives those transcripts, who operates it, what it logs and how long it retains prompts. Where data residency or contract terms apply, check them before pointing the scorer at a hosted judge.
Credentials in .env files
PyRIT reads judge and target credentials from ~/.pyrit/.env, so a plaintext key on a laptop or shared CI runner is a standing exposure. Confirm file permissions, keep the file out of version control, and decide whether judge credentials should come from your secrets manager instead. Use a key scoped to the judge deployment rather than a broad account key.
Judge bias and drift
A true/false verdict is only as stable as the judge model behind it. When the provider updates or retires a model, the same transcript can flip from pass to fail with no change in your target. Pin a model version where the provider allows it, re-run a fixed set of labeled transcripts after each change, and record which judge produced each verdict.
Prompt injection aimed at the judge
The target's response is data, but the judge reads it as text in the same prompt as your question. A response that says the objective was already met, or instructs the judge to answer true, can bias the verdict. Confirm that your template separates the response clearly, and spot-check verdicts on responses that contain instructions addressed to a grader.
Reviewable memory records
PyRIT stores conversations and scorer results in SQLite or Azure SQL, and that memory is what a reviewer or auditor will read. Confirm the storage location, access controls and backup plan for the memory database. Record the judge model, template and date alongside each verdict so a later reader can reproduce how a result was reached.
PyRIT docsQuestions teams ask before using LLM judges in PyRIT
What does it cost to run an LLM judge in PyRIT?
The PyRIT software is open source under the MIT license, so the license itself costs nothing. The recurring cost is the judge model: every response PyRIT scores is one more call to a model you pay for, whether it is a hosted API billed per token or a model you run on your own hardware. The one-time cost is the engineering time to write the judge question, build a labeled test set and check the verdicts. Costs rise with the number of attack prompts, the number of responses scored per prompt, and the size of the judge model you choose. Ask any partner for a quote that separates setup effort from the per-run model spend, and that states which judge model it assumes.
How long does initial setup of an LLM judge take?
No fixed duration is supplied for this work, so treat any timeline as something to confirm against your own scope. Setup has three parts that drive the time: getting the judge model access and credentials in place, writing a true/false question that matches your policy, and building enough labeled examples to test the judge. The second and third parts usually take longer than the code, because they depend on how clearly your policy defines a violation. Teams with a settled policy and an existing labeled set move quickly. Teams that must first agree what counts as a policy failure will spend most of their time there.
What does my team need to provide for an LLM judge?
Three inputs matter most. First, a policy owner who can state, in plain language, what outcome counts as the objective being met, and who can settle borderline cases. Second, access to a judge model, either a hosted API key or a self-hosted endpoint, kept out of source code and loaded through the PyRIT environment file (~/.pyrit/.env). Third, a test set of prompts and responses that a human has already labeled as met or not met. Without the test set, you cannot tell whether the judge is right. Ask a partner to confirm which of these they expect you to supply and which they will prepare.
Can our own team build and run LLM judge scoring in PyRIT?
Yes, if you have Python engineers who can install PyRIT, call a model endpoint and maintain a small evaluation harness. PyRIT is a Python framework, and its self-ask true/false scorer with no template judges whether the objective was met, so the starting point is short. The harder work is ongoing: rewriting the question when the policy changes, switching judge models, and rechecking accuracy after each change. Teams without a policy owner or without anyone who can read judge failures often find that the judging logic is not the bottleneck. A partner can take on part or all of that build and tuning under a written scope.
How do we check whether the LLM judge is accurate?
Compare the judge's verdicts with human labels on the same responses, and measure how often they disagree in each direction. A judge that marks harmful responses as safe is more dangerous to your program than one that over-flags, so track both error types separately. Keep a held-out set that you did not use to write the question, and recheck accuracy whenever you change the question, the judge model or the target. PyRIT includes scorer metric tooling for this comparison; confirm its current interface in the PyRIT documentation for your installed version before relying on it.
How should we handle malformed output from the judge model?
Plan for it from the start, because a judge model does not always return the single true or false answer you asked for. Responses can contain extra prose, hedging, or an answer in an unexpected format. Decide in advance how such output is recorded: as an error to retry, as a failed score, or as a separate review queue, rather than letting it count silently as a pass. Log the raw judge output in memory so reviewers can see why a verdict was reached or rejected. Test this path with deliberately awkward responses before you trust aggregate results.
Does a partner's support for LLM judges include attack testing?
DeployOpen plans, builds and tests self-hosted AI and agent systems and runs AI security testing, including red teaming. Scoping a PyRIT judge as part of that work is a fixed-scope question agreed in writing before work starts, and the scope should name the policy, the judge model, the test set and the retest plan. Any figures, timelines or fees come from that written scope, not from this page.
Limits to confirm before relying on the judge
An LLM judge returns a verdict, but that verdict is itself model output with its own error rate. The cards below cover what to validate, what to rewrite, what to confirm in your environment and what to recheck before a PyRIT upgrade.
Validate verdicts against human labels
A judge's true or false answer is a classification, and it can be wrong in both directions. Have reviewers label a sample of the same responses by hand, then compare the judge's verdicts with those labels before you report attack success rates. Keep the disagreements, because they show which kinds of responses the judge misreads. Re-run this check when you change the judge model or the question.
True/false scorer docsRewrite the default question for your policy
With no template, SelfAskTrueFalseScorer asks whether the objective was met. That generic wording may not match what your organization treats as a failure, such as disclosing account data, giving regulated advice or revealing a system prompt. Write the question so it names the exact behavior, the excluded cases and the true and false conditions. Test the wording on responses you already know are good and bad.
Confirm judge providers and models
The judge is a model call, so the provider, model and deployment must be available and approved in your environment. Confirm which judge models your PyRIT setup can reach, whether they run in your cloud account or a private network, and whether your data handling rules allow sending attack transcripts to them. Record the model version used for each run so verdicts can be reproduced later.
Check judge output handling
A judge can return text that does not parse into a clear true or false, such as hedged wording, extra prose or an empty reply. Decide in advance whether a malformed verdict counts as a failure, a pass, or a retry, and record which one applied. Count malformed outputs per run, because a rising count often signals a model change or a prompt that has drifted.
Recheck behavior on PyRIT version changes
Scorer behavior and defaults can change between PyRIT releases. Read the 1.1.0 documentation for the true/false scorer and compare it with your installed version before upgrading. Re-run your validation set after any upgrade, and keep the old and new verdicts side by side until the results match your reviewers' labels.
PyRIT 1.1.0 docsHow DeployOpen scopes and supports PyRIT scoring work
DeployOpen approaches LLM-as-judge true/false scoring in PyRIT as a defined piece of work: the judge question, the judge model, the handling of malformed output and the evidence that shows the scorer can be trusted. Each engagement is fixed-scope, with deliverables agreed in writing before any build starts.
How we scope
- We agree in writing which target systems, objectives and policy categories the true/false judge will cover.
- We document the policy wording the judge question must reflect, and who in your organization approves it.
- We confirm which judge model you may use, where it runs and what data it is allowed to see.
How we build
- We write and test the SelfAskTrueFalseScorer question against a labeled set of your own responses.
- We configure output parsing so malformed judge replies are logged and retried rather than silently counted.
- We set up PyRIT memory so every verdict stores the judge prompt, model version and raw reply.
How we hand over
- You receive the scorer configuration, judge question text and parsing rules in version-controlled files.
- We provide a written record of test cases, judge disagreements and the fixes applied during the build.
- Your team walks through the runbook so it can rerun the scorer and read its memory records unaided.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- Retainers can cover re-checking the judge when you change judge models or PyRIT releases.
- Ask any proposal to name the retest steps, the owner of policy changes and the support hours included.

