Metadata-Version: 2.4
Name: rote-benchmark
Version: 0.1.0
Summary: Rollout testing of exact symbolic memorization
Author: Xinye Chen
License-Expression: MIT
Project-URL: Homepage, https://github.com/chenxinye/slearn
Project-URL: Documentation, https://github.com/chenxinye/slearn/tree/main/docs
Project-URL: Repository, https://github.com/chenxinye/slearn
Project-URL: Issues, https://github.com/chenxinye/slearn/issues
Keywords: symbolic sequences,LZW,memorization,benchmark
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.23
Requires-Dist: pandas>=1.5
Provides-Extra: experiment
Requires-Dist: torch>=2.4; extra == "experiment"
Requires-Dist: minGRU-pytorch>=0.2.1; extra == "experiment"
Requires-Dist: linear-attention-transformer>=0.19.1; extra == "experiment"
Requires-Dist: performer-pytorch>=1.1.4; extra == "experiment"
Provides-Extra: plot
Requires-Dist: matplotlib>=3.7; extra == "plot"
Requires-Dist: seaborn>=0.12; extra == "plot"
Provides-Extra: all
Requires-Dist: torch>=2.4; extra == "all"
Requires-Dist: minGRU-pytorch>=0.2.1; extra == "all"
Requires-Dist: linear-attention-transformer>=0.19.1; extra == "all"
Requires-Dist: performer-pytorch>=1.1.4; extra == "all"
Requires-Dist: matplotlib>=3.7; extra == "all"
Requires-Dist: seaborn>=0.12; extra == "all"
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Provides-Extra: docs
Requires-Dist: sphinx>=7; extra == "docs"
Requires-Dist: furo>=2024.8.6; extra == "docs"
Dynamic: license-file

# ROTE

[![Tests](https://github.com/chenxinye/slearn/actions/workflows/tests.yml/badge.svg)](https://github.com/chenxinye/slearn/actions/workflows/tests.yml)
[![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B-3776AB?logo=python&logoColor=white)](https://github.com/chenxinye/slearn/blob/main/pyproject.toml)
[![License: MIT](https://img.shields.io/badge/License-MIT-008080.svg)](https://github.com/chenxinye/slearn/blob/main/LICENSE)

**ROTE** (Rollout Testing of Exact memorization) is a reproducible benchmark for learning and extending controlled symbolic sequences. It generates seeds at specified Lempel-Ziv-Welch (LZW) complexity, trains finite-context next-symbol predictors, and evaluates both teacher-forced prediction and closed-loop rollout. The package includes the fixed-budget comparison and a high-complexity matched-size check used in the accompanying manuscript.

## Install

ROTE is currently installed from source; a PyPI release has not yet been published. The distribution name is `rote-benchmark` and the import name is `rote_benchmark`. The shorter [`rote`](https://pypi.org/project/rote/) name belongs to an unrelated PyPI project.

```bash
git clone https://github.com/chenxinye/slearn.git
cd slearn
python -m pip install -e .                 # seed generation and rollout metrics
python -m pip install -e '.[all]'           # models and plotting
```

Python 3.10 or newer is required. The core install uses NumPy and pandas. The optional experiment dependencies include PyTorch, `minGRU-pytorch`, `linear-attention-transformer`, and `performer-pytorch`. The RWKV-style baseline is implemented in PyTorch and needs no separate RWKV package.

## Quick Start

```python
from rote_benchmark import lzw_string_seeds, normalized_damerau_levenshtein_distance

seeds = lzw_string_seeds(symbols=[4, 8], complexity=[30, 90], iterations=2, random_state=3407)
seed = seeds.loc[0, "string"]
print(seeds[["nr_symbols", "LZW_complexity", "length"]])
print(normalized_damerau_levenshtein_distance(seed, seed))  # 0.0
```

The generated table has `nr_symbols`, `LZW_complexity`, `length`, and `string` columns. Complexity is the number of LZW output codes after reducing a seed to its shortest period; it is not a compressed byte count. For complete experiment settings and CLI options, see the [documentation](https://github.com/chenxinye/slearn/tree/main/docs/source).

## Reproduce the Benchmark

```bash
rote-benchmark --smoke --device cpu --output-dir /tmp/rote-smoke
rote-benchmark --help
rote-matched-size --help
```

The main track compares LSTM, GRU, minGRU, minLSTM, Transformer, LinearAttention, Performer, and a compact RWKV-style model. The matched-size track selects widths close to a target parameter count. Both write configuration JSON and incremental CSV results. Install `.[all]` before running the full model set. The smoke test uses tiny settings and is an installation check, not a paper run.

On the Convergence cluster, submit from `exps/`:

```bash
cd exps
sbatch scripts/run_symbolic_benchmark_slurm.sh
sbatch scripts/run_matched_size_symbolic_slurm.sh
```

Merge completed array shards and plot locally from the repository root:

```bash
cd ..
bash exps/scripts/merge_symbolic_results.sh exps/results_symbolic/slurm_<job_id>
bash exps/scripts/run_symbolic_visualizations.sh exps/results_symbolic/slurm_<job_id>/results_merged.csv
bash exps/scripts/run_matched_size_comparison_visualization.sh \
  exps/results_symbolic/slurm_<job_id>/results_merged.csv \
  exps/results_symbolic_matched_size/slurm_<matched_job_id>/results_merged.csv
```

Published experiment outputs remain archived in [`legacy/exps`](https://github.com/chenxinye/slearn/tree/main/legacy/exps); the new scripts write only to root `exps/`. Historical seeds used a process-global Python random stream before the generator adopted an independently seeded stream for each seed. To replay those exact strings, pass the archived `results_merged.csv` as `--seed-manifest` (or set `SEED_MANIFEST` for Slurm). See the [experiment guide](https://github.com/chenxinye/slearn/blob/main/docs/source/experiments.rst) for commands and reproducibility limits.

## Documentation and Tests

```bash
python -m pip install -e '.[docs,test]'
python -m pytest
sphinx-build -b html -W docs/source docs/build/html
```

## Citation and License

The benchmark builds on Cahuantzi, Chen, and Guettel, [*A Comparison of LSTM and GRU Networks for Learning Symbolic Sequences*](https://doi.org/10.1007/978-3-031-37963-5_53) (2023). For the ROTE manuscript, cite the final published version when available. ROTE is distributed under the [MIT License](https://github.com/chenxinye/slearn/blob/main/LICENSE). The historical software and results are preserved in `legacy/`.
