MinnieMin commited on
Commit
be214cd
·
verified ·
1 Parent(s): 3d0cf8c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +197 -9
README.md CHANGED
@@ -69,22 +69,210 @@ This model is ideal for educational purposes, particularly in coding test prepar
69
  Users should be aware that the model encourages self-reflection and thought processes, which may not always align with seeking quick solutions. The model’s effectiveness depends on user interaction and the problem context, and it may not perform well in certain programming domains without further fine-tuning.
70
 
71
 
72
- ## How to Get Started with the Model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
- Use the code below to get started with the model.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ```python
77
- from transformers import AutoModelForCausalLM, AutoTokenizer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- model_name = "MinnieMin/gemma-2-2b-it-ThinkLink"
80
- model = AutoModelForCausalLM.from_pretrained(model_name)
81
- tokenizer = AutoTokenizer.from_pretrained(model_name)
82
 
83
- inputs = tokenizer("What algorithm should I use for this problem?", return_tensors="pt")
84
- outputs = model.generate(**inputs)
85
- print(tokenizer.decode(outputs[0]))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  ```
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  ## Training Details
89
 
90
  ### Training Data
 
69
  Users should be aware that the model encourages self-reflection and thought processes, which may not always align with seeking quick solutions. The model’s effectiveness depends on user interaction and the problem context, and it may not perform well in certain programming domains without further fine-tuning.
70
 
71
 
72
+ ## Project Overview
73
+
74
+ ### Problem:
75
+ - In the past, when preparing for **Coding Tests**, using **LLM models** felt like simply copying the answer sheet, which led to the perception that using these models was inappropriate. This is because the models focus solely on **providing the answer**. That is, LLM models directly deliver the solution without involving the user's thought process, resulting in an inefficient learning experience.
76
+ - A shift in perspective: Could the **Gemma model** be used as a **Tutor** to help users prepare for **Coding Tests**?
77
+
78
+ ---------------------------------------------
79
+
80
+ ### Analysis of the Gemma Model
81
+ - After inputting Coding Test problems into the Gemma model, the following observations were made:
82
+ 1. Inconsistent Answer Format:
83
+ - The response format provided by the model is inconsistent. For example, some answers provide explanations only, while others include complete code, which can confuse the user.
84
+ 2. Lack of Code or Incorrect Solutions:
85
+ - Some responses lack code or contain incorrect examples, which do not help the user solve the problem.
86
+
87
+ **Conclusion**:
88
+ The Gemma model often provides inconsistent answers, making it less likely to aid in user learning effectively.
89
+
90
+ ---------------------------------------------
91
+
92
+ #### Example Response from the Original Gemma Model
93
+
94
+ ##### Example 1: Closest Sum Problem
95
+ - Problem Description:
96
+ ```markdown
97
+ 1. Sort the input array `nums`.
98
+ 2. Initialize the closest variable to be the sum of the first three elements.
99
+ 3. Iterate through the sorted array with a pointer `i` running from the first element to the third-to-last element.
100
+ 4. Initialize two-pointers left (set to i + 1) and right (set to the last element).
101
+ 5. While left is less than right:
102
+ a. Calculate the current sum `cur_sum` using the elements at positions `i`, `left`, and `right`.
103
+ b. If `cur_sum` is equal to target, return it as the closest sum.
104
+ c. Update the closest sum if the difference between target and `cur_sum` is less than the difference between target and closest.
105
+ d. Move the left pointer forward if `cur_sum` is less than target, otherwise move the right pointer backward.
106
+ 6. Return the closest sum found.
107
+ ```
108
+
109
+ - Gemma Model Response:
110
+ ~~~
111
+ **Explanation:**
112
+
113
+ The code implements a solution to find the closest sum of three numbers in an array. It utilizes a two-pointer approach to efficiently explore the array and compare sums with the target value.
114
+
115
+ **Key Points:**
116
 
117
+ - **Sorting:** The input array is sorted to enable efficient searching.
118
+ - **Two-Pointers:** The code uses two pointers (`left` and `right`) to explore the array and compare sums.
119
+ - **Iteration:** The code iterates through the sorted array, comparing sums with the target value.
120
+ - **Comparison:** The code compares the difference between the target value and the current sum to determine the closest sum.
121
+ - **Update:** The code updates the `closest` sum if a smaller difference is found.
122
+
123
+ **Example:**
124
+
125
+ ```
126
+ nums = [1, 2, 3, 4, 5]
127
+ target = 7
128
+
129
+ Sorted nums: [1, 2, 3, 4, 5]
130
+ closest = 7
131
+ ```
132
+
133
+ **Code:**
134
 
135
  ```python
136
+ def closest_sum_of_three(nums, target):
137
+ nums.sort()
138
+ closest = nums[0] + nums[1] + nums[2]
139
+ for i in range(3):
140
+ left = i + 1
141
+ right = nums[-1]
142
+ while left < right:
143
+ cur_sum = nums[i] + nums[left] + nums[right]
144
+ if cur_sum == target:
145
+ return cur_sum
146
+ if abs(cur_sum - target) < abs(closest - target):
147
+ closest = cur_sum
148
+ if cur_sum < target:
149
+ left += 1
150
+ else:
151
+ right -= 1
152
+ return closest
153
+ ```
154
+
155
+ **Note:** The code assumes that the input array `nums` is sorted in ascending order.
156
+ <end_of_turn>
157
+ ~~~
158
+ - Note: The code assumes that the input array nums is sorted in ascending order.
159
+
160
+
161
+ - **Interpretation**:
162
+ - This code explains how to find the sum of three numbers closest to the target value in the `nums` array. However, the code contains errors and may not provide the intended results.
163
+
164
+ ---------------------------------------------
165
 
166
+ ## **Objective**:
 
 
167
 
168
+ - Fine-tune the **Gemma-2-2B-IT** model to not only provide direct answers to coding test problems but to guide users through the problem-solving process using **step-by-step hints**, encouraging the user to think critically and explore solutions on their own.
169
+
170
+ - **Problems with the Original Model**:
171
+ - "The original Gemma model often fails to provide essential code for solving the problem or presents incorrect code. This increases the risk of users misunderstanding and learning incorrect approaches."
172
+
173
+ - **Expected Outcome after Fine-Tuning**:
174
+ - By fine-tuning, the model's consistency improves, providing appropriate hints that enhance problem-solving skills.
175
+ - The model encourages users to think critically and offers **stepwise feedback** that fosters deeper understanding.
176
+
177
+ ---------------------------------------------
178
+
179
+ ## **Functionality and Structure**
180
+
181
+ - When a user submits a coding test problem, the fine-tuned Gemma model provides analysis and step-by-step hints instead of direct answers.
182
+ - For example:
183
+ - First question: "What type of algorithm is required for this problem?"
184
+ - Second question: "What part of this problem do you find challenging (key to implementation)?"
185
+ - Third question: "Describe the approach you would take to solve the problem, including how to handle exceptions and potential errors."
186
+ - This approach encourages users to think through the problem-solving process independently.
187
+
188
+ ---------------------------------------------
189
+
190
+ ## **Conclusion**
191
+
192
+ By creating a new dataset for fine-tuning, we were able to evaluate the model's performance improvement.
193
+
194
+ #### Example 1: Maximum Product Problem
195
+ ```markdown
196
+ The algorithm aims to find the maximum product of any three numbers in the given array. It first sorts the array, which allows easy access to the largest and smallest numbers. By sorting, the algorithm can quickly identify the highest and lowest values, which are crucial when dealing with negative numbers, as multiplying two negative numbers yields a positive product.
197
+
198
+ The main idea is to consider two scenarios:
199
+ 1. The product of the three largest numbers.
200
+ 2. The product of the two smallest (most negative) numbers multiplied by the largest number.
201
+
202
+ Steps:
203
+ 1. Sort the array `nums` in ascending order.
204
+ 2. Calculate the product of the last three numbers in the sorted array.
205
+ 3. Calculate the product of the first two numbers (smallest) and the last number (largest).
206
+ 4. Return the maximum value between the two products.
207
  ```
208
 
209
+ - ThinkLink Model Response :
210
+ ~~~
211
+ "problem_type": "Maximum Product",
212
+ "challenging_part": "Sorting the array",
213
+ "implementation_steps": [
214
+ "Sort the array `nums` in ascending order.",
215
+ "Calculate the product of the last three numbers in the sorted array.",
216
+ "Calculate the product of the first two numbers (smallest) and the last number (largest).",
217
+ "Return the maximum value between the two products."
218
+ ],
219
+ "Answer Code": "```python\ndef maxProduct(nums):\n nums.sort()\n return max(nums[-1] * nums[-2] * nums[-3], nums[0] * nums[1] * nums[-1])\n```\n\n"
220
+ ~~~
221
+
222
+ - Interpretation :
223
+ 1. Problem Type Clarified:
224
+ - Clearly defines the problem as Maximum Product, making it easier for learners to understand which algorithm or approach to apply.
225
+ 2. Challenging Part Identified:
226
+ - Highlights the importance of sorting the array as the challenging part, helping learners focus on the critical difficulty in the solution.
227
+ 3. Step-by-Step Explanation:
228
+ - Provides a detailed breakdown of how to approach the problem, making it easier for learners to follow the steps. Sorting and calculating the product in two different ways and then comparing the results are explained effectively.
229
+ 4. Concise Code Example:
230
+ - The code example is concise and directly reflects the core logic needed to solve the problem. This allows learners to easily grasp both the theory and implementation.
231
+
232
+
233
+ #### Example 2: Longest Increasing Subsequence Problem
234
+ ```markdown
235
+ Given an integer array nums, find the length of the longest strictly increasing subsequence.
236
+
237
+ A subsequence is derived by deleting some or no elements without changing the order of the remaining elements.
238
+
239
+ Example:
240
+
241
+ Input: nums = [10, 9, 2, 5, 3, 7, 101, 18]
242
+ Output: 4
243
+ Explanation: The longest increasing subsequence is [2, 3, 7, 101], therefore the length is 4.
244
+ ```
245
+
246
+ - ThinkLink Model Response :
247
+ ~~~
248
+ "problem_type": "Dynamic Programming",
249
+ "challenging_part": "Understanding the relationship between subsequences and the original array",
250
+ "implementation_steps": [
251
+ "Create a DP table with the same size as the input array.",
252
+ "Initialize the DP table with the maximum possible value for each index.",
253
+ "Iterate through the input array and for each element, compare it with the previous element.",
254
+ "If the current element is greater than the previous element, update the DP table with the maximum value of the current element.",
255
+ "If the current element is less than the previous element, update the DP table with the maximum value of the previous element."
256
+ ],
257
+ "Answer Code": "```python\ndef findLengthOfLCIS(nums):\n if not nums:\n return 0\n n = len(nums)\n dp = [1] * n\n for i in range(1, n):\n for j in range(i):\n if nums[i] > nums[j]:\n dp[i] = max(dp[i], dp[j] + 1)\n return max(dp)\n```\n\n"
258
+ ~~~
259
+
260
+ - Interpretation :
261
+ 1. Problem Type Clarified:
262
+ - The problem is clearly defined as Dynamic Programming, helping learners quickly identify the appropriate approach.
263
+ 2. Challenging Part Identified:
264
+ - Highlights the importance of sorting the array as the challenging part, helping learners focus on the critical difficulty in the solution.
265
+ 3. Step-by-Step Explanation:
266
+ - The steps to solve the problem are explained in detail, from creating and initializing the DP table to updating values based on increasing subsequences. This helps learners clearly follow the process.
267
+ 4. Concise Code Example:
268
+ - The provided code is clear, concise, and directly applicable, allowing learners to easily understand how dynamic programming can be used to solve the problem.
269
+
270
+
271
+ ## **Conclusion**
272
+
273
+ By fine-tuning the Gemma model, we built a more consistent and learner-friendly system that helps users develop problem-solving skills independently. We plan to continue improving the model by training it on larger datasets and incorporating user feedback for ongoing enhancements.
274
+
275
+
276
  ## Training Details
277
 
278
  ### Training Data