gonglinyuan commited on
Commit
e91816e
1 Parent(s): 7581677

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +43 -180
README.md CHANGED
@@ -31,197 +31,60 @@ model-index:
31
  value: 0.2388758782201405
32
  ---
33
 
34
- # Model Card for Model ID
35
 
36
- <!-- Provide a quick summary of what the model is/does. -->
37
 
 
38
 
 
39
 
40
- ## Model Details
41
 
42
- ### Model Description
43
 
44
- <!-- Provide a longer summary of what this model is. -->
45
 
46
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
47
 
48
- - **Developed by:** [More Information Needed]
49
- - **Funded by [optional]:** [More Information Needed]
50
- - **Shared by [optional]:** [More Information Needed]
51
- - **Model type:** [More Information Needed]
52
- - **Language(s) (NLP):** [More Information Needed]
53
- - **License:** [More Information Needed]
54
- - **Finetuned from model [optional]:** [More Information Needed]
55
 
56
- ### Model Sources [optional]
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
- <!-- Provide the basic links for the model. -->
 
 
 
59
 
60
- - **Repository:** [More Information Needed]
61
- - **Paper [optional]:** [More Information Needed]
62
- - **Demo [optional]:** [More Information Needed]
63
 
64
- ## Uses
65
 
66
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
67
 
68
- ### Direct Use
69
-
70
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
71
-
72
- [More Information Needed]
73
-
74
- ### Downstream Use [optional]
75
-
76
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
77
-
78
- [More Information Needed]
79
-
80
- ### Out-of-Scope Use
81
-
82
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
83
-
84
- [More Information Needed]
85
-
86
- ## Bias, Risks, and Limitations
87
-
88
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
89
-
90
- [More Information Needed]
91
-
92
- ### Recommendations
93
-
94
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
95
-
96
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
97
-
98
- ## How to Get Started with the Model
99
-
100
- Use the code below to get started with the model.
101
-
102
- [More Information Needed]
103
-
104
- ## Training Details
105
-
106
- ### Training Data
107
-
108
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
109
-
110
- [More Information Needed]
111
-
112
- ### Training Procedure
113
-
114
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
115
-
116
- #### Preprocessing [optional]
117
-
118
- [More Information Needed]
119
-
120
-
121
- #### Training Hyperparameters
122
-
123
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
124
-
125
- #### Speeds, Sizes, Times [optional]
126
-
127
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
128
-
129
- [More Information Needed]
130
-
131
- ## Evaluation
132
-
133
- <!-- This section describes the evaluation protocols and provides the results. -->
134
-
135
- ### Testing Data, Factors & Metrics
136
-
137
- #### Testing Data
138
-
139
- <!-- This should link to a Dataset Card if possible. -->
140
-
141
- [More Information Needed]
142
-
143
- #### Factors
144
-
145
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
146
-
147
- [More Information Needed]
148
-
149
- #### Metrics
150
-
151
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
152
-
153
- [More Information Needed]
154
-
155
- ### Results
156
-
157
- [More Information Needed]
158
-
159
- #### Summary
160
-
161
-
162
-
163
- ## Model Examination [optional]
164
-
165
- <!-- Relevant interpretability work for the model goes here -->
166
-
167
- [More Information Needed]
168
-
169
- ## Environmental Impact
170
-
171
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
172
-
173
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
174
-
175
- - **Hardware Type:** [More Information Needed]
176
- - **Hours used:** [More Information Needed]
177
- - **Cloud Provider:** [More Information Needed]
178
- - **Compute Region:** [More Information Needed]
179
- - **Carbon Emitted:** [More Information Needed]
180
-
181
- ## Technical Specifications [optional]
182
-
183
- ### Model Architecture and Objective
184
-
185
- [More Information Needed]
186
-
187
- ### Compute Infrastructure
188
-
189
- [More Information Needed]
190
-
191
- #### Hardware
192
-
193
- [More Information Needed]
194
-
195
- #### Software
196
-
197
- [More Information Needed]
198
-
199
- ## Citation [optional]
200
-
201
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
202
-
203
- **BibTeX:**
204
-
205
- [More Information Needed]
206
-
207
- **APA:**
208
-
209
- [More Information Needed]
210
-
211
- ## Glossary [optional]
212
-
213
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
214
-
215
- [More Information Needed]
216
-
217
- ## More Information [optional]
218
-
219
- [More Information Needed]
220
-
221
- ## Model Card Authors [optional]
222
-
223
- [More Information Needed]
224
-
225
- ## Model Card Contact
226
-
227
- [More Information Needed]
 
31
  value: 0.2388758782201405
32
  ---
33
 
34
+ Official repository: https://github.com/gonglinyuan/ast_t5
35
 
36
+ # AST-T5
37
 
38
+ Paper: [AST-T5: Structure-Aware Pretraining for Code Generation and Understanding](https://arxiv.org/abs/2401.03003)
39
 
40
+ Authors: [Linyuan Gong](https://github.com/gonglinyuan), Mostafa Elhoushi, Alvin Cheung
41
 
 
42
 
43
+ ## Use the AST-T5 Model
44
 
45
+ The AST-T5 model is readily available on the Huggingface Model Hub ([https://huggingface.co/gonglinyuan/ast_t5_base](https://huggingface.co/gonglinyuan/ast_t5_base)). To use our AST-T5 model in PyTorch (Python 3.8+, PyTorch 1.12+ and transformers 4.36+ are prerequisites), refer to the code snippet below:
46
 
47
+ ```python
48
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
49
 
50
+ model = AutoModelForSeq2SeqLM.from_pretrained("gonglinyuan/ast_t5_base", trust_remote_code=True)
51
+ tokenizer = AutoTokenizer.from_pretrained("gonglinyuan/ast_t5_base", trust_remote_code=True)
 
 
 
 
 
52
 
53
+ input_text = r'''def fibonacci(n):
54
+ """return n-th fibonacci number.
55
+ fibonacci[0] = 0
56
+ fibonacci[1] = 1
57
+ """'''
58
+ inputs = tokenizer(
59
+ [input_text + "<sen001>"], # T5-style sentinel token for completion
60
+ max_length=1024,
61
+ truncation=True,
62
+ add_special_tokens=True,
63
+ return_tensors="pt"
64
+ ).input_ids
65
+ outputs = model.generate(inputs, max_length=256, do_sample=False)
66
 
67
+ output_code = tokenizer.decode(outputs[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
68
+ output_code = output_code[len("<sen001>"):] # Remove the sentinel token
69
+ print(input_text + output_code)
70
+ ```
71
 
72
+ Note: The `ast_t5_base` model is not an instruct model. It works best with specific prompts like function signatures or comments, rather than general instructions such as "Please write a code to calculate the n-th fibonacci number".
 
 
73
 
74
+ ## Citation
75
 
76
+ If you find the code and models useful for your research, please cite the following paper:
77
 
78
+ ```
79
+ @article{
80
+ ast_t5,
81
+ title={{AST}-{T}5: Structure-Aware Pretraining for Code Generation and Understanding},
82
+ url={http://arxiv.org/abs/2401.03003},
83
+ DOI={10.48550/arXiv.2401.03003},
84
+ note={arXiv:2401.03003 [cs]},
85
+ number={arXiv:2401.03003},
86
+ publisher={arXiv},
87
+ author={Gong, Linyuan and Elhoushi, Mostafa and Cheung, Alvin},
88
+ year={2024}, month=jan
89
+ }
90
+ ```