--- library_name: transformers license: gpl-3.0 tags: - pylingual - decompilation --- # pylingual-v1-control-flow The control flow model of [PyLingual](https://github.com/syssec-utd/pylingual): given a code object's translated statements and its bytecode, it predicts how the statements nest, as a skeleton such as ` { } else { }`. One model serves Python 3.6 to 3.15. It is a transition model (`pylingual/control_flow_reconstruction/transition.py`, 5.1M parameters): a 4-layer transformer encodes the statements (d_model 256, 8 heads), and a 2-layer LSTM decoder writes the skeleton one action at a time, pointing at statements. A pushdown automaton of Python's block structure (`pylingual/control_flow_reconstruction/block_grammar.py`) masks the actions, so every skeleton renders to source that compiles. It loads with PyLingual's `TransitionModel`, not with `AutoModel`. ## Training Code objects of the 150k sources of the PyLingual v1 translation models' corpus, 15k per version (13,500 PyPI, 1,500 CodeSearchNet), each source compiled for one version, labeled with the skeleton of their source and kept only if it recompiles to equivalent bytecode (`dev_scripts/dataset_generation/bytecode2cflow.py`). Trained with `dev_scripts/control_flow/train_transition.py` and `dev_scripts/sample_jsons/sample-control-flow-transition-unified.json`: 48 epochs, learning rate 1e-3, cosine schedule, up to 64 code objects per batch, seed 42; validation loss 0.0095. On the held-out test split, the greedy skeleton equals the source's for 95.5% of code objects (`eval.json`).