nielsr HF staff commited on
Commit
b2220b1
·
1 Parent(s): 338c3a3

Add model card

Browse files
Files changed (1) hide show
  1. README.md +30 -0
README.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Description
2
+
3
+ CodeT5-small model, fine-tuned on the code summarization subtask of CodeXGLUE (Ruby programming language).
4
+
5
+ # Usage
6
+
7
+ Here's how to use this model:
8
+
9
+ ```python
10
+ from transformers import RobertaTokenizer, T5ForConditionalGeneration
11
+
12
+ model_name = "nielsr/codet5-small-code-summarization-ruby"
13
+ tokenizer = RobertaTokenizer.from_pretrained(model_name)
14
+ model = T5ForConditionalGeneration.from_pretrained(model_name)
15
+
16
+ code = """
17
+ def update_with_file_contents(digest, filename)
18
+ File.open(filename) do |io|
19
+ while (chunk = io.read(1024 * 8))
20
+ digest.update(chunk)
21
+ end
22
+ end
23
+ end
24
+ """
25
+
26
+ input_ids = tokenizer(code, return_tensors="pt").input_ids
27
+ outputs = model.generate(input_ids)
28
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
29
+ # Update the digest with the contents of the given file
30
+ ```