8000 feature(README): update examples · ise-uiuc/magicoder@1deaca7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1deaca7

Browse files
feature(README): update examples
1 parent 1555a4a commit 1deaca7

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,112 @@ print(todo.get_tasks()) # Output: []
126126

127127
We follow [WizardCoder](https://github.com/nlpxucan/WizardLM/blob/main/demo/wizardLM_demo.py) and provide the script to build a local demo server with [gradio](https://www.gradio.app). Refer to [/demo](demo/README.md) for more information.
128128

129+
Here are some interesting examples showing **Magicoder**'s improvements over base models:
130+
131+
<details>
132+
<summary> <strong> Magicoder's Understanding Ability </strong> </summary>
133+
134+
We create the following two examples by making two original HumanEval problems more complicated. While both **Magicoder-*S*-DS-6.7B** and **deepseek-coder-6.7b-base**, which is **Magicoder**'s base model, can solve the original HumanEval problem, only our **Magicoder-*S*-DS-6.7B** can solve the new complicated problems.
135+
136+
### Example 1
137+
Original Problem:
138+
```
139+
Write a function to, given list of integers, return list in "strange" order. "Strange" sorting, is when you start with the minimum value, then maximum of the remaining integers, then minimum and so on.
140+
```
141+
142+
New Problem:
143+
```
144+
Write a function to, given list of integers, return list in "ascending" order. "Ascending" sorting, is when you start with the minimum value, then maximum of the remaining integers, then minimum and so on.
145+
```
146+
147+
This problem is challenging because we change the name of a new way (not ascending) to sort integers from "strange" to "ascending". The model should understand that the word "ascending" here has a new meaning based on both the context and the fact that it is surrounded by quotation marks. As is shown in the following responses to the new problem from two models, **Magicoder-*S*-DS-6.7B** successfully understands this complicated requirement, while **deepseek-coder-6.7b-base** is misled and sort integers in ascending order instead.
148+
149+
Response to New Problem:
150+
```python
151+
# Magicoder-S-DS-6.7B (Correct)
152+
def ascending_sort(lst):
153+
sorted_lst = []
154+
while lst:
155+
min_val = min(lst)
156+
sorted_lst.append(min_val)
157+
lst.remove(min_val)
158+
if lst:
159+
max_val = max(lst)
160+
sorted_lst.append(max_val)
161+
lst.remove(max_val)
162+
return sorted_lst
163+
164+
# deepseek-coder-6.7b-base (Wrong)
165+
def sort_ascending(lst):
166+
lst.sort()
167+
return lst
168+
```
169+
170+
### Example 2
171+
Original Problem:
172+
```
173+
Write a function that takes an integer a and returns True if this ingeger is a cube of some integer number. Note: you may assume the input is always valid.
174+
```
175+
176+
New Problem:
177+
```
178+
Write a function that takes an integer a and returns True if this ingeger is a cube of some integer number. Note: you should check whether the input is valid.
179+
```
180+
181+
This problem is challenging because we ask the model to check the inputs' validity rather than assuming the input is always valid. While **Magicoder-*S*-DS-6.7B** successfully check the validity of the input, **deepseek-coder-6.7b-base** wrongly sets `a < 0` as the criterion of invalidity and thus fails to solve the problem.
182+
183+
Response to New Problem:
184+
```python
185+
# Magicoder-S-DS-6.7B (Correct)
186+
def is_cube(a):
187+
if not isinstance(a, int):
188+
return False
189+
if a < 0:
190+
a = -a
191+
return round(a ** (1. / 3)) ** 3 == a
192+
193+
# deepseek-coder-6.7b-base (Wrong)
194+
def is_cube(a):
195+
if a < 0:
196+
return False
197+
else:
198+
for i in range(1, a):
199+
if i**3 == a:
200+
return True
201+
return False
202+
```
203+
204+
</details>
205+
206+
207+
208+
<details>
209+
<summary> <strong> Magicoder's Ability to Use External Libraries </strong> </summary>
210+
211+
We create the following example that requires models to use external libraries for the certain task. While our **Magicoder-*S*-DS-6.7B** successfully follow the instruction in the example, both **deepseek-coder-6.7b-base** and **deepseek-coder-6.7b-instruct** tend to miss some requirements in the instruction.
212+
213+
Prompt:
214+
```
215+
Write a gradio application for the following use case: Take an input image and return a 45 degree clockwise rotated image. You should also add text description under the output showing the rotation degree.
216+
```
217+
218+
This instruction is challenging because our **Magicoder**'s training dataset does not contain the library "gradio" that is necessary for this task. Here are the gradio applications that **Magicoder-*S*-DS-6.7B**, **deepseek-coder-6.7b-instruct**, and **deepseek-coder-6.7b-base** construct respectively:
219+
220+
**Magicoder-*S*-DS-6.7B**: **Correct!**
221+
![Magicoder](assets/magicoder-s-ds.png)
222+
**Magicoder-*S*-DS-6.7B** successfully performs the 45-degree rotation on the input image in the **clockwise** direction. As required in the instruction, it **adds the text description** under the output.
223+
224+
**Deepseek-coder-6.7b-instruct**: Wrong...
225+
![deepseek-coder-6.7b-instruct](assets/ds-coder-instruct.png)
226+
**Deepseek-coder-6.7b-instruct** wrongly performs the 45-degree rotation on the input image in the **counterclockwise** direction. It also **adds the text description** under the output.
227+
228+
**Deepseek-coder-6.7b-base**: Wrong...
229+
![deepseek-coder-6.7b-base](assets/ds-coder-base.png)
230+
**Deepseek-coder-6.7b-base** also wrongly performs the 45-degree rotation on the input image in the **counterclockwise** direction. Even worse, it **misses the text description** under the output.
231+
232+
</details>
233+
234+
129235
## 📝 Citation
130236

131237
```bibtex

assets/ds-coder-base.png

213 KB
Loading

assets/ds-coder-instruct.png

192 KB
Loading

assets/magicoder-s-ds.png

253 KB
Loading

0 commit comments

Comments
 (0)
0