code_trans_t5_small_code_documentation_generation_php_multitask_finetune
SEBISIntroduction
The CodeTrans model is a pretrained model designed for generating documentation for PHP code, specifically using the T5 small model architecture. It is optimized for tokenized PHP code functions and is part of a broader effort to apply machine learning to software engineering tasks.
Architecture
The model is based on the T5-small architecture, using a SentencePiece vocabulary model. It employs a multi-task training approach encompassing 13 supervised tasks and 7 unsupervised datasets within the software development domain. This architecture allows the model to be fine-tuned specifically for generating documentation for PHP functions and methods.
Training
Multi-Task Pretraining
The model was pre-trained on a TPU Pod V3-8 for 500,000 steps with a sequence length of 512 and a batch size of 4096. It has approximately 220 million parameters and utilizes an encoder-decoder architecture. The AdaFactor optimizer with an inverse square root learning rate schedule was used during pre-training.
Fine-Tuning
Fine-tuning was conducted on a single TPU Pod V2-8 for 10,000 steps, focusing solely on datasets containing PHP code. The sequence length was maintained at 512 with a batch size of 256. The model demonstrated competitive results compared to state-of-the-art models across various programming languages.
Guide: Running Locally
To use the model for generating PHP function documentation, you can utilize the Transformers library's SummarizationPipeline
. Here are the basic steps:
-
Install the Transformers library and dependencies.
pip install transformers
-
Set up the model and tokenizer.
from transformers import AutoTokenizer, AutoModelWithLMHead, SummarizationPipeline pipeline = SummarizationPipeline( model=AutoModelWithLMHead.from_pretrained("SEBIS/code_trans_t5_small_code_documentation_generation_php_multitask_finetune"), tokenizer=AutoTokenizer.from_pretrained("SEBIS/code_trans_t5_small_code_documentation_generation_php_multitask_finetune", skip_special_tokens=True), device=0 )
-
Run the pipeline on tokenized PHP code.
tokenized_code = "public static function update ( $ table ) { ... }" print(pipeline([tokenized_code]))
For optimal performance, consider using cloud-based GPU services such as Google Colab or AWS EC2 with GPU instances.
License
The model and associated code are subject to the licensing terms provided in the original repository. Ensure compliance with these terms when using or distributing the model.