Nan-Do commited on
Commit
debbbde
1 Parent(s): 7b851dd

Added a description including the model's capabilities

Browse files
Files changed (1) hide show
  1. README.md +219 -1
README.md CHANGED
@@ -6,4 +6,222 @@ tags:
6
  - Python
7
  - assistant
8
  - code
9
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  - Python
7
  - assistant
8
  - code
9
+ ---
10
+
11
+ This is proof of concept to see how far LLM's on the smaller side can go when fine-tuned for code generation and understanding.
12
+ The base model is based on OpenLlama-3b and can be found [here](https://huggingface.co/psmathur/orca_mini_3b) and it has been trained using [axolotl](https://github.com/OpenAccess-AI-Collective/axolotl/tree/main).
13
+
14
+ Next I'll show some examples of what the model is currently capable of.
15
+ I have edited the quotes to be able to show the prompts correctly here the model outputs proper markdown.
16
+
17
+ The first sample shows a non-trivial example of the model generating code.
18
+ (Depending on the complexity of the required task the generated code might not work. For example, making the model write code to move the square
19
+ around has proven to be quite difficult.)
20
+ ```
21
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
22
+
23
+ ### Instruction:
24
+ Write Python code to draw a square on the screen using Pygame.
25
+
26
+ ### Response:
27
+ Sure, here's a Python code to draw a square on the screen using PyGame.
28
+ '''python
29
+ import pygame
30
+
31
+ pygame.init()
32
+ window = pygame.display.set_mode((800, 600))
33
+
34
+ def draw(x, y):
35
+ pygame.draw.rect(window, (255, 170, 170), [x, y, 50, 50])
36
+
37
+ running = True
38
+ while running:
39
+ for event in pygame.event.get():
40
+ if event.type == pygame.QUIT:
41
+ running = False
42
+
43
+ # Clear the screen
44
+ window.fill((0, 0, 0))
45
+
46
+ # Draw a square
47
+ x, y = 40, 30
48
+ draw(x, y)
49
+
50
+ # Update the display
51
+ pygame.display.flip()
52
+ '''
53
+ ```
54
+
55
+ Next there are a few samples to show how the model understands the code.
56
+ In this first example the model is able to answer correctly what shape is being drawn and even tells the position correctly,
57
+ it gets the color wrong in this case
58
+ ```
59
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
60
+
61
+ ### Instruction:
62
+ What shape does the following code draw on the screen?
63
+ import pygame
64
+
65
+ pygame.init()
66
+ window = pygame.display.set_mode((800, 600))
67
+
68
+ def draw(x, y):
69
+ pygame.draw.rect(window, (255, 170, 170), [x, y, 50, 50])
70
+
71
+ running = True
72
+ while running:
73
+ for event in pygame.event.get():
74
+ if event.type == pygame.QUIT:
75
+ running = False
76
+
77
+ # Clear the screen
78
+ window.fill((0, 0, 0))
79
+
80
+ # Draw a square
81
+ x, y = 40, 30
82
+ draw(x, y)
83
+
84
+ # Update the display
85
+ pygame.display.flip()
86
+
87
+ ### Response:
88
+ The code will draw a red square at position (40, 30).
89
+ ```
90
+
91
+ To the question about how to improve the code the model answers by adding code to limit the number of frames per second.
92
+ ```
93
+ Below there are some samples generated by the model:
94
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
95
+
96
+ ### Instruction:
97
+ How could you improve the following code?
98
+
99
+ '''python
100
+ import pygame
101
+ from pygame.locals import *
102
+
103
+ pygame.init()
104
+ window = pygame.display.set_mode((800, 600))
105
+
106
+ def main():
107
+ done = False
108
+
109
+ while not done:
110
+ for event in pygame.event.get():
111
+ if event.type == QUIT:
112
+ done = True
113
+
114
+ # Clear the screen
115
+ window.fill((0, 0, 0))
116
+
117
+ # Draw the square
118
+ x, y = 150, 140
119
+ pygame.draw.rect(window, (255, 0, 0), [x, y, 50, 50])
120
+
121
+ # Update the display
122
+ pygame.display.flip()
123
+
124
+ if __name__ == '__main__':
125
+ main()
126
+ '''
127
+
128
+ ### Response:
129
+ You can use `pygame.time.Clock` to control the frames per second and limit the number of frames to prevent
130
+ your program from freezing. Here's a modified version of your code with this addition:
131
+
132
+ '''python
133
+ import pygame
134
+ from pygame.locals import *
135
+
136
+ pygame.init()
137
+ window = pygame.display.set_mode((800, 600))
138
+ clock = pygame.time.Clock()
139
+
140
+ def main():
141
+ done = False
142
+
143
+ targetFPS = 30
144
+ currentFPS = clock.tick(targetFPS) / targetFPS
145
+ maxFrames = int(currentFPS * 60) + 1
146
+ while not done:
147
+ for event in pygame.event.get():
148
+ if event.type == QUIT:
149
+ done = True
150
+
151
+ # Limit frames to targetFPS
152
+ if currentFPS > targetFPS:
153
+ currentFPS = targetFPS
154
+ maxFrames = min(maxFrames, targetFPS * 60)
155
+
156
+ # Clear the screen
157
+ window.fill((0, 0, 0))
158
+
159
+ # Draw the square
160
+ x, y = 150, 140
161
+ pygame.draw.rect(window, (255, 0, 0), [x, y, 50, 50])
162
+
163
+ # Update the display
164
+ pygame.display.flip()
165
+
166
+ if __name__ == '__main__':
167
+ main()
168
+ '''
169
+ ```
170
+
171
+ Finally a example in which the model completely hallucinates the answer. It's an easy leetcode problem.
172
+ The model clearly needs more work in order to deal with these tasks, or perhaps this task is too complicated for its size.
173
+ ```
174
+ Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
175
+
176
+ ### Instruction:
177
+ Solve the following problem using Python 3. Write only the code.
178
+
179
+ ### Input:
180
+ Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
181
+
182
+ You may assume that each input would have exactly one solution, and you may not use the same element twice.
183
+
184
+ You can return the answer in any order.
185
+
186
+
187
+ Example 1:
188
+
189
+ Input: nums = [2,7,11,15], target = 9
190
+ Output: [0,1]
191
+ Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
192
+
193
+ Example 2:
194
+
195
+ Input: nums = [3,2,4], target = 6
196
+ Output: [1,2]
197
+
198
+ Example 3:
199
+
200
+ Input: nums = [3,3], target = 6
201
+ Output: [0,1]
202
+
203
+
204
+
205
+ Constraints:
206
+
207
+ 2 <= nums.length <= 10^4
208
+ -10^9 <= nums[i] <= 10^9
209
+ -10^9 <= target <= 10^9
210
+ Only one valid answer exists.
211
+
212
+
213
+
214
+ ### Response:
215
+ Certainly, here is one potential way to implement a function in Python 3 that effectively solves the problem.
216
+ '''python
217
+ class Solution:
218
+ def twoSum(self, A: List[int], T: int) -> List[int]:
219
+ ans = []
220
+ for x in range(len(A)-1):
221
+ if A[x]+A[x+1] == T:
222
+ ans.append(x)
223
+ else:
224
+ ans.append(x+1)
225
+ return ans
226
+ '''
227
+ ```