mohamedemam commited on
Commit
44f6b90
ยท
verified ยท
1 Parent(s): fff53d5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +168 -8
README.md CHANGED
@@ -1,30 +1,190 @@
1
  ---
2
  language:
3
- - ar
4
  - en
 
5
  license: gpl
6
  tags:
7
  - autograding
8
- - 'essay quetion '
9
  - sentence similarity
10
  metrics:
11
  - accuracy
12
  library_name: peft
 
 
13
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  We are thrilled to introduce our graduation project, the EM5 model, designed for automated essay grading in both Arabic and English. ๐Ÿ“โœจ
15
 
16
  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.
17
 
18
  Our model utilizes the following impressive models:
19
 
20
- Mistral: 96%
21
- LLaMA: 93%
22
- FLAN-T5: 93%
23
- BLOOMZ (Arabic): 86%
24
- MT0 (Arabic): 84%
25
 
26
  You can try our models for auto-grading on Hugging Face! ๐ŸŒ
27
 
28
  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. ๐ŸŒŸ
29
 
30
- #MachineLearning #AI #Education #EssayGrading #GraduationProject
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  language:
 
3
  - en
4
+ - ar
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
+
17
+ # Model Card for Model ID
18
+
19
+ <!-- Provide a quick summary of what the model is/does. -->
20
+
21
+
22
+
23
+ ## Model Details
24
+
25
+ ### Model Description
26
+
27
+ <!-- Provide a longer summary of what this model is. -->
28
+
29
  We are thrilled to introduce our graduation project, the EM5 model, designed for automated essay grading in both Arabic and English. ๐Ÿ“โœจ
30
 
31
  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.
32
 
33
  Our model utilizes the following impressive models:
34
 
35
+ Mistral: 96%
36
+ LLaMA: 93%
37
+ FLAN-T5: 93%
38
+ BLOOMZ (Arabic): 86%
39
+ MT0 (Arabic): 84%
40
 
41
  You can try our models for auto-grading on Hugging Face! ๐ŸŒ
42
 
43
  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. ๐ŸŒŸ
44
 
45
+ #MachineLearning #AI #Education #EssayGrading #GraduationProject
46
+
47
+ - **Developed by:** mohamed emam
48
+ - **Model type:** decoder only
49
+ - **Language(s) (NLP):** English
50
+ - **License:** gpl
51
+ - **Finetuned from model :** llama
52
+
53
+
54
+ <!-- Provide the basic links for the model. -->
55
+
56
+ - **Repository:** https://github.com/mohamed-em2m/auto-grading
57
+ ### Direct Use
58
+
59
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
60
+
61
+ auto grading for essay quetions
62
+
63
+ ### Downstream Use [optional]
64
+
65
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
66
+
67
+ Text generation
68
+
69
+ [More Information Needed]
70
+
71
+ ### Training Data
72
+ - **mohamedemam/Essay-quetions-auto-grading-arabic**
73
+
74
+
75
+ ### Training Procedure
76
+
77
+ using Trl
78
+ ### Pipline
79
+ ```python
80
+ from transformers import Pipeline
81
+ import torch.nn.functional as F
82
+
83
+
84
+ class MyPipeline:
85
+
86
+ def __init__(self,model,tokenizer):
87
+ self.model=model
88
+ self.tokenizer=tokenizer
89
+
90
+ def chat_Format(self,context, quetion, answer):
91
+ 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:"
92
+
93
+
94
+ def __call__(self, context, quetion, answer,generate=1,max_new_tokens=4, num_beams=2, do_sample=False,num_return_sequences=1):
95
+ inp=self.chat_Format(context, quetion, answer)
96
+ w = self.tokenizer(inp, add_special_tokens=True,
97
+ pad_to_max_length=True,
98
+ return_attention_mask=True,
99
+ return_tensors='pt')
100
+ response=""
101
+ if(generate):
102
+ 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)
103
+ response = outputs
104
+
105
+ s =self.model(input_ids=w['input_ids'].cuda(), attention_mask=w['attention_mask'].cuda())['logits'][0][-1]
106
+ s = F.softmax(s, dim=-1)
107
+ yes_token_id = self.tokenizer.convert_tokens_to_ids(self.tokenizer.tokenize("True")[0])
108
+ no_token_id = self.tokenizer.convert_tokens_to_ids(self.tokenizer.tokenize("False")[0])
109
+
110
+ for i in ["Yes", "yes", "True", "true","ุตุญูŠุญ"]:
111
+ for word in self.tokenizer.tokenize(i):
112
+ s[yes_token_id] += s[self.tokenizer.convert_tokens_to_ids(word)]
113
+ for i in ["No", "no", "False", "false","ุฎุทุฃ"]:
114
+ for word in self.tokenizer.tokenize(i):
115
+
116
+ s[no_token_id] += s[self.tokenizer.convert_tokens_to_ids(word)]
117
+ true = (s[yes_token_id] / (s[no_token_id] + s[yes_token_id])).item()
118
+ return {"response": response, "true": true}
119
+ 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:
120
+
121
+ Model Selection: Choosing a pre-trained model that fits the application's needs.
122
+ Infrastructure Setup: Setting up the necessary hardware and software infrastructure to run the model efficiently, including cloud services, GPUs, and necessary libraries.
123
+ Integration: Integrating the model into an application, which can involve setting up APIs or embedding the model directly into the software.
124
+ Optimization: Fine-tuning the model for specific tasks or domains and optimizing it for performance and cost-efficiency.
125
+ Monitoring and Maintenance: Ensuring the model performs well over time, monitoring for biases, and updating the model as needed."""
126
+ quetion="What are the key considerations when choosing a cloud service provider for deploying a large language model like GPT-4?"
127
+ answer="""When choosing a cloud service provider for deploying a large language model like GPT-4, the key considerations include:
128
+ Compute Power: Ensure the provider offers high-performance GPUs or TPUs capable of handling the computational requirements of the model.
129
+ Scalability: The ability to scale resources up or down based on the application's demand to handle varying workloads efficiently.
130
+ Cost: Analyze the pricing models to understand the costs associated with compute time, storage, data transfer, and any other services.
131
+ 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.
132
+ Security and Compliance: Ensure the provider adheres to industry standards for security and compliance, protecting sensitive data and maintaining privacy.
133
+ Latency and Availability: Consider the geographical distribution of data centers to ensure low latency and high availability for your end-users.
134
+
135
+ 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."""
136
+ from peft import PeftModel, PeftConfig
137
+ from transformers import AutoModelForCausalLM
138
+
139
+ config = PeftConfig.from_pretrained("mohamedemam/Em2-llama-7b")
140
+ base_model = AutoModelForCausalLM.from_pretrained("NousResearch/Llama-2-7b-hf")
141
+ model = PeftModel.from_pretrained(base_model, "mohamedemam/Em2-llama-7b")
142
+ pipe=MyPipeline(model,tokenizer)
143
+ print(pipe(context,quetion,answer,generate=True,max_new_tokens=4, num_beams=2, do_sample=False,num_return_sequences=1))
144
+ ```
145
+ - **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}
146
+
147
+ ### Chat Format Function
148
+ This function formats the input context, question, and answer into a specific structure for the model to process.
149
+
150
+ ```python
151
+ def chat_Format(self, context, question, answer):
152
+ 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:"
153
+ ```
154
+
155
+
156
+ ## Configuration
157
+
158
+ ### Dropout Probability for LoRA Layers
159
+ - **lora_dropout:** 0.05
160
+
161
+ ### Quantization Settings
162
+ - **use_4bit:** True
163
+ - **bnb_4bit_compute_dtype:** "float16"
164
+ - **bnb_4bit_quant_type:** "nf4"
165
+ - **use_nested_quant:** False
166
+
167
+ ### Output Directory
168
+ - **output_dir:** "./results"
169
+
170
+ ### Training Parameters
171
+ - **num_train_epochs:** 1
172
+ - **fp16:** False
173
+ - **bf16:** False
174
+ - **per_device_train_batch_size:** 1
175
+ - **per_device_eval_batch_size:** 4
176
+ - **gradient_accumulation_steps:** 8
177
+ - **gradient_checkpointing:** True
178
+ - **max_grad_norm:** 0.3
179
+ - **learning_rate:** 5e-5
180
+ - **weight_decay:** 0.001
181
+ - **optim:** "paged_adamw_8bit"
182
+ - **lr_scheduler_type:** "constant"
183
+ - **max_steps:** -1
184
+ - **warmup_ratio:** 0.03
185
+ - **group_by_length:** True
186
+
187
+ ### Logging and Saving
188
+ - **save_steps:** 100
189
+ - **logging_steps:** 25
190
+ - **max_seq_length:** False