IsmaelMousa commited on
Commit
01dc807
·
verified ·
1 Parent(s): f163773

prepared the documentation

Browse files
Files changed (1) hide show
  1. README.md +108 -164
README.md CHANGED
@@ -3,199 +3,143 @@ library_name: transformers
3
  tags:
4
  - trl
5
  - sft
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  ---
7
 
8
- # Model Card for Model ID
9
 
10
- <!-- Provide a quick summary of what the model is/does. -->
11
 
12
 
 
 
 
 
13
 
14
- ## Model Details
15
 
16
- ### Model Description
17
 
18
- <!-- Provide a longer summary of what this model is. -->
 
 
 
 
 
19
 
20
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
 
 
 
21
 
22
- - **Developed by:** [More Information Needed]
23
- - **Funded by [optional]:** [More Information Needed]
24
- - **Shared by [optional]:** [More Information Needed]
25
- - **Model type:** [More Information Needed]
26
- - **Language(s) (NLP):** [More Information Needed]
27
- - **License:** [More Information Needed]
28
- - **Finetuned from model [optional]:** [More Information Needed]
29
 
30
- ### Model Sources [optional]
31
-
32
- <!-- Provide the basic links for the model. -->
33
-
34
- - **Repository:** [More Information Needed]
35
- - **Paper [optional]:** [More Information Needed]
36
- - **Demo [optional]:** [More Information Needed]
37
-
38
- ## Uses
39
-
40
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
41
-
42
- ### Direct Use
43
-
44
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
45
-
46
- [More Information Needed]
47
-
48
- ### Downstream Use [optional]
49
-
50
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
51
-
52
- [More Information Needed]
53
-
54
- ### Out-of-Scope Use
55
-
56
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
57
-
58
- [More Information Needed]
59
-
60
- ## Bias, Risks, and Limitations
61
-
62
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
63
-
64
- [More Information Needed]
65
-
66
- ### Recommendations
67
-
68
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
69
-
70
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
71
-
72
- ## How to Get Started with the Model
73
-
74
- Use the code below to get started with the model.
75
-
76
- [More Information Needed]
77
-
78
- ## Training Details
79
-
80
- ### Training Data
81
-
82
- <!-- 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. -->
83
-
84
- [More Information Needed]
85
-
86
- ### Training Procedure
87
-
88
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
89
-
90
- #### Preprocessing [optional]
91
-
92
- [More Information Needed]
93
-
94
-
95
- #### Training Hyperparameters
96
-
97
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
98
-
99
- #### Speeds, Sizes, Times [optional]
100
-
101
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
102
-
103
- [More Information Needed]
104
 
105
  ## Evaluation
 
106
 
107
- <!-- This section describes the evaluation protocols and provides the results. -->
108
-
109
- ### Testing Data, Factors & Metrics
110
-
111
- #### Testing Data
112
-
113
- <!-- This should link to a Dataset Card if possible. -->
114
-
115
- [More Information Needed]
116
-
117
- #### Factors
118
-
119
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
120
-
121
- [More Information Needed]
122
-
123
- #### Metrics
124
-
125
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
126
-
127
- [More Information Needed]
128
-
129
- ### Results
130
-
131
- [More Information Needed]
132
-
133
- #### Summary
134
-
135
-
136
-
137
- ## Model Examination [optional]
138
-
139
- <!-- Relevant interpretability work for the model goes here -->
140
-
141
- [More Information Needed]
142
-
143
- ## Environmental Impact
144
-
145
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
146
-
147
- 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).
148
-
149
- - **Hardware Type:** [More Information Needed]
150
- - **Hours used:** [More Information Needed]
151
- - **Cloud Provider:** [More Information Needed]
152
- - **Compute Region:** [More Information Needed]
153
- - **Carbon Emitted:** [More Information Needed]
154
-
155
- ## Technical Specifications [optional]
156
-
157
- ### Model Architecture and Objective
158
-
159
- [More Information Needed]
160
-
161
- ### Compute Infrastructure
162
-
163
- [More Information Needed]
164
-
165
- #### Hardware
166
 
167
- [More Information Needed]
 
 
 
168
 
169
- #### Software
170
 
171
- [More Information Needed]
172
 
173
- ## Citation [optional]
174
 
175
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
 
 
176
 
177
- **BibTeX:**
178
 
179
- [More Information Needed]
 
180
 
181
- **APA:**
 
182
 
183
- [More Information Needed]
184
 
185
- ## Glossary [optional]
 
 
 
186
 
187
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
188
 
189
- [More Information Needed]
 
 
 
 
 
190
 
191
- ## More Information [optional]
192
 
193
- [More Information Needed]
194
 
195
- ## Model Card Authors [optional]
196
 
197
- [More Information Needed]
 
198
 
199
- ## Model Card Contact
200
 
201
- [More Information Needed]
 
 
 
 
 
 
 
3
  tags:
4
  - trl
5
  - sft
6
+ license: apache-2.0
7
+ base_model: Qwen/Qwen2.5-1.5B-Instruct
8
+ datasets:
9
+ - IsmaelMousa/books
10
+ metrics:
11
+ - accuracy
12
+ - f1
13
+ - precision
14
+ - recall
15
+ - cohen_kappa
16
+ - rmse
17
+ model-index:
18
+ - name: Qwen2.5-1.5B-Instruct-Books-19K
19
+ results:
20
+ - task:
21
+ name: Text Generation
22
+ type: text-generation
23
+ dataset:
24
+ name: IsmaelMousa/books
25
+ type: IsmaelMousa/books
26
+ config: IsmaelMousa/books
27
+ split: train
28
+ args: IsmaelMousa/books
29
+ metrics:
30
+ - name: Accuracy
31
+ type: accuracy
32
+ value: 0.1200
33
+ - name: F1
34
+ type: f1
35
+ value: 0.0973
36
+ - name: Precision
37
+ type: precision
38
+ value: 0.1739
39
+ - name: Recall
40
+ type: recall
41
+ value: 0.1198
42
+ - name: Cohen Kappa
43
+ type: cohen_kappa
44
+ value: -0.1549
45
+ - name: RMSE
46
+ type: rmse
47
+ value: 1.6248
48
+ language:
49
+ - en
50
+ pipeline_tag: text-generation
51
  ---
52
 
53
+ # Qwen2.5-1.5B-Instruct-Books-19K
54
 
55
+ This model is a fine-tuned version of [Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) on the Books dataset for Essay Grading.
56
 
57
 
58
+ - **Workflow:** GitHub Repository: [https://github.com/IsmaelMousa/automatic-essay-grading](https://github.com/IsmaelMousa/automatic-essay-grading).
59
+ - **Base Model:** Qwen2.5-1.5B-Instruct: [https://doi.org/10.48550/arXiv.2412.15115](https://doi.org/10.48550/arXiv.2412.15115).
60
+ - **Fine-tuning Dataset:** Books-19K: [https://github.com/IsmaelMousa/Books/19K](https://github.com/IsmaelMousa/automatic-essay-grading/blob/main/data/books/clean/entries/train/200_entries.csv).
61
+ - **Task:** Automatic Essay Grading (Text Generation).
62
 
63
+ [![Report](https://img.shields.io/badge/W&B_Report-gray?logo=weightsandbiases&logoColor=yellow)](https://api.wandb.ai/links/ismael-amjad/783p4r3l)
64
 
65
+ ## Dataset
66
 
67
+ The Books dataset is a synthetic collection of essay-style data points generated using public domain literature and
68
+ large language model prompting. The dataset comprises a total of 300 entries and is built from six classic books. Four
69
+ of these: *The Life of James Watt*, *The Life of Julius Caesar*, *The Moonstone*, and *North and South*; were used
70
+ during the training phase, while the remaining two: *The Life of Napoleon* and *Sense and Sensibility*; were held out
71
+ for benchmarking purposes. Each book contributed exactly 50 entries, leading to a structured split of 200 training
72
+ samples and 100 benchmark samples.
73
 
74
+ All entries were generated using Le Chat Mistral, a model developed by Mistral AI. A carefully crafted prompt was used
75
+ to ensure each generated entry included a question, a reference answer written by an expert, a student answer meant to
76
+ simulate a real-world response, a mark scheme outlining the grading criteria, a score between 1 and 4, and a rationale
77
+ explaining why the score was assigned. The prompt enforced strict quality control: no duplicate questions or answers
78
+ were allowed, all required fields had to be present, and the scoring range was strictly limited to valid values. The
79
+ final output was formatted as CSV files to maintain consistency and ensure compatibility with downstream processing.
80
 
81
+ For more details, the metadata can be accessed at: [metadata](https://github.com/IsmaelMousa/automatic-essay-grading/blob/main/data/books/metadata.py).
 
 
 
 
 
 
82
 
83
+ ## Modeling
84
+ The modeling approach for this study was carefully designed to evaluate the performance of different large language models (LLMs) on the automated essay grading task. We selected the Qwen2.5 architecture to represent a range of model sizes: 0.5B, 1.5B, and 3B. Each model was instruction-tuned on the Books dataset in varying sizes, with hyperparameters optimized to balance computational efficiency and performance. The experiments were conducted on GPU-accelerated hardware, leveraging techniques such as gradient checkpointing, flash attention, and mixed-precision training to maximize resource utilization.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
  ## Evaluation
87
+ The evaluation methodology employed both quantitative metrics and qualitative analysis. For quantitative assessment, we computed accuracy, precision, recall, F1 score, root mean squared error (RMSE), and Cohen's kappa score (CKS) for the scoring task, while using BERT-Score precision, recall, and F1 for rationale evaluation. On a held-out test set of 100 samples. Qualitative examination of models' outputs revealed cases where most of the models correctly identified key aspects of student answers but sometimes failed to properly align its scoring with the rubric criteria.
88
 
89
+ ### Evaluation results for `score` and `rationale` outputs:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
+ | **Aspect** | **F1** | **Precision** | **Recall** | **Accuracy** | **CKS** | **RMSE** |
92
+ |:----------:|:------:|:-------------:|:----------:|:------------:|:-------:|:--------:|
93
+ | Score | 0.0973 | 0.1739 | 0.1198 | 0.1200 | -0.1549 | 1.6248 |
94
+ | Rationale | 0.4921 | 0.4872 | 0.5001 | -- | -- | -- |
95
 
 
96
 
97
+ ## Usage
98
 
99
+ Below is an example of how to use the model with the Hugging Face Transformers library:
100
 
101
+ ```python
102
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
103
+ import torch
104
 
 
105
 
106
+ checkpoint = "IsmaelMousa/Qwen2.5-1.5B-Instruct-Books-19K"
107
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
108
 
109
+ tokenizer = AutoTokenizer .from_pretrained(checkpoint)
110
+ model = AutoModelForCausalLM.from_pretrained(checkpoint)
111
 
112
+ assistant = pipeline("text-generation", tokenizer=tokenizer, model=model, device=device)
113
 
114
+ question = input("Question : ")
115
+ reference_answer = input("Reference Answer: ")
116
+ student_answer = input("Student Answer : ")
117
+ mark_scheme = input("Mark Scheme : ")
118
 
119
+ system_content = "You are a grading assistant. Evaluate student answers based on the mark scheme. Respond only in JSON format with keys 'score' (int) and 'rationale' (string)."
120
 
121
+ user_content = ("Provide both a score and a rationale by evaluating the student's answer strictly within the mark scheme range,"
122
+ " grading based on how well it meets the question's requirements by comparing the student answer to the reference answer.\n"
123
+ f"Question: {question}\n"
124
+ f"Reference Answer: {reference_answer}\n"
125
+ f"Student Answer: {student_answer}\n"
126
+ f"Mark Scheme: {mark_scheme}")
127
 
128
+ messages = [{"role": "system", "content": system_content}, {"role": "user", "content": user_content}]
129
 
130
+ inputs = tokenizer.apply_chat_template(messages, tokenize=False)
131
 
132
+ output = assistant(inputs, max_new_tokens=128, do_sample=False, return_full_text=False)[0]["generated_text"]
133
 
134
+ print(output)
135
+ ```
136
 
137
+ ### Frameworks
138
 
139
+ - `datasets-3.6.0`
140
+ - `torch-2.7.0`
141
+ - `transformers-4.51.3`
142
+ - `trl-0.17.0`
143
+ - `scikit-learn-1.6.1`
144
+ - `bert-score-0.3.13`
145
+ - `json-repair-0.46.0`