alsubari commited on
Commit
41d030c
1 Parent(s): b5f954e

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +240 -0
README.md ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - ar
4
+ pipeline_tag: text-generation
5
+ ---
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+ This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Shared by [optional]:** [More Information Needed]
22
+ - **Model type:** [More Information Needed]
23
+ - **Language(s) (NLP):** [More Information Needed]
24
+ - **License:** [More Information Needed]
25
+ - **Finetuned from model [optional]:** [More Information Needed]
26
+
27
+ ### Model Sources [optional]
28
+
29
+ <!-- Provide the basic links for the model. -->
30
+
31
+ - **Repository:** [More Information Needed]
32
+ - **Paper [optional]:** [More Information Needed]
33
+ - **Demo [optional]:** [More Information Needed]
34
+
35
+ ## Uses
36
+
37
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
38
+
39
+ ### Direct Use
40
+
41
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
42
+
43
+ [More Information Needed]
44
+
45
+ ### Downstream Use [optional]
46
+
47
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
48
+
49
+ [More Information Needed]
50
+
51
+ ### Out-of-Scope Use
52
+
53
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
54
+
55
+ [More Information Needed]
56
+
57
+ ## Bias, Risks, and Limitations
58
+
59
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
60
+
61
+ [More Information Needed]
62
+
63
+ ### Recommendations
64
+
65
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
66
+
67
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
68
+
69
+ ## How to Get Started with the Model
70
+
71
+ Use the code below to get started with the model.
72
+ from transformers import GPT2Tokenizer
73
+ from arabert.preprocess import ArabertPreprocessor
74
+ from arabert.aragpt2.grover.modeling_gpt2 import GPT2LMHeadModel
75
+ from pyarabic.araby import strip_tashkeel
76
+ import pyarabic.trans
77
+ model_name='alsubari/aragpt2-mega-pos-msa'
78
+
79
+
80
+ tokenizer = GPT2Tokenizer.from_pretrained('alsubari/aragpt2-mega-pos-msa')
81
+ model = GPT2LMHeadModel.from_pretrained('alsubari/aragpt2-mega-pos-msa').to("cuda")
82
+
83
+ arabert_prep = ArabertPreprocessor(model_name='aubmindlab/aragpt2-mega')
84
+ prml=['اعراب الجملة :', ' صنف الكلمات من الجملة :']
85
+ text='تعلَّمْ من أخطائِكَ'
86
+ text=arabert_prep.preprocess(strip_tashkeel(text))
87
+ generation_args = {
88
+ 'pad_token_id':tokenizer.eos_token_id,
89
+ 'max_length': 256,
90
+ 'num_beams':20,
91
+ 'no_repeat_ngram_size': 3,
92
+ 'top_k': 20,
93
+ 'top_p': 0.1, # Consider all tokens with non-zero probability
94
+ 'do_sample': True,
95
+ 'repetition_penalty':2.0
96
+ }
97
+ input_text = f'<|startoftext|>Instruction: {prml[1]} {text}<|pad|>Answer:'
98
+ input_ids = tokenizer.encode(input_text, return_tensors='pt').to("cuda")
99
+ output_ids = model.generate(input_ids=input_ids,**generation_args)
100
+ output_text = tokenizer.decode(output_ids[0],skip_special_tokens=True).split('Answer:')[1]
101
+ answer_pose=pyarabic.trans.delimite_language(output_text, start="<token>", end="</token>")
102
+
103
+ print(answer_pose)
104
+ ## <token>تعلم : تعلم</token> : Verb <token>من : من</token> : Relative pronoun <token>أخطائك : اخطا</token> : Noun <token>ك</token> : Personal pronunction
105
+
106
+ input_text = f'<|startoftext|>Instruction: {prml[0]} {text}<|pad|>Answer:'
107
+ input_ids = tokenizer.encode(input_text, return_tensors='pt').to("cuda")
108
+ output_ids = model.generate(input_ids=input_ids,**generation_args)
109
+ output_text = tokenizer.decode(output_ids[0],skip_special_tokens=True).split('Answer:')[1]
110
+
111
+ print(output_text)
112
+ ##تعلم : تعلم : فعل ، مفرد المخاطب للمذكر ، فعل مضارع ، مرفوع من : من : حرف جر أخطائك : اخطا : اسم ، جمع المذكر ، مجرور ك : ضمير ، مفرد المتكلم
113
+ [More Information Needed]
114
+
115
+ ## Training Details
116
+
117
+ ### Training Data
118
+
119
+ <!-- This should link to a Data 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. -->
120
+
121
+ [More Information Needed]
122
+
123
+ ### Training Procedure
124
+
125
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
126
+
127
+ #### Preprocessing [optional]
128
+
129
+ [More Information Needed]
130
+
131
+
132
+ #### Training Hyperparameters
133
+
134
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
135
+
136
+ #### Speeds, Sizes, Times [optional]
137
+
138
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
139
+
140
+ [More Information Needed]
141
+
142
+ ## Evaluation
143
+
144
+ <!-- This section describes the evaluation protocols and provides the results. -->
145
+
146
+ ### Testing Data, Factors & Metrics
147
+
148
+ #### Testing Data
149
+
150
+ <!-- This should link to a Data Card if possible. -->
151
+
152
+ [More Information Needed]
153
+
154
+ #### Factors
155
+
156
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
157
+
158
+ [More Information Needed]
159
+
160
+ #### Metrics
161
+
162
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
163
+
164
+ [More Information Needed]
165
+
166
+ ### Results
167
+
168
+ [More Information Needed]
169
+
170
+ #### Summary
171
+
172
+
173
+
174
+ ## Model Examination [optional]
175
+
176
+ <!-- Relevant interpretability work for the model goes here -->
177
+
178
+ [More Information Needed]
179
+
180
+ ## Environmental Impact
181
+
182
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
183
+
184
+ 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).
185
+
186
+ - **Hardware Type:** [More Information Needed]
187
+ - **Hours used:** [More Information Needed]
188
+ - **Cloud Provider:** [More Information Needed]
189
+ - **Compute Region:** [More Information Needed]
190
+ - **Carbon Emitted:** [More Information Needed]
191
+
192
+ ## Technical Specifications [optional]
193
+
194
+ ### Model Architecture and Objective
195
+
196
+ [More Information Needed]
197
+
198
+ ### Compute Infrastructure
199
+
200
+ [More Information Needed]
201
+
202
+ #### Hardware
203
+
204
+ [More Information Needed]
205
+
206
+ #### Software
207
+
208
+ [More Information Needed]
209
+
210
+ ## Citation [optional]
211
+
212
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
213
+
214
+ **BibTeX:**
215
+
216
+ [More Information Needed]
217
+
218
+ **APA:**
219
+
220
+ [More Information Needed]
221
+
222
+ ## Glossary [optional]
223
+
224
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
225
+
226
+ [More Information Needed]
227
+
228
+ ## More Information [optional]
229
+
230
+ [More Information Needed]
231
+
232
+ ## Model Card Authors [optional]
233
+
234
+ [More Information Needed]
235
+
236
+ ## Model Card Contact
237
+
238
+ [More Information Needed]
239
+
240
+