license: bsd-3-clause
CodeT5(大尺寸模型770M)
模型描述
CodeT5是基于论文《CodeT5:面向代码理解与生成的标识符感知统一预训练编码器-解码器模型》开发的编码器-解码器语言模型家族,作者为Yue Wang、Weishi Wang、Shafiq Joty和Steven C.H. Hoi。
本仓库包含的检查点标记为CodeT5-large(770M参数),源自论文《CodeRL:通过预训练模型与深度强化学习掌握代码生成》,作者为Hung Le、Yue Wang、Akhilesh Deepak Gotmare、Silvio Savarese和Steven C.H. Hoi。
训练数据
CodeT5-large在六种编程语言(Ruby/JavaScript/Go/Python/Java/PHP)的CodeSearchNet数据上进行预训练。详见论文第4.1节。
训练流程
CodeT5-large采用掩码跨度预测目标进行150轮预训练。详见论文第4.1节。
评估结果
我们在CodeXGLUE基准测试上验证了该简化策略预训练检查点的有效性。详见论文附录A.1。
使用方法
可通过T5ForConditionalGeneration
轻松加载本模型:
from transformers import AutoTokenizer, T5ForConditionalGeneration
tokenizer = AutoTokenizer.from_pretrained("Salesforce/codet5-large")
model = T5ForConditionalGeneration.from_pretrained("Salesforce/codet5-large")
text = "def greet(user): print(f'hello <extra_id_0>!')"
input_ids = tokenizer(text, return_tensors="pt").input_ids
generated_ids = model.generate(input_ids, max_length=8)
print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
伦理考量
本版本仅供支持学术论文的研究用途。我们的模型、数据集和代码并非针对所有下游用途设计或评估。强烈建议用户在部署前评估并解决可能涉及的准确性、安全性和公平性问题。我们鼓励用户考虑AI的普遍局限性,遵守适用法律,在选择应用场景时(尤其是可能显著影响人们生活、权利或安全的高风险场景)采用最佳实践。关于应用场景的进一步指导,请参阅我们的AUP和AI AUP。
BibTeX引用信息
@inproceedings{CodeT52021,
author = {Yue Wang and Weishi Wang and Shafiq R. Joty and Steven C. H. Hoi},
title = {CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation},
booktitle = {EMNLP},
pages = {8696--8708},
publisher = {Association for Computational Linguistics},
year = {2021}
}
@article{CodeRL2022
author = {Hung Le, Yue Wang, Akhilesh Deepak Gotmare, Silvio Savarese, Steven C.H. Hoi},
title = {CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learning},
journal = {arXiv preprint},
volume = {abs/2207.01780},
year = {2022}
}