To compare two prompt versions fairly, run both against the same saved inputs, preserve both responses, and score them with a small local Python script. The method below uses illustrative text only, so it requires no paid API call.
Prerequisites and intended result
You need Python 3, a text editor, and a way to run each prompt manually. ChatGPT or another model interface is sufficient.
The comparison script never contacts OpenAI. It reads a CSV file and checks required and forbidden phrases.
The result is a report with pass counts, regressions, improvements, and unchanged cases. A regression means version 1 passed but version 2 failed.
| Item | Fixed for both versions |
|---|---|
| Test cases | The same three CSV rows |
| Model | The same selected model |
| Tools | The same enabled or disabled tools |
| Input | The same text from the input column |
| Evaluation | The same required and forbidden phrases |
OpenAI Playground currently supports project-level prompts, variables, published versions, rollback, and side-by-side comparison. Its documented path is Playground → Prompts → Create New. See the Playground prompt management guide.
If you use Playground or an API-backed interface, check its billing conditions first. The local comparison step below does not call an API.
Complete worked example: identical cases, two prompts
Use one variable called input. Keep the model, tools, and conversation conditions unchanged.
Prompt A is the baseline:
You are a customer-support editor.
Answer the user's question in one concise sentence.
Use clear, direct language.
Prompt B is the candidate revision:
You are a customer-support editor.
Answer the user's question in one concise sentence.
Use clear, direct language.
Include every date, time, condition, and safety qualification stated by the user.
Do not invent missing information.
If using Playground, create version 1 with Prompt A, then create a draft containing Prompt B. The documented side-by-side control lets you inspect both versions before publishing.
Example input:
case_id,input,required_terms,forbidden_terms,v1_output,v2_output
case-1,"Explain why a password reset link expires.","expires;security","never expires","The link expires for security.","The link never expires; use it anytime."
case-2,"Rewrite this in plain English: The meeting is moved to Friday at 3 PM.","Friday;3 PM","Thursday","The meeting is on Friday.","The meeting is on Friday at 3 PM."
case-3,"Can I cancel the order before shipment?","cancel;before shipment","cannot cancel","You can cancel before shipment.","You can cancel before shipment."
The responses in this fixture are invented sample data. They demonstrate the comparison logic and are not claimed results from a model run.
Save the CSV as prompt_comparison.csv. The required_terms field uses semicolons, so a case passes only when every required phrase appears.
Run the local comparison and read the report
Save this complete program as compare_prompts.py in the same folder:
import csv
from pathlib import Path
FIXTURE = Path("prompt_comparison.csv")
def terms(value):
return [
item.strip().casefold()
for item in value.split(";")
if item.strip()
]
def evaluate(output, required, forbidden):
text = output.casefold()
missing = [item for item in required if item not in text]
forbidden_found = [item for item in forbidden if item in text]
passed = not missing and not forbidden_found
return passed, missing, forbidden_found
def label(passed):
return "PASS" if passed else "FAIL"
def main():
with FIXTURE.open(newline="", encoding="utf-8") as file:
rows = list(csv.DictReader(file))
results = []
totals = {"v1": 0, "v2": 0}
for row in rows:
required = terms(row["required_terms"])
forbidden = terms(row["forbidden_terms"])
checked = {}
for version in ("v1", "v2"):
passed, missing, forbidden_found = evaluate(
row[f"{version}_output"],
required,
forbidden,
)
checked[version] = {
"passed": passed,
"missing": missing,
"forbidden": forbidden_found,
}
totals[version] += int(passed)
before = checked["v1"]["passed"]
after = checked["v2"]["passed"]
if before and not after:
status = "regression"
elif not before and after:
status = "improvement"
else:
status = "unchanged"
details = [f'{row["case_id"]}: {status}']
details.append(
f'v1={label(before)}, v2={label(after)}'
)
if checked["v1"]["missing"]:
details.append(
"v1 missing=" + ", ".join(checked["v1"]["missing"])
)
if checked["v2"]["missing"]:
details.append(
"v2 missing=" + ", ".join(checked["v2"]["missing"])
)
if checked["v1"]["forbidden"]:
details.append(
"v1 forbidden=" + ", ".join(checked["v1"]["forbidden"])
)
if checked["v2"]["forbidden"]:
details.append(
"v2 forbidden=" + ", ".join(checked["v2"]["forbidden"])
)
results.append("; ".join(details))
total = len(rows)
print(f"v1: {totals['v1']}/{total} passed ({totals['v1'] / total:.1%})")
print(f"v2: {totals['v2']}/{total} passed ({totals['v2'] / total:.1%})")
for result in results:
print(result)
if __name__ == "__main__":
main()
Run it with:
python compare_prompts.py
Expected output:
v1: 2/3 passed (66.7%)
v2: 2/3 passed (66.7%)
case-1: regression; v1=PASS, v2=FAIL; v2 missing=security; v2 forbidden=never expires
case-2: improvement; v1=FAIL, v2=PASS; v1 missing=3 pm
case-3: unchanged; v1=PASS, v2=PASS
The CSV contains invented responses. The local Python script was run against this fixture on September 22, 2026, and produced the five lines shown above; this is not a comparison of actual model runs.
Verify the result:
- Case 1 must be marked
regression. - Case 2 must be marked
improvement. - Case 3 must be marked
unchanged. - Both versions must show two passing cases out of three.
- The script must run without an API key or network connection.
This is a deliberately simple evaluator. It checks phrase presence, not factual truth, tone, grammar, or semantic equivalence.
Acceptance checks, failures, and recovery
Accept version 2 only if it improves the intended cases without creating an unacceptable regression. A higher total score is not enough when a safety or compliance case fails.
A useful acceptance rule for this fixture is:
| Check | Acceptance condition |
|---|---|
| Required details | Every required phrase appears |
| Forbidden details | No forbidden phrase appears |
| Regression gate | Zero regressions in protected cases |
| Improvement | Case 2 changes from FAIL to PASS |
| Reproducibility | Both versions use the same rows and settings |
A likely failure is editing the CSV while collecting outputs. For example, changing required_terms after seeing version 2 can make the comparison favor the revision.
Recover by restoring the fixture from version control or a read-only copy. Then collect both outputs again using the original rows.
Another failure occurs when the two versions use different models or tools. That measures a prompt-and-model change rather than a prompt change.
Recover by recording the model name, enabled tools, and prompt version beside each output. Repeat the test with those controls fixed.
OpenAI’s official Evals system supports richer graders and custom data schemas, but using it requires an API workflow. This local script is suitable for a small smoke test, not for large-scale statistical evaluation or subjective quality scoring.
The method is unsuitable when outputs contain sensitive data that should not be stored locally, when correctness requires expert review, or when phrase matching cannot represent the task. Add human review or a domain-specific evaluator in those cases.
Frequently Asked Questions (FAQ)
Q1) Does this method prove that Prompt B is better?
No. It proves only how the two saved outputs perform against the listed checks. A larger test set and human review are needed for broader claims. A prompt can pass phrase checks while still being misleading or stylistically poor.
Q2) Can I use OpenAI Evals instead of the Python script?
Yes, if you are willing to use an API-backed evaluation workflow. OpenAI documents custom data sources and graders such as string checks and model-based graders in its Evals API reference. The local script is the no-API alternative.
Q3) Why did the score stay the same after an improvement?
Version 2 improved case 2 but regressed case 1, so the gains canceled out. This is why the report lists regressions and improvements separately. Protect important cases with a zero-regression acceptance rule instead of relying only on the average score.