razent commited on
Commit
8ce4eb8
1 Parent(s): 4f9c332

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +53 -0
README.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CoText (1-CC)
2
+
3
+ ## Introduction
4
+ Paper: [CoTexT: Multi-task Learning with Code-Text Transformer](https://aclanthology.org/2021.nlp4prog-1.5.pdf)
5
+
6
+ Authors: _Long Phan, Hieu Tran, Daniel Le, Hieu Nguyen, James Anibal, Alec Peltekian, Yanfang Ye_
7
+
8
+ ## How to use
9
+ For more details, do check out [our Github repo](https://github.com/justinphan3110/CoTexT).
10
+ ```python
11
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
12
+
13
+ tokenizer = AutoTokenizer.from_pretrained("razent/cotext-1-cc")
14
+ model = AutoModelForSeq2SeqLM.from_pretrained("razent/cotext-1-cc")
15
+
16
+ sentence = "def add(a, b): return a + b"
17
+ text = "python: " + sentence + " </s>"
18
+
19
+ encoding = tokenizer.encode_plus(text, pad_to_max_length=True, return_tensors="pt")
20
+ input_ids, attention_masks = encoding["input_ids"].to("cuda"), encoding["attention_mask"].to("cuda")
21
+
22
+ outputs = model.generate(
23
+ input_ids=input_ids, attention_mask=attention_masks,
24
+ max_length=256,
25
+ early_stopping=True
26
+ )
27
+
28
+ for output in outputs:
29
+ line = tokenizer.decode(output, skip_special_tokens=True, clean_up_tokenization_spaces=True)
30
+ print(line)
31
+ ```
32
+
33
+ ## Citation
34
+ ```
35
+ @inproceedings{phan-etal-2021-cotext,
36
+ title = "{C}o{T}ex{T}: Multi-task Learning with Code-Text Transformer",
37
+ author = "Phan, Long and
38
+ Tran, Hieu and
39
+ Le, Daniel and
40
+ Nguyen, Hieu and
41
+ Annibal, James and
42
+ Peltekian, Alec and
43
+ Ye, Yanfang",
44
+ booktitle = "Proceedings of the 1st Workshop on Natural Language Processing for Programming (NLP4Prog 2021)",
45
+ month = aug,
46
+ year = "2021",
47
+ address = "Online",
48
+ publisher = "Association for Computational Linguistics",
49
+ url = "https://aclanthology.org/2021.nlp4prog-1.5",
50
+ doi = "10.18653/v1/2021.nlp4prog-1.5",
51
+ pages = "40--47"
52
+ }
53
+ ```