google/code_x_glue_ct_code_to_text
Viewer • Updated • 1.01M • 5.77k • 79
Run nielsr/codet5-small-code-summarization-ruby 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:
Use HF Jobs to fine-tune https://huggingface.co/nielsr/codet5-small-code-summarization-ruby. 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.
Use HF Jobs to run batch inference with https://huggingface.co/nielsr/codet5-small-code-summarization-ruby 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.
How to use nielsr/codet5-small-code-summarization-ruby with Transformers:
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("nielsr/codet5-small-code-summarization-ruby")
model = AutoModelForSeq2SeqLM.from_pretrained("nielsr/codet5-small-code-summarization-ruby", device_map="auto")CodeT5-small model, fine-tuned on the code summarization subtask of CodeXGLUE (Ruby programming language). This model can generate a docstring of a given function written in Ruby.
The notebook that I used to fine-tune CodeT5 can be found here.
Here's how to use this model:
from transformers import RobertaTokenizer, T5ForConditionalGeneration
model_name = "nielsr/codet5-small-code-summarization-ruby"
tokenizer = RobertaTokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)
code = """
def update_with_file_contents(digest, filename)
File.open(filename) do |io|
while (chunk = io.read(1024 * 8))
digest.update(chunk)
end
end
end
"""
input_ids = tokenizer(code, return_tensors="pt").input_ids
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# Update the digest with the contents of the given file