Skip to main content

Symbolic reasoning playground and benchmark

Project description

The goal of this library is to provide a symbolic reasoning benchmark, and associated benchmarking utilities, that is very simple, easy to extend, experiment with, and has many knobs to tweak to change difficulty.

Currently supports 16-bit long binary tasks, i.e., your solver system is supplied some 16-bit long inputs with corresponding 16-bit outputs, and you need to create a function f(input) -> output.

Inputs are randomly generated then passed through a function to produce the output, so just by defining a function with signature Callable[[list[int]] -> list[int]], you get access to 2^length input-output pairs (65536 currently). You can easily adjust the number of train and test samples per task, see the basic use example:

import random

from tasks import Register, Pair, TaskCollection
from task_list import task_list

def main() -> None:
    # task_list: list[Callable[[Register], Register]], Register: tuple[int, ...]
    # Easily add your own
    def nand(bits: Register) -> Register:
        # bitwise NAND between halves, zero pad on left
        mid = len(bits) // 2
        return tuple(1 - (bits[i] & bits[i + mid]) for i in range(mid)) + (0,) * mid

    task_list.append(nand)

    # Define tasks to be used in this experiment
    # For each, we will generate random strings for input, then pass through hidden function to get output
    collection = TaskCollection(task_list, train_samples=10, test_samples=100)

    for train_samples, eval_fn, task_name in collection.tasks(): # train_samples: list[Pair]
        for pair in train_samples: # pair: Pair[input: Register, output: Register]
            inp = pair.input # Register: tuple[int, ...]
            out = pair.output # Register: tuple[int, ...]
            # Currently both are 16 values long, values restricted to 0 or 1

        # Define solver function using this task's inputs and outputs
        def random_solver(inputs: Register) -> Register:
            return tuple(random.randint(0, 1) for _ in inputs)

        # Pass solver function to task-specific eval_fn, so there can't be test data leakage
        # pixel_acc: what fraction of pixel predictions are correct?
        # pair_acc: what fraction of output predictions are correct? (all pixels correct in one output)
        pixel_acc, pair_acc = eval_fn(random_solver)
        print(
            f"{task_name}: pixel_accuracy={pixel_acc:.3f} pair_accuracy={pair_acc:.3f}"
        )

if __name__ == "__main__":
    main()

Plan to support:

  • Arbitrary lengths in input and output (currently 16), and differing input/output lengths
  • Arbitrary number of categories (currently 2)
  • 2D and 3D tasks (currently only 1D)
  • Task input templates (where some or all of input is set manually by humans - currently all random)

Currently the main library functionality lives in tasks.py, and the small number of pre-defined tasks live as simple functions in task_list.py

See the advanced example for WIP functionality including defining parameter sweeps for arbitrary models / solvers, logging training progress, and aggregating and visualizing training by task, metric, and solver.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minireason-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minireason-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file minireason-0.1.0.tar.gz.

File metadata

  • Download URL: minireason-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for minireason-0.1.0.tar.gz
Algorithm Hash digest
SHA256 218dfa5db6be3e41abd62bb5ac45402293dfe4cc7798deb79538009a44321903
MD5 e0d1b5aba8ccd8f6cca6946bb90058c2
BLAKE2b-256 4eb6d144bc551acd0d26a75f97b9d82d2c7976bdd8c83fbc9241da30bbd1a4e7

See more details on using hashes here.

File details

Details for the file minireason-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: minireason-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for minireason-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6bf5c66794bbc441784964bb483068462cd350fca07c4c1ed9e5e970c655bc1f
MD5 eb0f5806552099a8b884bc5d020d09c5
BLAKE2b-256 300ec27a8152deb6f5413a577018cdd975554a1d1a4635645a0c7b6d4292f7cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page