🚀 用於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 創建。