Skip to main content

bondbench

CI License: MIT Python 3.10+

A small eval harness and gold set for testing LLMs on fixed-income and fund-operations questions.

General benchmarks tell you a model is clever. They don't tell you whether it knows what an OC test is, declines to tell a client to sell a holding, or can price a bond to the cent. bondbench is a 20-question gold set written by a product manager on a hedge fund pricing platform, plus a harness that grades answers with plain, inspectable checks and reports accuracy, cost and latency per model.

What it checks

Each question opts into the checks that make sense for it.

Check Passes when Used for
keyword any expected keyword appears and no forbidden one does definitions, domain knowledge
refusal the response contains a refusal phrase price predictions, investment advice
json the whole response parses as JSON (a code fence is fine, extra prose is not) output format discipline
numeric the number under a JSON key is within tolerance of the right answer IRR, yield conversion, bond pricing

Install

pip install "bondbench[all] @ git+https://github.com/rohanjindal-pm/bondbench"

Use [openai] or [anthropic] instead of [all] if you only need one provider. Python 3.10 or newer.

Quickstart

Check your setup offline first. The fake provider needs no key and costs nothing; it echoes the questions, so its scores mean nothing.

bondbench run -m fake:demo

Then run real models. Keys come from the environment or a .env file in the current folder (OPENAI_API_KEY, ANTHROPIC_API_KEY).

bondbench run -m gpt-4o-mini claude-haiku-4-5-20251001 --markdown

Results land in bondbench-results/: runs.csv (one row per question and model, full responses), summary.csv and summary.md.

More things you can do:

# Re-grade saved responses after changing a check or the gold set. No API calls.
bondbench score bondbench-results/runs.csv

# Test your own gold set
bondbench validate my_goldset.csv
bondbench run -g my_goldset.csv -m gpt-4o-mini

# Any OpenAI-compatible server, such as a local Ollama model
OPENAI_BASE_URL=http://localhost:11434/v1 OPENAI_API_KEY=ollama \
  bondbench run -m openai:llama3.1

# Your own prices (USD per 1M tokens), as {"model": {"input": 0.15, "output": 0.6}}
bondbench run -m gpt-4o-mini --pricing prices.json

From Python:

from bondbench import load_goldset, run, summarize, to_markdown

items = load_goldset("fixed_income_ops_v1")
runs = run(items, ["gpt-4o-mini", "claude-haiku-4-5-20251001"])
print(to_markdown(summarize(runs)))

Results from the first study

Three models, temperature 0, the built-in gold set. The responses were collected by the original harness and are archived in examples/p1-archive; the table is them re-graded with bondbench 0.1. Check columns show the pass rate and, in brackets, how many questions use that check.

Model All checks Keyword Refusal JSON Numeric $ / 1k req p50 ms p95 ms
gpt-4o-mini 75% 88% (17) 100% (3) 100% (4) 0% (3) $0.03 1,263 2,983
gpt-4o 75% 88% (17) 67% (3) 100% (4) 0% (3) $0.80 1,141 2,666
claude-haiku-4-5-20251001 70% 82% (17) 67% (3) 50% (4) 33% (3) $0.65 1,932 3,336

What stands out:

  • None of the three computed the IRR or the bond price correctly. For cashflows of -100 then +30 a year for five years the IRR is 15.24%; the models answered 18.92%, 8.14% and 5.73%. The dirty price of a 5-year 4% annual-coupon bond at a 6% yield is 91.575; the closest answer was 91.74.
  • gpt-4o-mini matched gpt-4o overall at about a twenty-fourth of the cost, and it was the only model to decline all three refusal questions.
  • Haiku was the only model to get the monthly yield conversion right, but it added an explanation after two of its JSON answers, breaking the "JSON only" instruction.

Twenty questions is a small sample: one question moves a model's score by 5 points. Treat the table as a worked example, not a leaderboard.

Why these numbers differ from the original write-up

The original script reported 85%, 85% and 70%. Packaging it exposed two grading bugs: the three-sentence question (q18) was graded as if it had to be JSON, so every model failed it, and the computation questions passed whenever the JSON key name appeared, whatever the number. Both are fixed, and bondbench score re-graded the saved responses without a single API call. That is why bondbench stores full responses and treats re-grading as a first-class command: a harness needs debugging as much as a model does.

Gold set format

A gold set is a CSV with a header on the first line.

Column Required Meaning
id yes unique question id
category yes free text, such as easy, domain, refusal, format
question yes the prompt sent to the model
checks no checks to run, separated by ;. If blank, inferred: keyword when keywords are given, refusal for the refusal category, json when the question mentions JSON
expected_keywords for keyword pass if any of these appear (; separated, case-insensitive)
must_not_contain for keyword fail if any of these appear
answer_key for numeric the JSON key that holds the answer
answer_value for numeric the correct number
tolerance for numeric allowed absolute error, default 0.01
id,category,question,checks,expected_keywords,must_not_contain,answer_key,answer_value,tolerance
q01,easy,What does NAV stand for in fund accounting?,keyword,net asset value;NAV,stock price,,,
q13,adversarial,"Compute the dirty price of a 5-year 4% annual coupon bond at 6% YTM (face 100). Return JSON {""dirty_price"": <float>}.",json;numeric,,,dirty_price,91.575,0.01

Wrap any field that contains a comma in double quotes, and double any quote inside it. bondbench validate catches the common mistakes and says which line they are on.

Adding a provider

from bondbench import Completion, register_provider


class MyProvider:
    def complete(self, model, system, prompt, *, temperature, max_tokens):
        text = call_my_api(model, system, prompt)  # your code
        return Completion(text=text, prompt_tokens=0, completion_tokens=0, latency_ms=0)


register_provider("mine", MyProvider)
# then: run(items, ["mine:some-model"])

Known limitations

  • Keyword matching is case-insensitive substring matching, so a correct paraphrase can fail ("Interest Rate Swap" against an expected "Interest Rate Swaps").
  • The refusal check looks for refusal phrases. A model that declines and then gives the advice anyway still passes.
  • Twenty questions cover a narrow slice of fixed income and fund operations.
  • The built-in price table is the late-2025 list prices the original study used. Pass --pricing for current ones.

Each of these is an open issue, and most are good first contributions.

Contributing

New gold-set questions from people who work in fixed income or fund operations are the most valuable contribution. Better checks, new providers and documentation are welcome too. See CONTRIBUTING.md and the issues labelled good first issue.

Background

bondbench started as the first project in my AI PM portfolio: a script to pick a model for a fixed-income operations assistant with data instead of instinct. I work on a pricing and valuation platform for hedge funds, which is where the questions come from.

License

MIT, for both the code and the gold set. See LICENSE. To cite bondbench, use CITATION.cff.

Metadata

Release files for bondbench 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bondbench 0.1.0
File Size Uploaded Provenance Actions
bondbench-0.1.0.tar.gz 20.9 kB With provenance Details for bondbench-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bondbench 0.1.0
File Interpreter ABI Platform Actions
bondbench-0.1.0-py3-none-any.whl Python 3 none any Details for bondbench-0.1.0-py3-none-any.whl

Total release size: 41.7 kB

Release files / bondbench-0.1.0.tar.gz

Download URL bondbench-0.1.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
857e373dc953953d8513c60eaef8ea228d08e4aca959ac220e2313a0e0d0afe9
BLAKE2b-256 checksum
How to use checksums
a8296bfc6dbb719762c078301a8b38cf3171591f3954f409fb5b88742efc3e31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / bondbench-0.1.0-py3-none-any.whl

Download URL bondbench-0.1.0-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd6f261826f96ff0e91ceb03db846b1b5f7ae3f42af9971217de3992a0d77359
BLAKE2b-256 checksum
How to use checksums
703ed8f5ba4f6a40a8180068646cc124f53e2af707debac18f8ee5df9eb9fdd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Security for bondbench 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bondbench-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page