How to use from the
Use from the
Transformers library
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("syssec-utd/pylingual-v1-control-flow", device_map="auto")
Quick Links

pylingual-v1-control-flow

The control flow model of PyLingual: given a code object's translated statements and its bytecode, it predicts how the statements nest, as a skeleton such as <s0> { <s1> } else { <s2> }. 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).

Downloads last month
36
Safetensors
Model size
5.12M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support