Run this model with HF Jobs
Run antolin/distilroberta-base-csn-python-bimodal on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/antolin/distilroberta-base-csn-python-bimodal. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/antolin/distilroberta-base-csn-python-bimodal on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use antolin/distilroberta-base-csn-python-bimodal with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use antolin/distilroberta-base-csn-python-bimodal with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="antolin/distilroberta-base-csn-python-bimodal")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("antolin/distilroberta-base-csn-python-bimodal") model = AutoModelForMaskedLM.from_pretrained("antolin/distilroberta-base-csn-python-bimodal", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Model Architecture
This model follows the distilroberta-base architecture. Futhermore, this model was initialized with the checkpoint of distilroberta-base.
Pre-training phase
This model was pre-trained with the MLM objective (mlm_probability=0.15).
During this phase, the inputs had the following format: where $t_1, \dots, t_n$ are the code tokens and $w_1, \dots, w_m$ are the natural language description tokens. More concretely, this is the snippet that tokenizes the input:
def tokenize_function_bimodal(examples, tokenizer, max_len):
codes = [' '.join(example) for example in examples['func_code_tokens']]
nls = [' '.join(example) for example in examples['func_documentation_tokens']]
pairs = [[c, nl] for c, nl in zip(codes, nls)]
return tokenizer(pairs, max_length=max_len, padding="max_length", truncation=True)
Training details
- Max length: 512
- Effective batch size: 64
- Total steps: 60000
- Learning rate: 5e-4
Usage
model = AutoModelForMaskedLM.from_pretrained('antolin/distilroberta-base-csn-python-bimodal')
tokenizer = AutoTokenizer.from_pretrained('antolin/distilroberta-base-csn-python-bimodal')
mask_filler = pipeline("fill-mask", model=model, tokenizer=tokenizer)
code_tokens = ["def", "<mask>", "(", "a", ",", "b", ")", ":", "if", "a", ">", "b", ":", "return", "a", "else", "return", "b"]
nl_tokens = ["return", "the", "maximum", "value"]
input_text = ' '.join(code_tokens) + tokenizer.sep_token + ' '.join(nl_tokens)
pprint(mask_filler(input_text, top_k=5))
[{'score': 0.4645618796348572,
'sequence': 'def max ( a, b ) : if a > b : return a else return b return '
'the maximum value',
'token': 19220,
'token_str': ' max'},
{'score': 0.40963634848594666,
'sequence': 'def maximum ( a, b ) : if a > b : return a else return b '
'return the maximum value',
'token': 4532,
'token_str': ' maximum'},
{'score': 0.02103462442755699,
'sequence': 'def min ( a, b ) : if a > b : return a else return b return '
'the maximum value',
'token': 5251,
'token_str': ' min'},
{'score': 0.014217409305274487,
'sequence': 'def value ( a, b ) : if a > b : return a else return b return '
'the maximum value',
'token': 923,
'token_str': ' value'},
{'score': 0.010762304067611694,
'sequence': 'def minimum ( a, b ) : if a > b : return a else return b '
'return the maximum value',
'token': 3527,
'token_str': ' minimum'}]
- Downloads last month
- 32
Dataset used to train antolin/distilroberta-base-csn-python-bimodal
Viewer • Updated • 4.14M • 73.9k • 344