CodeBertForCodeTrans
This model is a fine-tuned version of microsoft/codebert-base on an unknown dataset. It achieves the following results on the evaluation set:
- Loss: 0.0006
Model description
More information needed
Driectly uses
from transformers import AutoTokenizer, AutoModelForCausalLM
additional_special_tokens = {'additional_special_tokens':['<|begin_of_java_code|>','<|end_of_java_code|>'\
,'<|begin_of_c-sharp_code|>','<|end_of_c-sharp_code|>',\
'<|translate|>']}
basemodel = "ljcnju/CodeBertForCodeTrans"
tokenizer = AutoTokenizer.from_pretrained(basemodel)
tokenizer.pad_token = tokenizer.eos_token
config = AutoConfig.from_pretrained(basemodel)
config.is_decoder = True
model = AutoModelForCausalLM.from_pretrained(basemodel,config=config)
device = torch.device("cuda") if torch.cuda.is_available() else torch.device('cpu')
model.to(device)
code = "public void serialize(LittleEndianOutput out) {out.writeShort(field_1_vcenter);}\n"
prefix = additional_special_tokens['additional_special_tokens'][0]
input_str = prefix + code +additional_special_tokens['additional_special_tokens'][1] + additional_special_tokens['additional_special_tokens'][2]
input = tokenizer(input_str,return_tensors = "pt")
output = model.generate(**input, max_length = 256)
outputs_str = tokenizer.decode(output[0])
print(outputs_str)
More information needed
Training and evaluation data
More information needed
Training procedure
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 16
- eval_batch_size: 16
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- lr_scheduler_warmup_steps: 12354.0
- num_epochs: 20
- mixed_precision_training: Native AMP
Training results
Training Loss | Epoch | Step | Validation Loss |
---|---|---|---|
5.7169 | 1.0 | 644 | 4.5075 |
3.0571 | 2.0 | 1288 | 2.1423 |
0.7391 | 3.0 | 1932 | 0.2866 |
0.1028 | 4.0 | 2576 | 0.0219 |
0.0158 | 5.0 | 3220 | 0.0047 |
0.0065 | 6.0 | 3864 | 0.0024 |
0.0036 | 7.0 | 4508 | 0.0020 |
0.0028 | 8.0 | 5152 | 0.0014 |
0.0018 | 9.0 | 5796 | 0.0010 |
0.0023 | 10.0 | 6440 | 0.0017 |
0.002 | 11.0 | 7084 | 0.0009 |
0.002 | 12.0 | 7728 | 0.0012 |
0.0015 | 13.0 | 8372 | 0.0020 |
0.0028 | 14.0 | 9016 | 0.0010 |
0.0015 | 15.0 | 9660 | 0.0007 |
0.0027 | 16.0 | 10304 | 0.0015 |
0.002 | 17.0 | 10948 | 0.0007 |
0.0011 | 18.0 | 11592 | 0.0009 |
0.0019 | 19.0 | 12236 | 0.0007 |
0.0003 | 20.0 | 12880 | 0.0006 |
Framework versions
- Transformers 4.37.2
- Pytorch 2.1.2+cu121
- Datasets 2.15.0
- Tokenizers 0.15.0
- Downloads last month
- 64
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.
Model tree for ljcnju/CodeBertForCodeTrans
Base model
microsoft/codebert-base