devilyouwei
commited on
add usage exmaple
Browse files
README.md
CHANGED
@@ -27,6 +27,21 @@ tags:
|
|
27 |
- **Training Duration:** Over 30 hours.
|
28 |
- **Evaluation Data:** Evaluated on **1,500** (starts from 96425) smart contracts.
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
## Preprocessing
|
31 |
|
32 |
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.
|
|
|
27 |
- **Training Duration:** Over 30 hours.
|
28 |
- **Evaluation Data:** Evaluated on **1,500** (starts from 96425) smart contracts.
|
29 |
|
30 |
+
## Usage
|
31 |
+
|
32 |
+
```python
|
33 |
+
from transformers import RobertaTokenizer, RobertaForMaskedLM, pipeline
|
34 |
+
|
35 |
+
model = RobertaForMaskedLM.from_pretrained('web3se/SmartBERT-v3')
|
36 |
+
tokenizer = RobertaTokenizer.from_pretrained('web3se/SmartBERT-v3')
|
37 |
+
|
38 |
+
code_example = "function totalSupply() external view <mask> (uint256);"
|
39 |
+
fill_mask = pipeline('fill-mask', model=model, tokenizer=tokenizer)
|
40 |
+
|
41 |
+
outputs = fill_mask(code_example)
|
42 |
+
print(outputs)
|
43 |
+
```
|
44 |
+
|
45 |
## Preprocessing
|
46 |
|
47 |
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.
|