🚀 CodeTrans模型用於程序合成
CodeTrans模型基於t5基礎模型架構,在受Lisp啟發的領域特定語言(DSL)編程上進行預訓練。它能根據自然語言描述生成相應的代碼,為程序合成任務提供了高效的解決方案。
🚀 快速開始
本模型可用於根據自然語言描述生成受Lisp啟發的DSL代碼。以下是使用Transformers的SummarizationPipeline
調用該模型的示例:
from transformers import AutoTokenizer, AutoModelWithLMHead, SummarizationPipeline
pipeline = SummarizationPipeline(
model=AutoModelWithLMHead.from_pretrained("SEBIS/code_trans_t5_base_program_synthese"),
tokenizer=AutoTokenizer.from_pretrained("SEBIS/code_trans_t5_base_program_synthese", skip_special_tokens=True),
device=0
)
tokenized_code = "you are given an array of numbers a and a number b , compute the difference of elements in a and b"
pipeline([tokenized_code])
你可以在colab notebook中運行此示例。
✨ 主要特性
- 基於
t5-base
架構:利用了t5-base
模型的強大語言理解和生成能力。
- 獨立的詞彙模型:擁有自己的SentencePiece詞彙模型,更適配特定的編程任務。
- 單任務訓練:在程序合成數據集上進行單任務訓練,專注於代碼生成能力。
📚 詳細文檔
模型描述
此CodeTrans模型基於t5-base
模型構建,擁有獨立的SentencePiece詞彙模型,並在程序合成數據集上進行了單任務訓練。
預期用途與限制
該模型可根據自然語言描述的任務生成受Lisp啟發的DSL代碼。
📦 安裝指南
文檔未提及具體安裝步驟,你可參考原項目倉庫 CodeTrans 進行安裝。
💻 使用示例
基礎用法
from transformers import AutoTokenizer, AutoModelWithLMHead, SummarizationPipeline
pipeline = SummarizationPipeline(
model=AutoModelWithLMHead.from_pretrained("SEBIS/code_trans_t5_base_program_synthese"),
tokenizer=AutoTokenizer.from_pretrained("SEBIS/code_trans_t5_base_program_synthese", skip_special_tokens=True),
device=0
)
tokenized_code = "you are given an array of numbers a and a number b , compute the difference of elements in a and b"
pipeline([tokenized_code])
🔧 技術細節
本模型基於t5-base
架構,使用SentencePiece構建詞彙模型,並在程序合成數據集上進行單任務訓練,以實現根據自然語言描述生成代碼的功能。
📄 許可證
文檔未提及相關許可證信息。
📦 訓練數據
有監督的訓練任務數據集可從 此處 下載。
📊 評估結果
對於代碼文檔任務,不同模型在不同編程語言上的測試結果(以BLEU分數衡量)如下:
語言 / 模型 |
LISP |
CodeTrans - ST - Small |
89.43 |
CodeTrans - ST - Base |
89.65 |
CodeTrans - TF - Small |
90.30 |
CodeTrans - TF - Base |
90.24 |
CodeTrans - TF - Large |
90.21 |
CodeTrans - MT - Small |
82.88 |
CodeTrans - MT - Base |
86.99 |
CodeTrans - MT - Large |
90.27 |
CodeTrans - MT - TF - Small |
90.31 |
CodeTrans - MT - TF - Base |
90.30 |
CodeTrans - MT - TF - Large |
90.17 |
現有最優模型 |
85.80 |
由 Ahmed Elnaggar | LinkedIn 和 Wei Ding | LinkedIn 創建