🚀 CodeTrans API推荐生成模型
CodeTrans是一个基于t5-small
架构的预训练模型,可用于API推荐生成。该模型在软件开发领域的多个任务上进行了训练,能为Java编程任务生成API使用建议。
🚀 快速开始
模型描述
此CodeTrans模型基于t5-small
模型构建,拥有自己的SentencePiece词汇模型。它在软件开发领域的13个有监督任务和7个无监督数据集上进行了多任务训练。
预期用途与限制
该模型可用于为Java编程任务生成API使用建议。
使用方法
以下是使用Transformers的SummarizationPipeline
来生成Java函数文档的示例代码:
from transformers import AutoTokenizer, AutoModelWithLMHead, SummarizationPipeline
pipeline = SummarizationPipeline(
model=AutoModelWithLMHead.from_pretrained("SEBIS/code_trans_t5_small_api_generation_multitask"),
tokenizer=AutoTokenizer.from_pretrained("SEBIS/code_trans_t5_small_api_generation_multitask", skip_special_tokens=True),
device=0
)
tokenized_code = "parse the uses licence node of this package , if any , and returns the license definition if theres"
pipeline([tokenized_code])
你可以在colab notebook中运行此示例。
📦 安装指南
文档未提及具体安装步骤,暂无法提供。
💻 使用示例
基础用法
from transformers import AutoTokenizer, AutoModelWithLMHead, SummarizationPipeline
pipeline = SummarizationPipeline(
model=AutoModelWithLMHead.from_pretrained("SEBIS/code_trans_t5_small_api_generation_multitask"),
tokenizer=AutoTokenizer.from_pretrained("SEBIS/code_trans_t5_small_api_generation_multitask", skip_special_tokens=True),
device=0
)
tokenized_code = "parse the uses licence node of this package , if any , and returns the license definition if theres"
pipeline([tokenized_code])
📚 详细文档
训练数据
有监督训练任务的数据集可从此处下载。
训练过程
多任务预训练
该模型在单个TPU Pod V3 - 8上进行了总共500,000步的训练,使用的序列长度为512(批量大小为4096)。
模型总共约有2.2亿个参数,采用编码器 - 解码器架构进行训练。
预训练使用的优化器是AdaFactor,并采用平方根倒数学习率调度。
评估结果
对于代码文档任务,不同模型在不同编程语言上取得了以下结果(以BLEU分数衡量):
语言 / 模型 |
Java |
CodeTrans - ST - Small |
68.71 |
CodeTrans - ST - Base |
70.45 |
CodeTrans - TF - Small |
68.90 |
CodeTrans - TF - Base |
72.11 |
CodeTrans - TF - Large |
73.26 |
CodeTrans - MT - Small |
58.43 |
CodeTrans - MT - Base |
67.97 |
CodeTrans - MT - Large |
72.29 |
CodeTrans - MT - TF - Small |
69.29 |
CodeTrans - MT - TF - Base |
72.89 |
CodeTrans - MT - TF - Large |
73.39 |
现有最优模型 |
54.42 |
🔧 技术细节
模型基于t5-small
架构,使用SentencePiece词汇模型,在多个有监督和无监督数据集上进行多任务训练。采用编码器 - 解码器架构,使用AdaFactor优化器和平方根倒数学习率调度进行预训练。
📄 许可证
文档未提及许可证信息,暂无法提供。
Created by Ahmed Elnaggar | LinkedIn and Wei Ding | LinkedIn