??中国語|

CodeasSistは、Python、Java、C ++などに高品質のコード完了をインテリジェントに提供する高度なコード完了ツールです。
CodeasSistは、Python、Java、C ++などのプログラミング言語のコードを完成させる高品質のコード完了ツールです。
Python 、 Java 、 C++ 、 javascriptなどのコード完了| アーチ | ベースモデル | モデル | モデルサイズ |
|---|---|---|---|
| gpt | GPT2 | Shibing624/code-autocomplete-gpt2-base | 487MB |
| gpt | distilgpt2 | Shibing624/code-autocomplete-distilgpt2-python | 319MB |
| gpt | BigCode/StarCoder | wizardlm/wizardcoder-15b-v1.0 | 29GB |
Huggingfaceデモ:https://huggingface.co/spaces/shibing624/code-autocomplete
バックエンドモデル: shibing624/code-autocomplete-gpt2-base
pip install torch # conda install pytorch
pip install -U codeassistまたは
git clone https://github.com/shibing624/codeassist.git
cd CodeAssist
python setup.py installWizardCoder-15Bは、ALPACAコードデータを備えた微調整されたbigcode/starcoderです。次のコードを使用してコードを生成できます。
例:例/wizardcoder_demo.py
import sys
sys . path . append ( '..' )
from codeassist import WizardCoder
m = WizardCoder ( "WizardLM/WizardCoder-15B-V1.0" )
print ( m . generate ( 'def load_csv_file(file_path):' )[ 0 ])出力:
import csv
def load_csv_file ( file_path ):
"""
Load data from a CSV file and return a list of dictionaries.
"""
# Open the file in read mode
with open ( file_path , 'r' ) as file :
# Create a CSV reader object
csv_reader = csv . DictReader ( file )
# Initialize an empty list to store the data
data = []
# Iterate over each row of data
for row in csv_reader :
# Append the row of data to the list
data . append ( row )
# Return the list of data
return dataモデル出力は印象的に効果的であり、現在英語と中国語の入力をサポートしており、必要に応じて手順またはコードプレフィックスを入力できます。
Distilgpt2微調整コードオートコンプリートモデル、次のコードを使用できます。
例:例/distilgpt2_demo.py
import sys
sys . path . append ( '..' )
from codeassist import GPT2Coder
m = GPT2Coder ( "shibing624/code-autocomplete-distilgpt2-python" )
print ( m . generate ( 'import torch.nn as' )[ 0 ])出力:
import torch.nn as nn
import torch.nn.functional as F例:例/use_transformers_gpt2.py
例:Examples/Training_WizardCoder_MyData.py
cd examples
CUDA_VISIBLE_DEVICES=0,1 python training_wizardcoder_mydata.py --do_train --do_predict --num_epochs 1 --output_dir outputs-wizard --model_name WizardLM/WizardCoder-15B-V1.0例:Examples/Training_gpt2_mydata.py
cd examples
python training_gpt2_mydata.py --do_train --do_predict --num_epochs 15 --output_dir outputs-gpt2 --model_name gpt2PS:微調整された結果モデルはGPT2-Python:Shibing624/code-autocomplete-gpt2-baseです。V100で約24時間を費やして微調整しました。
FASTAPIサーバーを開始します:
例:例/server.py
cd examples
python server.pyオープンURL:http://0.0.0.0:8001/docs

これにより、データセットの構築をカスタマイズできます。
Awesome-Pytorch-ListのPythonコードを使用しましょう
データセットツリー:
examples/download/python
├── train.txt
└── valid.txt
└── test.txtデータセットを構築するには3つの方法があります。
from datasets import load_dataset
dataset = load_dataset ( "shibing624/source_code" , "python" ) # python or java or cpp
print ( dataset )
print ( dataset [ 'test' ][ 0 : 10 ])出力:
DatasetDict({
train: Dataset({
features: [ ' text ' ],
num_rows: 5215412
})
validation: Dataset({
features: [ ' text ' ],
num_rows: 10000
})
test: Dataset({
features: [ ' text ' ],
num_rows: 10000
})
})
{ ' text ' : [
" {'max_epochs': [1, 2]},n " ,
' refit=False,n ' , ' cv=3,n ' ,
" scoring='roc_auc',n " , ' )n ' ,
' search.fit(*data)n ' ,
' ' ,
' def test_module_output_not_1d(self, net_cls, data):n ' ,
' from skorch.toy import make_classifiern ' ,
' module = make_classifier(n '
]}| 名前 | ソース | ダウンロード | サイズ |
|---|---|---|---|
| Python+Java+CPPソースコード | Awesome-Pytorch-List(522万行) | github_source_code.zip | 105m |
データセットをダウンロードして解凍し、 examples/を掲載します。
prepare_code_data.py
cd examples
python prepare_code_data.py --num_repos 260
研究でCodeasSistを使用している場合は、次の形式で引用してください。
APA:
Xu, M. codeassist: Code AutoComplete with GPT model (Version 1.0.0) [Computer software]. https://github.com/shibing624/codeassistbibtex:
@software{Xu_codeassist,
author = {Ming Xu},
title = {CodeAssist: Code AutoComplete with Generation model},
url = {https://github.com/shibing624/codeassist},
version = {1.0.0}
}このリポジトリは、Apacheライセンス2.0に基づいてライセンスされています。
Attribution-NonCommercial 4.0 Internationalに従って、WizardCoderモデルを使用してください。
プロジェクトコードはまだ非常にラフです。
testsに対応する単体テストを追加しますpython setup.py testを使用してすべてのユニットテストを実行して、すべての単一テストが渡されるようにします後でPRを送信できます。