Instructions to use syssec-utd/pylingual-v1-control-flow with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use syssec-utd/pylingual-v1-control-flow with Transformers:
# 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") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from syssec-utd/pylingual-v1-control-flow: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/syssec-utd/pylingual-v1-control-flow/resolve/main/README.md
- Command line
-
hf download hf://syssec-utd/pylingual-v1-control-flow/README.md
-
curl -L -o README.md https://huggingface.co/syssec-utd/pylingual-v1-control-flow/resolve/main/README.md
1.59 kB
| 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 `<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`). | |