mohamedemam commited on
Commit
f25cbbf
·
verified ·
1 Parent(s): 4ba0d75

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +131 -158
README.md CHANGED
@@ -1,198 +1,171 @@
1
- ---
2
- library_name: peft
3
- ---
4
-
5
- # Model Card for Model ID
6
-
7
- <!-- Provide a quick summary of what the model is/does. -->
8
-
9
-
10
-
11
- ## Model Details
12
-
13
- ### Model Description
14
-
15
- <!-- Provide a longer summary of what this model is. -->
16
-
17
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
18
-
19
- - **Developed by:** [More Information Needed]
20
- - **Funded by [optional]:** [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
-
73
- [More Information Needed]
74
-
75
- ## Training Details
76
 
77
- ### Training Data
78
 
79
- <!-- 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. -->
80
-
81
- [More Information Needed]
82
-
83
- ### Training Procedure
84
-
85
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
86
-
87
- #### Preprocessing [optional]
88
-
89
- [More Information Needed]
90
-
91
-
92
- #### Training Hyperparameters
93
-
94
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
95
-
96
- #### Speeds, Sizes, Times [optional]
97
-
98
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
99
-
100
- [More Information Needed]
101
-
102
- ## Evaluation
103
-
104
- <!-- This section describes the evaluation protocols and provides the results. -->
105
-
106
- ### Testing Data, Factors & Metrics
107
-
108
- #### Testing Data
109
-
110
- <!-- This should link to a Dataset Card if possible. -->
111
-
112
- [More Information Needed]
113
 
114
- #### Factors
 
 
115
 
116
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
117
 
118
- [More Information Needed]
119
 
120
- #### Metrics
121
 
122
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
123
 
124
- [More Information Needed]
125
 
126
- ### Results
127
 
128
- [More Information Needed]
129
 
130
- #### Summary
 
 
 
 
131
 
 
132
 
 
133
 
134
- ## Model Examination [optional]
 
135
 
136
- <!-- Relevant interpretability work for the model goes here -->
137
 
138
  [More Information Needed]
 
139
 
140
- ## Environmental Impact
141
 
142
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
143
 
144
- 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).
 
145
 
146
- - **Hardware Type:** [More Information Needed]
147
- - **Hours used:** [More Information Needed]
148
- - **Cloud Provider:** [More Information Needed]
149
- - **Compute Region:** [More Information Needed]
150
- - **Carbon Emitted:** [More Information Needed]
151
 
152
- ## Technical Specifications [optional]
153
 
154
- ### Model Architecture and Objective
155
 
156
- [More Information Needed]
 
 
157
 
158
- ### Compute Infrastructure
 
 
159
 
160
- [More Information Needed]
 
 
 
 
 
 
 
 
 
161
 
162
- #### Hardware
 
 
 
 
 
 
 
 
 
163
 
164
- [More Information Needed]
 
 
 
165
 
166
- #### Software
 
 
 
 
 
 
 
 
 
 
 
 
167
 
168
- [More Information Needed]
 
 
169
 
170
- ## Citation [optional]
 
 
 
 
171
 
172
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
173
 
174
- **BibTeX:**
175
 
176
- [More Information Needed]
177
 
178
- **APA:**
 
179
 
180
- [More Information Needed]
181
-
182
- ## Glossary [optional]
183
-
184
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
185
-
186
- [More Information Needed]
187
 
188
- ## More Information [optional]
189
 
190
- [More Information Needed]
191
-
192
- ## Model Card Authors [optional]
193
-
194
- [More Information Needed]
195
 
196
- ## Model Card Contact
 
 
 
 
 
197
 
198
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
 
2
 
3
+ language:
4
+ - en
5
+ license: gpl
6
+ tags:
7
+ - autograding
8
+ - essay quetion
9
+ - sentence similarity
10
+ metrics:
11
+ - accuracy
12
+ library_name: peft
13
+ datasets:
14
+ - mohamedemam/Essay-quetions-auto-grading
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ Model Card for Model ID
17
+ Model Details
18
+ Model Description
19
 
20
+ We are thrilled to introduce our graduation project, the EM5 model, designed for automated essay grading in both Arabic and English. 📝✨
21
 
22
+ To develop this model, we first created a custom dataset for training. We adapted the QuAC and OpenOrca datasets to make them suitable for our automated essay grading application.
23
 
24
+ Our model utilizes the following impressive models:
25
 
26
+ Mistral: 96% LLaMA: 93% FLAN-T5: 93% BLOOMZ (Arabic): 86% MT0 (Arabic): 84%
27
 
28
+ You can try our models for auto-grading on Hugging Face! 🌐
29
 
30
+ We then deployed these models for practical use. We are proud of our team's hard work and the potential impact of the EM2 model in the field of education. 🌟
31
 
32
+ #MachineLearning #AI #Education #EssayGrading #GraduationProject
33
 
34
+ Developed by: mohamed emam
35
+ Model type: decoder only
36
+ Language(s) (NLP): English
37
+ License: gpl
38
+ Finetuned from model : llama
39
 
40
+ Repository: https://github.com/mohamed-em2m/auto-grading
41
 
42
+ Direct Use
43
 
44
+ auto grading for essay quetions
45
+ Downstream Use [optional]
46
 
47
+ Text generation
48
 
49
  [More Information Needed]
50
+ Training Data
51
 
52
+ mohamedemam/Essay-quetions-auto-grading-arabic
53
 
54
+ Training Procedure
55
 
56
+ using Trl
57
+ Pipline
58
 
59
+ from transformers import Pipeline
60
+ import torch.nn.functional as F
 
 
 
61
 
 
62
 
63
+ class MyPipeline:
64
 
65
+ def __init__(self,model,tokenizer):
66
+ self.model=model
67
+ self.tokenizer=tokenizer
68
 
69
+ def chat_Format(self,context, quetion, answer):
70
+ return "Instruction:/n check answer is true or false of next quetion using context below:\n" + "#context: " + context + f".\n#quetion: " + quetion + f".\n#student answer: " + answer + ".\n#response:"
71
+
72
 
73
+ def __call__(self, context, quetion, answer,generate=1,max_new_tokens=4, num_beams=2, do_sample=False,num_return_sequences=1):
74
+ inp=self.chat_Format(context, quetion, answer)
75
+ w = self.tokenizer(inp, add_special_tokens=True,
76
+ pad_to_max_length=True,
77
+ return_attention_mask=True,
78
+ return_tensors='pt')
79
+ response=""
80
+ if(generate):
81
+ outputs = self.tokenizer.batch_decode(self.model.generate(input_ids=w['input_ids'].cuda(), attention_mask=w['attention_mask'].cuda(), max_new_tokens=max_new_tokens, num_beams=num_beams, do_sample=do_sample, num_return_sequences=num_return_sequences), skip_special_tokens=True)
82
+ response = outputs
83
 
84
+ s =self.model(input_ids=w['input_ids'].cuda(), attention_mask=w['attention_mask'].cuda())['logits'][0][-1]
85
+ s = F.softmax(s, dim=-1)
86
+ yes_token_id = self.tokenizer.convert_tokens_to_ids(self.tokenizer.tokenize("True")[0])
87
+ no_token_id = self.tokenizer.convert_tokens_to_ids(self.tokenizer.tokenize("False")[0])
88
+
89
+ for i in ["Yes", "yes", "True", "true","صحيح"]:
90
+ for word in self.tokenizer.tokenize(i):
91
+ s[yes_token_id] += s[self.tokenizer.convert_tokens_to_ids(word)]
92
+ for i in ["No", "no", "False", "false","خطأ"]:
93
+ for word in self.tokenizer.tokenize(i):
94
 
95
+ s[no_token_id] += s[self.tokenizer.convert_tokens_to_ids(word)]
96
+ true = (s[yes_token_id] / (s[no_token_id] + s[yes_token_id])).item()
97
+ return {"response": response, "true": true}
98
+ context="""Large language models, such as GPT-4, are trained on vast amounts of text data to understand and generate human-like text. The deployment of these models involves several steps:
99
 
100
+ Model Selection: Choosing a pre-trained model that fits the application's needs.
101
+ Infrastructure Setup: Setting up the necessary hardware and software infrastructure to run the model efficiently, including cloud services, GPUs, and necessary libraries.
102
+ Integration: Integrating the model into an application, which can involve setting up APIs or embedding the model directly into the software.
103
+ Optimization: Fine-tuning the model for specific tasks or domains and optimizing it for performance and cost-efficiency.
104
+ Monitoring and Maintenance: Ensuring the model performs well over time, monitoring for biases, and updating the model as needed."""
105
+ quetion="What are the key considerations when choosing a cloud service provider for deploying a large language model like GPT-4?"
106
+ answer="""When choosing a cloud service provider for deploying a large language model like GPT-4, the key considerations include:
107
+ Compute Power: Ensure the provider offers high-performance GPUs or TPUs capable of handling the computational requirements of the model.
108
+ Scalability: The ability to scale resources up or down based on the application's demand to handle varying workloads efficiently.
109
+ Cost: Analyze the pricing models to understand the costs associated with compute time, storage, data transfer, and any other services.
110
+ Integration and Support: Availability of tools and libraries that support easy integration of the model into your applications, along with robust technical support and documentation.
111
+ Security and Compliance: Ensure the provider adheres to industry standards for security and compliance, protecting sensitive data and maintaining privacy.
112
+ Latency and Availability: Consider the geographical distribution of data centers to ensure low latency and high availability for your end-users.
113
 
114
+ By evaluating these factors, you can select a cloud service provider that aligns with your deployment needs, ensuring efficient and cost-effective operation of your large language model."""
115
+ from peft import PeftModel, PeftConfig
116
+ from transformers import AutoModelForCausalLM
117
 
118
+ config = PeftConfig.from_pretrained("mohamedemam/Em2-llama-7b")
119
+ base_model = AutoModelForCausalLM.from_pretrained("NousResearch/Llama-2-7b-hf")
120
+ model = PeftModel.from_pretrained(base_model, "mohamedemam/Em2-llama-7b")
121
+ pipe=MyPipeline(model,tokenizer)
122
+ print(pipe(context,quetion,answer,generate=True,max_new_tokens=4, num_beams=2, do_sample=False,num_return_sequences=1))
123
 
124
+ output:{'response': ["Instruction:/n check answer is true or false of next quetion using context below:\n#context: Large language models, such as GPT-4, are trained on vast amounts of text data to understand and generate human-like text. The deployment of these models involves several steps:\n\n Model Selection: Choosing a pre-trained model that fits the application's needs.\n Infrastructure Setup: Setting up the necessary hardware and software infrastructure to run the model efficiently, including cloud services, GPUs, and necessary libraries.\n Integration: Integrating the model into an application, which can involve setting up APIs or embedding the model directly into the software.\n Optimization: Fine-tuning the model for specific tasks or domains and optimizing it for performance and cost-efficiency.\n Monitoring and Maintenance: Ensuring the model performs well over time, monitoring for biases, and updating the model as needed..\n#quetion: What are the key considerations when choosing a cloud service provider for deploying a large language model like GPT-4?.\n#student answer: When choosing a cloud service provider for deploying a large language model like GPT-4, the key considerations include:\n Compute Power: Ensure the provider offers high-performance GPUs or TPUs capable of handling the computational requirements of the model.\n Scalability: The ability to scale resources up or down based on the application's demand to handle varying workloads efficiently.\n Cost: Analyze the pricing models to understand the costs associated with compute time, storage, data transfer, and any other services.\n Integration and Support: Availability of tools and libraries that support easy integration of the model into your applications, along with robust technical support and documentation.\n Security and Compliance: Ensure the provider adheres to industry standards for security and compliance, protecting sensitive data and maintaining privacy.\n Latency and Availability: Consider the geographical distribution of data centers to ensure low latency and high availability for your end-users.\n\nBy evaluating these factors, you can select a cloud service provider that aligns with your deployment needs, ensuring efficient and cost-effective operation of your large language model..\n#response: true the answer is"], 'true': 0.943033754825592}
125
 
126
+ Chat Format Function
127
 
128
+ This function formats the input context, question, and answer into a specific structure for the model to process.
129
 
130
+ def chat_Format(self, context, question, answer):
131
+ return "Instruction:/n check answer is true or false of next question using context below:\n" + "#context: " + context + f".\n#question: " + question + f".\n#student answer: " + answer + ".\n#response:"
132
 
133
+ Configuration
134
+ Dropout Probability for LoRA Layers
 
 
 
 
 
135
 
136
+ lora_dropout: 0.05
137
 
138
+ Quantization Settings
 
 
 
 
139
 
140
+ use_4bit: True
141
+ bnb_4bit_compute_dtype: "float16"
142
+ bnb_4bit_quant_type: "nf4"
143
+ use_nested_quant: False
144
+
145
+ Output Directory
146
 
147
+ output_dir: "./results"
148
+
149
+ Training Parameters
150
+
151
+ num_train_epochs: 1
152
+ fp16: False
153
+ bf16: False
154
+ per_device_train_batch_size: 1
155
+ per_device_eval_batch_size: 4
156
+ gradient_accumulation_steps: 8
157
+ gradient_checkpointing: True
158
+ max_grad_norm: 0.3
159
+ learning_rate: 5e-5
160
+ weight_decay: 0.001
161
+ optim: "paged_adamw_8bit"
162
+ lr_scheduler_type: "constant"
163
+ max_steps: -1
164
+ warmup_ratio: 0.03
165
+ group_by_length: True
166
+
167
+ Logging and Saving
168
+
169
+ save_steps: 100
170
+ logging_steps: 25
171
+ max_seq_length: False