Downloads · 30 days
106
4% of all-time downloads
cvnberk/solidity-generator
solidity-generator is a text generation model from cvnberk. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This model is a model specialized in generating Solidity contract codes. Derived from the codeparrot/codeparrot-small model, it's been meticulously trained on an extensive set of Solidity contracts and patterns, makin…
Downloads · 30 days
106
4% of all-time downloads
All-time downloads
3K
Public
Repo size
6.5 GB
Likes
10
Public
Click a slice to open those files.
.bin444 MB · 100%
From the Hugging Face model README
This model is a model specialized in generating Solidity contract codes. Derived from the codeparrot/codeparrot-small model, it's been meticulously trained on an extensive set of Solidity contracts and patterns, making it apt for assisting in drafting or suggesting contract structures.
This model has been designed specifically for generating Solidity contracts. Being a derivative of the codeparrot-small model, it retains the broader capabilities of the parent model while demonstrating a keen proficiency in understanding and generating Solidity-centric texts.
The model reported a loss of 0.2180 on the evaluation set.
The model was fine-tuned on mwritescode/slither-audited-smart-contracts dataset comprised of a range of Solidity contracts.
More information needed
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 0.302 | 0.35 | 2000 | 0.3237 |
| 0.298 | 0.69 | 4000 | 0.2871 |
| 0.232 | 1.04 | 6000 | 0.2645 |
| 0.2415 | 1.38 | 8000 | 0.2522 |
| 0.2261 | 1.73 | 10000 | 0.2431 |
| 0.1924 | 2.07 | 12000 | 0.2332 |
| 0.1913 | 2.42 | 14000 | 0.2282 |
| 0.2152 | 2.76 | 16000 | 0.2215 |
| 0.1508 | 3.11 | 18000 | 0.2180 |
If you wish to use this model to generate Solidity contract code, follow the steps below:
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load the model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("ckandemir/solidity_generator")
model = AutoModelForCausalLM.from_pretrained("ckandemir/solidity_generator")
# Input your code prompt
input_text = "contract MyToken is ERC20{"
input_ids = tokenizer.encode(input_text, return_tensors='pt')
sample_output = model.generate(input_ids, do_sample=True, max_length=400, num_return_sequences=1, temperature=0.7)
# Decode and print the generated text
generated_text = tokenizer.decode(sample_output[0], skip_special_tokens=True)
print(generated_text)