CoolFace
Modelpublic

SEBIS/code_trans_t5_small_code_documentation_generation_php

sourceHugging Faceupdated 5y agoView on Hugging Face
0likes41downloads
Model Card

CodeTrans model for code documentation generation php

Pretrained model on programming language php using the t5 small model architecture. It was first released in this repository. This model is trained on tokenized php code functions: it works best with tokenized php functions.

Model description

This CodeTrans model is based on the t5-small model. It has its own SentencePiece vocabulary model. It used single-task training on CodeSearchNet Corpus php dataset.

Intended uses & limitations

The model could be used to generate the description for the php function or be fine-tuned on other php code tasks. It can be used on unparsed and untokenized php code. However, if the php code is tokenized, the performance should be better.

How to use

Here is how to use this model to generate php function documentation using Transformers SummarizationPipeline:

python
from transformers import AutoTokenizer, AutoModelWithLMHead, SummarizationPipeline

pipeline = SummarizationPipeline(
    model=AutoModelWithLMHead.from_pretrained("SEBIS/code_trans_t5_small_code_documentation_generation_php"),
    tokenizer=AutoTokenizer.from_pretrained("SEBIS/code_trans_t5_small_code_documentation_generation_php", skip_special_tokens=True),
    device=0
)

tokenized_code = "public static function update ( $ table ) { if ( ! is_array ( $ table ) ) { $ table = json_decode ( $ table , true ) ; } if ( ! SchemaManager :: tableExists ( $ table [ 'oldName' ] ) ) { throw SchemaException :: tableDoesNotExist ( $ table [ 'oldName' ] ) ; } $ updater = new self ( $ table ) ; $ updater -> updateTable ( ) ; }"
pipeline([tokenized_code])

Run this example in colab notebook.

Training data

The supervised training tasks datasets can be downloaded on Link

Evaluation results

For the code documentation tasks, different models achieves the following results on different programming languages (in BLEU score):

Test results :

Language / ModelPythonJavaGoPhpRubyJavaScript
CodeTrans-ST-Small17.3116.6516.8923.059.1913.7
CodeTrans-ST-Base16.8617.1717.1622.988.2313.17
CodeTrans-TF-Small19.9319.4818.8825.3513.1517.23
CodeTrans-TF-Base20.2620.1919.5025.8414.0718.25
CodeTrans-TF-Large20.3520.0619.5426.1814.9418.98
CodeTrans-MT-Small19.6419.0019.1524.6814.9115.26
CodeTrans-MT-Base20.3921.2219.4326.2315.2616.11
CodeTrans-MT-Large20.1821.8719.3826.0815.0016.23
CodeTrans-MT-TF-Small19.7720.0419.3625.5513.7017.24
CodeTrans-MT-TF-Base19.7721.1218.8625.7914.2418.62
CodeTrans-MT-TF-Large18.9421.4218.7726.2014.1918.83
State of the art19.0617.6518.0725.1612.1614.90
Created by Ahmed Elnaggar | LinkedIn and Wei Ding | LinkedIn