Skip to main content

TF-Bench

python Code style: black

Evaluating Program Semantics Reasoning with Type Inference in System F

evaluation workflow

If you find this work useful, please cite us as:

@inproceedings{he2025tfbench,
    author = {He, Yifeng and Yang, Luning and Gonzalo, Christopher and Chen, Hao},
    title = {Evaluating Program Semantics Reasoning with Type Inference in System F},
    booktitle = {Neural Information Processing Systems (NeurIPS)},
    date = {2025-11-30/2025-12-07},
    address = {San Diego, CA, USA},
}

Development

Python

We use Python 3.11. We recommend using uv to manage your Python dependencies.

cd TF-Bench
uv sync # create a virtual environment, and install dependencies

Haskell

To run evaluation, you need GHC (the Glasgow Haskell Compiler) installed. We recommend using ghcup to install.

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

Due to the GHC dependency, the evaluation module currently only supports Linux and macOS. Our evaluation requires Haskell language extensions type operators and impredicative polymorphism, so we require GHC version >= 9.2.1. Our evaluation used GHC-9.6.7.

Building TF-Bench from scratch (optional)

TF-Bench (base)

This script will build the benchmark (Prelude with NL) from the raw data.

uv run scripts/preprocess_benchmark.py -o tfb.json

TF-Bench (pure)

git clone https://github.com/SecurityLab-UCD/alpharewrite.git
cd alpharewrite

stack build
stack exec alpharewrite-exe 1 ../tfb.json > ../tfb.pure.json

cd ..

For details, please check out the README of alpharewrite.

Download pre-built benchmark

You can also use TF-Bench on HuggingFace datasets.

from datasets import load_dataset

split = "pure" # or "base"
dataset = load_dataset("SecLabUCD/TF-Bench", split=split)

Or through our provided package.

from tfbench import load_tfb_from_hf

dataset = load_tfb_from_hf(split)

Using as an application

git clone https://github.com/SecurityLab-UCD/TF-Bench.git
cd TF-Bench
uv sync

Please have your API key ready in .env.

Proprietary models

We use each provider's official SDK to access their models. You can check our pre-supported models in tfbench.lm module.

from tfbench.lm import supported_models
print(supported_models)

To run single model, which runs both base and pure splits:

uv run main.py -m gpt-5-2025-08-07

Open-weights models with Ollama

We use Ollama to manage and run the OSS models reported in the Appendix. We switched to vLLM for better performance and SDK design. Although the Ollama option is still available, it is no longer maintained. We recommend using vLLM instead.

curl -fsSL https://ollama.com/install.sh | sh # install ollama, you need sudo for this
ollama serve # start your own instance instead of a system service

NOTE: we required the ollama version at least 0.9.0 to enable thinking parsers. We use 0.11.7 for our experiments.

> ollama --version
ollama version is 0.11.7

Run the benchmark.

uv run src/main.py -m llama3:8b

Running any model on HuggingFace Hub

We also support running any model that is on HuggingFace Hub out-of-the-box. We provide an example using Qwen3.

uv run src/main.py Qwen/Qwen3-4B-Instruct-2507 # or other models

Note that our main.py uses a pre-defined model router, which routes all un-recognized model names to HuggingFace. We use the </think> token to parse thinking process, if the model do it differently, please see the next section.

Running your own model

To support your customized model, you can input the path to your HuggingFace compatible checkpoint to our main.py.

uv run src/main.py <path to your checkpoint>

Using as a package

Our package is also available on PyPi.

uv add tfbench

Or directly using pip, you know the way

pip install tfbench

Proprietary model checkpoints that are not currently supported

Our supported model list is used to route the model name to the correct SDK. Even a newly released model is not in our supported models list, you can still use it by specifying the SDK client directly. We take OpenAI GPT-4.1 as and example here.

from tfbench.lm import OpenAIResponse
from tfbench import run_one_model

model = "gpt-4.1"
split = "pure"
client = OpenAIResponses(model_name=model, pure=split == "pure", effort=None)
eval_result = run_one_model(client, pure=split == "pure", effort=None)

Support other customized models

You may implement an LM instance.

from tfbench.lm._types import LM, LMAnswer

class YourLM(LM):
    def __init__(self, model_name: str, pure: bool = False):
        """initialize your model"""
        super().__init__(model_name=model_name, pure=pure)
        ...

    def _gen(self, prompt: str) -> LMAnswer:
        """your generation logic here"""
        return LMAnswer(answer=content, reasoning_steps=thinking_content)

Metadata

Release files for tfbench 1.0.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 tfbench 1.0.0
File Size Uploaded Provenance Actions
tfbench-1.0.0.tar.gz 27.1 kB Without provenance Details for tfbench-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 63.9 kB

Release files / tfbench-1.0.0.tar.gz

Download URL tfbench-1.0.0.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0c17231759ccadad442c0e1edf80f3f93cedf56fa6b42162fc660a8c537d3148
BLAKE2b-256 checksum
How to use checksums
ecfc881637bca89fd4a2b0cca276208a7e66624c903d1e7cdb8179d547771906
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release files / tfbench-1.0.0-py3-none-any.whl

Download URL tfbench-1.0.0-py3-none-any.whl
Size 36.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5f3a2ba4aade82cd09e0f697527e9702f6fafd53bfaf892b7fe4594a54dbf0b
BLAKE2b-256 checksum
How to use checksums
2d51e2f4b12dfc8fbf7c91f6c3789c4aaac7c6cac521a308b0966a774cfd3206
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Security for tfbench 1.0.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

1.0.0 This release

2 release files No 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