Combining scorers in PyRIT: composite, inverted, threshold and conversation scorers

PyRIT's composite, inverter, threshold and conversation scorers let you build pass or fail logic that matches your own policy from small scorers. This page covers how to design, configure and verify them.

On this page

Why combine PyRIT scorers instead of trusting one verdict

A team often starts with one PyRIT scorer, runs an attack, and reads a single verdict as proof that the model did or did not break policy. The trouble appears when that verdict does not match the policy the team actually has. A scorer built to detect a harm category may flag responses the policy allows, or miss a failure the policy forbids because it sits outside the scorer's question. PyRIT lets you build the verdict from smaller scorers instead of trusting one of them. You combine true/false scorers with TrueFalseCompositeScorer, negate one with TrueFalseInverterScorer, and convert a float-scale scorer into a true/false result with FloatScaleThresholdScorer.

Teams need this when their policy has several conditions that must hold together, such as a response that is harmful and not refused, or when a rule is phrased as the absence of something, such as a response that should not contain a disclosure. It also matters when one scorer rates harm on a continuous scale and the policy requires a fixed cut-off. Before you build any composite, confirm which conditions your policy names, which scorer answers each one, and whether a single verdict would hide a failure your reviewers care about. Write that mapping down first, because the composite logic is only as sound as the policy it encodes.

This section is part of the PyRIT scoring group, which covers the individual scorers these combinations draw on, from LLM judges and Likert scales to refusal detection and content safety services. Read those sibling topics first if you have not yet chosen the scorers you will combine. The rest of this topic shows how the combinations are built, how to score a whole conversation when the signal only appears across turns, and how to check that the result behaves as your policy intends.

How small scorers combine into one policy verdict

The diagram starts with individual scorers on the left: an LLM judge, a refusal check, or a Content Safety or Likert score passed through a threshold. Each produces a true or false result, or a float that a threshold turns into one. A composite AND or OR node merges those results, and an inverter can negate one of them before the merge. The final pass or fail verdict then drives the attack's next decision. The conversation scorer path is drawn separately, because it renders the whole transcript as text before judging a signal that only appears across turns.

Individual scorers merge through composites, while conversation scoring runs on a separate path.

Which combining scorer fits which policy rule

This table compares the four combining tools in PyRIT's scoring layer, showing the question each one answers and the main trade-off to weigh before wiring it into a policy. It is drawn from the PyRIT Combining and Stacking Scorers documentation, so read each row as the job the scorer does rather than a judgment of how well it performs on your data.

ScorerQuestion it answersHow it combines resultsMain trade-off
TrueFalseCompositeScorer (AND)Did every required condition hold at once?Returns true only when all underlying true/false scorers agreeStrict, so one noisy judge can hide real failures and lower your measured success rate
TrueFalseCompositeScorer (OR)Did at least one harm signal fire?Returns true when any underlying true/false scorer returns trueBroad, so one false positive from any judge flags the response and needs review
TrueFalseInverterScorerDoes the response fail to show the behaviour?Negates a single true/false scorer's resultEasy to misread, so confirm in test cases that true means the intended outcome
FloatScaleThresholdScorerDid a graded score cross the line my policy sets?Converts a float-scale score into true or false at a chosen thresholdThe threshold is a policy decision, so pick it from labeled examples and document it
create_conversation_scorer()Did the conversation as a whole drift, escalate or persuade?Renders the full conversation as text for a single scorer to judgeCatches cross-turn patterns but scores longer context, which can raise judge cost and confuse per-turn evidence
Illustrative: AND plus thresholdDid a Likert harm score exceed the bar and a second check agree?Threshold on a float scorer, then composite AND with another checkTwo layers of judgment, so measure each layer's accuracy before trusting the combined verdict

How to build a composite scorer in PyRIT step by step

This sequence takes a team from a clean PyRIT install to a composite scorer that returns verdicts matching a policy on a small labeled set. Each step ends with a check so problems surface before the scorer is trusted.

  1. Install PyRIT on a supported Python version

    The engineer responsible for the test environment creates a virtual environment and installs PyRIT from PyPI. The PyPI package supports Python 3.10 up to but not including 3.15, and the PyRIT documentation recommends Python 3.13, so pin the interpreter to one of those versions. Confirm the installed version against the PyRIT release notes before you start, because scorer interfaces change between releases. Check that the package imports cleanly in a Python shell and that the version reported matches what your team has agreed to test against.

  2. Configure credentials for the underlying scorers

    The engineer who owns the judge model or safety service creates the credentials PyRIT needs and places them in ~/.pyrit/.env, with settings in ~/.pyrit/.pyrit_conf. Each component scorer, such as an LLM judge or Azure AI Content Safety, needs its own endpoint and key, and the composite is only as reachable as its least available component. Confirm with your platform or security team which endpoints and secrets are approved for this environment. Check by instantiating each component scorer alone and scoring one known harmful and one known benign response.

  3. Build the true/false components and the composite

    The engineer creates each true/false scorer that represents one part of your policy, then passes them to TrueFalseCompositeScorer to aggregate them. Decide before coding whether a flagged response should require all components to agree (AND) or any one of them (OR), since that choice sets how strict the policy is. Record the aggregation rule in your test plan next to each component's question. Check that the composite returns a single true/false score on one sample response and that the component results are retained in memory for review.

  4. Invert and threshold components where the policy needs it

    Where a component measures the opposite of what the policy needs, wrap it in TrueFalseInverterScorer so a true result means the desired behavior. Where a component returns a float score on a scale, such as a Likert rating, wrap it in FloatScaleThresholdScorer and set the cut-off that your policy defines. Write the threshold value in your policy document with its rationale, because the scorer will not choose it for you. Check each wrapped scorer on two responses you have already judged by hand, one on each side of the threshold, and confirm the output flips as expected.

  5. Add a conversation scorer for signals across turns

    Where the risk only appears over several turns, such as gradual persuasion or escalation, the engineer uses create_conversation_scorer() to render the whole conversation as text before scoring it. Use this only for behaviors that single responses cannot show, because scoring full transcripts adds judge calls and makes verdicts harder to trace to a specific turn. Confirm that the rendered text includes all turns in order and that the scorer's verdict changes when the late turns are changed. Keep the single-turn composite alongside it so each finding can be attributed.

  6. Run the composite on a small labeled set

    The test lead assembles a small set of responses that a human reviewer has already labeled as meeting or not meeting the policy, covering clear cases and borderline cases. The engineer runs the full composite, including inverted and thresholded components and any conversation scorer, over this set and records each verdict. Keep the labeled set in version control so the same run can be repeated after changes. Check the output by comparing each verdict with its human label and listing every mismatch for review.

  7. Check verdicts against expected outcomes

    The test lead reviews each mismatch and decides whether the component scorer, the aggregation rule, the threshold or the labels are at fault, then makes one change at a time and reruns the set. Agreement with the labels on this small set is a sanity check, not evidence that the scorer is accurate at scale, so measure accuracy separately before relying on it. Record the final configuration, the labeled set version and the mismatch log together. The step is complete when the team agrees that remaining disagreements are understood and accepted, and the configuration is written down for the next release review.

Security and operational risks in combined scoring

A composite scorer is only as trustworthy as the judges, settings and stored records beneath it. The risks below cover what attack output can do to a judge, where secrets and results live, and how quiet logic changes can distort trend lines between runs.

Manipulated judge models

A judge model reads the target's response, and that response can contain text written to influence the verdict. A response that tells the judge to answer "false" or to ignore the policy can flip a true/false scorer, and a composite inherits that flip. Test your judge with adversarial responses that you know should score as failures before you trust it on live attacks.

Combining scorers docs

Credentials in the local env file

PyRIT reads credentials from ~/.pyrit/.env, so any user or process with access to that file can use the keys for the target and judge services. Restrict file permissions on shared workstations and CI runners, keep the file out of repositories, and confirm whether your secrets manager can supply the same values at runtime.

Scores stored in memory

PyRIT memory keeps conversations and scorer results in SQLite or Azure SQL. Each stored verdict records which scorer produced it, so retention, access control and backups for that database become part of your evidence trail. Decide who can query or edit those rows and how long they are kept before the first scan runs.

Silent logic changes between runs

Changing a threshold, reordering a composite's inputs or swapping an inverter can move attack success rates without any change to the target. Pin scorer configuration in version control, record the configuration with each run, and rerun a fixed set of known responses after any edit so that a trend line change has a visible cause.

Scorer errors masked by composition

An OR composite can count one permissive scorer as a pass for the whole policy, and an AND composite can hide a failing judge behind a passing one. Log the individual child verdicts next to the composite result, so a reviewer can see which component decided each outcome.

Reporting PyRIT vulnerabilities

If you find a security flaw in PyRIT itself, such as a way a scorer or memory component can be abused, do not open a public issue. The project asks for private reports through the Microsoft Security Response Center under its security policy, so check the current guidance in the repository before reporting.

PyRIT repository

How AND, OR, inversion and thresholds change the verdict

An AND composite in PyRIT's TrueFalseCompositeScorer only reports success when every scorer it aggregates agrees, so it is the stricter choice when you need several independent conditions to hold at once. An OR composite reports success when any one of its scorers is true, which makes it the looser choice and the one to use when any of several failure signals should count. The difference matters most when a scorer is noisy. Illustrative example: a policy that flags a response when it contains step-by-step instructions or names a restricted product will fire more often under OR, so you should expect more findings to review and check the sample by hand before tightening the rule.

Inversion is where teams most often get the verdict backwards. TrueFalseInverterScorer negates one true/false scorer, so a refusal detector that returns true when the model refuses becomes a success signal only after inversion. Before wrapping any refusal-style scorer, decide what counts as a successful attack for your objective, then confirm the scorer's true and false meanings in its documentation and in a handful of stored responses. A reversed refusal check will report a blocked attack as a win, and the error will look like a strong result in your summary.

FloatScaleThresholdScorer turns a graded float score into a boolean by applying a threshold you set, so a Likert-style or other float-scale scorer can feed a composite that expects true/false inputs. The threshold is a policy decision, not a default to accept: a lower value flags more responses and a higher value flags fewer. Confirm the scale range of the wrapped scorer, choose the cut-off from labeled examples you trust, and record the value in your run configuration so that a later rerun uses the same rule. Plan to revisit the threshold whenever you change the judge model or the policy wording.

Limits to confirm before relying on combined verdicts

Combined scorers are only as reliable as their parts and the rules that join them. The cards below list what to confirm in your environment before a composite, inverted or threshold verdict drives a pass or fail decision. Each check maps to a behavior that can differ by scorer type, version or threshold choice.

Supported scorer types per combinator

Confirm which scorer classes each combinator accepts before you build the chain. TrueFalseCompositeScorer aggregates true/false scorers, TrueFalseInverterScorer negates one, and FloatScaleThresholdScorer wraps a float-scale scorer. Mixing a float scorer directly into a true/false composite is a common build error, so check the input type on every node and fail the build if a type does not match.

Combining scorers docs

Composite behavior with errors

Find out what the composite does when one component scorer fails, times out or returns no score. A judge model that returns malformed output or a content safety call that errors may not produce a clean true or false value. Test a deliberately broken component in a non-production run and record whether the attack is counted as a success, a failure or excluded, because that choice changes your attack success rate.

Thresholds that fit your scale

A FloatScaleThresholdScorer converts a score only at the cutoff you set, so the threshold must match the scale of the scorer it wraps. Confirm the range and direction of each float scorer's output, then decide where a harmful response starts for your policy. Record the cutoff with the policy it encodes, and retest it when you change the scorer or the model.

Accuracy of each component

A composite is not more accurate than its weakest component. An OR composite can raise false positives, and an AND composite can hide real failures when one scorer misses them. Before trusting any combined verdict, measure each component against human-labeled examples from your own policy. The method is covered in the scorer accuracy guidance linked from this section.

Conversation scorer inputs and cost

A conversation scorer renders the whole dialogue as text and scores it, so the result depends on how much context you include and how the judge model handles it. Check the rendered transcript for the turns you expect, and confirm the judge model's context window can hold a long conversation. Long transcripts can also raise the cost of each verdict, so measure the effect on a sample before running a large batch.

Version-specific behavior

Scorer classes, class names and default behaviors can change between PyRIT releases. Confirm every combinator's behavior against the PyRIT 1.1.0 documentation for the version you run, and pin that version in your environment. Re-run your accuracy checks after each upgrade, because a change in composition logic can move your results without any change to the target.

PyRIT 1.1.0 docs

Questions teams ask before combining PyRIT scorers

How much effort does a composite PyRIT scoring setup take?

Effort depends mostly on how many policy rules you must cover and how many of them already have a scorer. A composite built from two or three existing true/false scorers, combined with an AND or OR rule, is a small change in code. The larger effort is deciding what each sub-scorer should detect, testing the combined verdict on real responses, and checking the edge cases where scorers disagree. Ask any partner or internal lead to break the estimate into scorer selection, composite logic, threshold choices, conversation scoring and validation, and to state which of these is one-time and which recurs when the policy changes.

Can an in-house team build PyRIT composite scoring by itself?

A team with Python skills and familiarity with PyRIT's scorer classes can write the composite, inverter and threshold code without outside help. The harder part is the policy work: turning a written acceptable-use rule into a question that a judge model answers consistently, and deciding which failures count. Teams without a red teaming or applied safety owner often find that the code is the easy part and the judgment is not. A useful test is whether someone on the team can explain, for each sub-scorer, what it misses and why the combined rule is correct.

What inputs does the work need from our team?

Most setups need three inputs from your side. The first is the written policy text, including the harm categories and the level at which a response counts as a failure. The second is a set of labeled example responses that a human reviewer has marked as passing or failing, which you need to check that the combined scorer behaves as intended. The third is access to a judge model, through an endpoint, key or deployment that your security and data handling rules allow. Confirm with your security team where prompts and responses may be sent before you select a judge model.

How long does validation take, and what affects it?

Validation time depends on how many labeled examples you have, how many policy categories the composite covers, and how stable the judge model is between runs. Small sets with clear policy rules are quick to check. Large sets, ambiguous categories and multi-turn conversation scoring take longer because reviewers must agree on the labels first. Ask for the validation plan in writing, including the number of labeled examples, the reviewers involved, the metrics used to compare verdicts with human labels, and the point at which the team will rerun the check after a model or policy change.

Does conversation scoring need a different setup from single-turn scoring?

Yes. The create_conversation_scorer() helper renders a whole conversation as text so that a scorer can detect signals that only appear across turns, such as gradual persuasion or escalation. This changes the cost because each conversation is longer, so a judge call processes more text. It also changes the labels you need, since a reviewer must judge the whole exchange rather than one reply. Confirm with the PyRIT documentation that the scorer you plan to use supports this pattern in your installed version, and test it on conversations that break policy late rather than early.

Is a partner worth bringing in for PyRIT scoring?

A partner is most useful when the policy is complex, when several regulated categories must be covered by one verdict, or when the team needs evidence that an auditor or customer security reviewer can follow. DeployOpen plans and implements self-hosted testing setups inside your infrastructure and prepares the validation records that such reviews ask for, but it does not issue audit reports or certifications. Engagements are fixed-scope, so ask for a written scope, the list of deliverables, the labeled data you must supply and the retest or handover terms before work starts.

What should we ask for in a quote for this work?

Ask for the quote to be tied to a written scope that lists the policy categories, the number of sub-scorers, whether conversation scoring is included, the labeled examples you will provide, and the validation steps. Confirm which items are one-time, such as design and first validation, and which recur, such as rerunning checks after a judge model or PyRIT version changes. DeployOpen does not publish a price list, so the quote will follow from that written scope rather than a standard rate.

Official PyRIT documentation for scorer composition

Start with the PyRIT 1.1.0 documentation page on Combining and Stacking Scorers before you write any composite logic. It is the primary reference for the three building blocks this topic depends on: TrueFalseCompositeScorer for aggregating several true/false scorers, TrueFalseInverterScorer for negating one, and FloatScaleThresholdScorer for turning a float-scale scorer into a true/false result. It also documents create_conversation_scorer(), which renders a whole conversation as text so a scorer can judge signals that only appear across turns. Read the page against the exact version you run, because scorer class names and signatures change between releases, and the 1.1 line is the one this page describes.

Use the PyRIT documentation root and the GitHub repository for context around that page. The documentation root links the scorer, target, attack and memory sections, which you need when a composite depends on a scorer described elsewhere, such as an LLM judge or a Likert scale. The repository at github.com/microsoft/PyRIT is where the source of each scorer class lives, so when the documentation leaves a parameter or default unclear, read the code for the version you have pinned rather than relying on memory or on examples from older releases. Confirm the exact class names and constructor arguments in your installed version before you copy any snippet into a policy pipeline.

How DeployOpen works on this

DeployOpen plans, builds, tests and documents PyRIT scoring logic inside your infrastructure, starting from your written policy and the harms you need to decide on. Composite, inverted, threshold and conversation scorers are scoped as one set of decisions, so the verdicts your team relies on can be traced back to the rules that produced them.

How we scope

  • Start from your written policy and list each harm the scorer must decide on, with the pass and fail meaning for each.
  • Define which small scorers feed each composite, and whether every one must agree or any one is enough.
  • Agree in writing which conversation-level signals, if any, need a whole-conversation scorer and which stay per response.

How we build

  • Assemble TrueFalseCompositeScorer and TrueFalseInverterScorer logic from tested building blocks, with each rule written as a reviewable configuration.
  • Set FloatScaleThresholdScorer cutoffs against labeled sample responses that your reviewers agree on before they are used.
  • Test composites against known-compliant and known-violating transcripts, including edge cases where scorers disagree.

How we hand over

  • Deliver the scorer configuration, the rule definitions and the test transcripts used to validate each one.
  • Document how each verdict is produced so your security and compliance reviewers can follow it from input to result.
  • Run a handover session with the engineers who will maintain the scoring rules and change them safely.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer, including re-checking scorers after PyRIT releases.
  • Ask any quote to state which scorers, composites and thresholds are in scope, and who maintains them after handover.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.