devilyouwei
commited on
Commit
·
cb50f6a
1
Parent(s):
d953b06
init SmartBERT V3 model
Browse files- README.md +65 -3
- config.json +28 -0
- merges.txt +0 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +9 -0
- tokenizer_config.json +63 -0
- training_args.bin +3 -0
- vocab.json +0 -0
README.md
CHANGED
@@ -1,3 +1,65 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
base_model:
|
6 |
+
- microsoft/codebert-base-mlm
|
7 |
+
pipeline_tag: sentence-similarity
|
8 |
+
tags:
|
9 |
+
- smart-contract
|
10 |
+
- web3
|
11 |
+
- software-engineering
|
12 |
+
- embedding
|
13 |
+
- codebert
|
14 |
+
---
|
15 |
+
|
16 |
+
# SmartBERT V3 CodeBERT
|
17 |
+
|
18 |
+
![SmartBERT](./framework.png)
|
19 |
+
|
20 |
+
## Overview
|
21 |
+
|
22 |
+
**SmartBERT V3** is a pre-trained programming language model, initialized with **[CodeBERT-base-mlm](https://huggingface.co/microsoft/codebert-base-mlm)**. It has been further trained on [SmartBERT V2](https://huggingface.co/web3se/SmartBERT-v2) with an additional **64,000** smart contracts, to enhance its robustness in representing smart contract code at the _function_ level.
|
23 |
+
|
24 |
+
- **Training Data:** Trained on a total of **80,000** smart contracts, including **16,000** from [SmartBERT V2](https://huggingface.co/web3se/SmartBERT-v2) and **64,000** (starts from 30001) new contracts.
|
25 |
+
- **Hardware:** Utilized 2 Nvidia A100 80G GPUs.
|
26 |
+
- **Training Duration:** Over 30 hours.
|
27 |
+
- **Evaluation Data:** Evaluated on **1,500** (starts from 96425) smart contracts.
|
28 |
+
|
29 |
+
## Preprocessing
|
30 |
+
|
31 |
+
All newline (`\n`) and tab (`\t`) characters in the _function_ code were replaced with a single space to ensure consistency in the input data format.
|
32 |
+
|
33 |
+
## Base Model
|
34 |
+
|
35 |
+
- **Original Model**: [CodeBERT-base-mlm](https://huggingface.co/microsoft/codebert-base-mlm)
|
36 |
+
|
37 |
+
## Training Setup
|
38 |
+
|
39 |
+
```python
|
40 |
+
training_args = TrainingArguments(
|
41 |
+
output_dir=OUTPUT_DIR,
|
42 |
+
overwrite_output_dir=True,
|
43 |
+
num_train_epochs=20,
|
44 |
+
per_device_train_batch_size=64,
|
45 |
+
save_steps=10000,
|
46 |
+
save_total_limit=2,
|
47 |
+
evaluation_strategy="steps",
|
48 |
+
eval_steps=10000,
|
49 |
+
resume_from_checkpoint=checkpoint
|
50 |
+
)
|
51 |
+
```
|
52 |
+
|
53 |
+
## How to Use
|
54 |
+
|
55 |
+
To train and deploy the SmartBERT V3 model for Web API services, please refer to our GitHub repository: [web3se-lab/SmartBERT](https://github.com/web3se-lab/SmartBERT).
|
56 |
+
|
57 |
+
## Contributors
|
58 |
+
|
59 |
+
- [Youwei Huang](https://www.devil.ren)
|
60 |
+
- [Sen Fang](https://github.com/TomasAndersonFang)
|
61 |
+
|
62 |
+
## Sponsors
|
63 |
+
|
64 |
+
- [Institute of Intelligent Computing Technology, Suzhou, CAS](http://iict.ac.cn/)
|
65 |
+
- CAS Mino (中科劢诺)
|
config.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "./model/SmartBERT-codebert-16000",
|
3 |
+
"architectures": [
|
4 |
+
"RobertaForMaskedLM"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"bos_token_id": 0,
|
8 |
+
"classifier_dropout": null,
|
9 |
+
"eos_token_id": 2,
|
10 |
+
"hidden_act": "gelu",
|
11 |
+
"hidden_dropout_prob": 0.1,
|
12 |
+
"hidden_size": 768,
|
13 |
+
"initializer_range": 0.02,
|
14 |
+
"intermediate_size": 3072,
|
15 |
+
"layer_norm_eps": 1e-05,
|
16 |
+
"max_position_embeddings": 514,
|
17 |
+
"model_type": "roberta",
|
18 |
+
"num_attention_heads": 12,
|
19 |
+
"num_hidden_layers": 12,
|
20 |
+
"output_past": true,
|
21 |
+
"pad_token_id": 1,
|
22 |
+
"position_embedding_type": "absolute",
|
23 |
+
"torch_dtype": "float32",
|
24 |
+
"transformers_version": "4.28.1",
|
25 |
+
"type_vocab_size": 1,
|
26 |
+
"use_cache": true,
|
27 |
+
"vocab_size": 50265
|
28 |
+
}
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ee606e09af427f20e264da959fb9162a8fbce455fc921296294cfefd88bfe46a
|
3 |
+
size 498863862
|
special_tokens_map.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"eos_token": "</s>",
|
5 |
+
"mask_token": "<mask>",
|
6 |
+
"pad_token": "<pad>",
|
7 |
+
"sep_token": "</s>",
|
8 |
+
"unk_token": "<unk>"
|
9 |
+
}
|
tokenizer_config.json
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_prefix_space": false,
|
3 |
+
"bos_token": {
|
4 |
+
"__type": "AddedToken",
|
5 |
+
"content": "<s>",
|
6 |
+
"lstrip": false,
|
7 |
+
"normalized": true,
|
8 |
+
"rstrip": false,
|
9 |
+
"single_word": false
|
10 |
+
},
|
11 |
+
"clean_up_tokenization_spaces": true,
|
12 |
+
"cls_token": {
|
13 |
+
"__type": "AddedToken",
|
14 |
+
"content": "<s>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": true,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false
|
19 |
+
},
|
20 |
+
"eos_token": {
|
21 |
+
"__type": "AddedToken",
|
22 |
+
"content": "</s>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": true,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false
|
27 |
+
},
|
28 |
+
"errors": "replace",
|
29 |
+
"mask_token": {
|
30 |
+
"__type": "AddedToken",
|
31 |
+
"content": "<mask>",
|
32 |
+
"lstrip": true,
|
33 |
+
"normalized": true,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
},
|
37 |
+
"model_max_length": 512,
|
38 |
+
"pad_token": {
|
39 |
+
"__type": "AddedToken",
|
40 |
+
"content": "<pad>",
|
41 |
+
"lstrip": false,
|
42 |
+
"normalized": true,
|
43 |
+
"rstrip": false,
|
44 |
+
"single_word": false
|
45 |
+
},
|
46 |
+
"sep_token": {
|
47 |
+
"__type": "AddedToken",
|
48 |
+
"content": "</s>",
|
49 |
+
"lstrip": false,
|
50 |
+
"normalized": true,
|
51 |
+
"rstrip": false,
|
52 |
+
"single_word": false
|
53 |
+
},
|
54 |
+
"tokenizer_class": "RobertaTokenizer",
|
55 |
+
"unk_token": {
|
56 |
+
"__type": "AddedToken",
|
57 |
+
"content": "<unk>",
|
58 |
+
"lstrip": false,
|
59 |
+
"normalized": true,
|
60 |
+
"rstrip": false,
|
61 |
+
"single_word": false
|
62 |
+
}
|
63 |
+
}
|
training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3ea7957e5a22d9aa5348c6d1d7a5784773db403329029e673c3d9ea3bb2a1b34
|
3 |
+
size 4024
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|