🚀 用于SQL源代码摘要的CodeTrans模型
本模型基于t5-small
架构,在SQL编程语言上进行预训练,可用于生成SQL函数描述或在其他SQL代码任务上进行微调。它首次发布于 此仓库。
🚀 快速开始
本CodeTrans模型基于t5-small
模型,拥有自己的SentencePiece词汇模型,在SQL源代码摘要数据集上进行了单任务训练。该模型可用于生成SQL函数的描述,也可在其他SQL代码任务上进行微调,可处理未解析和未分词的SQL代码,但对分词后的SQL代码处理效果更佳。
✨ 主要特性
- 基于
t5-small
模型架构,拥有独立的SentencePiece词汇模型。
- 经过单任务训练,适用于SQL源代码摘要任务。
- 可处理未解析和未分词的SQL代码,对分词后的代码处理效果更好。
📦 安装指南
使用此模型时,可借助Transformers的SummarizationPipeline
来生成SQL函数文档,示例代码如下:
from transformers import AutoTokenizer, AutoModelWithLMHead, SummarizationPipeline
pipeline = SummarizationPipeline(
model=AutoModelWithLMHead.from_pretrained("SEBIS/code_trans_t5_small_source_code_summarization_sql"),
tokenizer=AutoTokenizer.from_pretrained("SEBIS/code_trans_t5_small_source_code_summarization_sql", skip_special_tokens=True),
device=0
)
tokenized_code = "select time ( col0 ) from tab0"
pipeline([tokenized_code])
你可以在 colab notebook 中运行此示例。
💻 使用示例
基础用法
from transformers import AutoTokenizer, AutoModelWithLMHead, SummarizationPipeline
pipeline = SummarizationPipeline(
model=AutoModelWithLMHead.from_pretrained("SEBIS/code_trans_t5_small_source_code_summarization_sql"),
tokenizer=AutoTokenizer.from_pretrained("SEBIS/code_trans_t5_small_source_code_summarization_sql", skip_special_tokens=True),
device=0
)
tokenized_code = "select time ( col0 ) from tab0"
pipeline([tokenized_code])
📚 详细文档
模型描述
此CodeTrans模型基于t5-small
模型,具备自己的SentencePiece词汇模型,在SQL源代码摘要数据集上进行了单任务训练。
预期用途与限制
该模型可用于生成SQL函数的描述,或在其他SQL代码任务上进行微调。它能处理未解析和未分词的SQL代码,但如果SQL代码经过分词处理,性能会更好。
训练数据
有监督的训练任务数据集可从 此处 下载。
评估结果
对于源代码摘要任务,不同模型在不同编程语言上的评估结果(BLEU分数)如下:
语言 / 模型 |
Python |
SQL |
C# |
CodeTrans - ST - Small |
8.45 |
17.55 |
19.74 |
CodeTrans - ST - Base |
9.12 |
15.00 |
18.65 |
CodeTrans - TF - Small |
10.06 |
17.71 |
20.40 |
CodeTrans - TF - Base |
10.94 |
17.66 |
21.12 |
CodeTrans - TF - Large |
12.41 |
18.40 |
21.43 |
CodeTrans - MT - Small |
13.11 |
19.15 |
22.39 |
CodeTrans - MT - Base |
13.37 |
19.24 |
23.20 |
CodeTrans - MT - Large |
13.24 |
19.40 |
23.57 |
CodeTrans - MT - TF - Small |
12.10 |
18.25 |
22.03 |
CodeTrans - MT - TF - Base |
10.64 |
16.91 |
21.40 |
CodeTrans - MT - TF - Large |
12.14 |
19.98 |
21.10 |
CODE - NN |
-- |
18.40 |
20.50 |
由 Ahmed Elnaggar | LinkedIn 和 Wei Ding | LinkedIn 创建。