GGUF
conversational
wenhuach commited on
Commit
46cc47c
·
verified ·
1 Parent(s): 74ab054

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +416 -0
README.md ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - Qwen/Qwen3-Coder-480B-A35B-Instruct
5
+ datasets:
6
+ - codeparrot/github-code-clean
7
+
8
+ ---
9
+
10
+ ## Model Details
11
+
12
+ This model is a gguf q4km format of [Qwen/Qwen3-Coder-480B-A35B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round) algorithm. Embedding layer and lm-head layer are fallback to 8 bits . Please refer to Section `Generate the model` for more details.
13
+
14
+ Please follow the license of the original model.
15
+
16
+ ## How To Use
17
+
18
+ Llamacpp inference
19
+
20
+ ~~~bash
21
+ /llama-cli -hf Intel/Qwen3-Coder-480B-A35B-Instruct-gguf-q4km-AutoRound:q4_k_m --conversation
22
+
23
+ ~~~
24
+
25
+ ~~~bash
26
+ > Hi
27
+ Hello! How can I help you today?
28
+
29
+ > code flappy bird in python
30
+ # Flappy Bird in Python using Pygame
31
+
32
+ Here's a complete implementation of Flappy Bird using Pygame:
33
+
34
+ ```python
35
+ import pygame
36
+ import random
37
+ import sys
38
+
39
+ # Initialize pygame
40
+ pygame.init()
41
+
42
+ # Game constants
43
+ SCREEN_WIDTH = 400
44
+ SCREEN_HEIGHT = 600
45
+ GRAVITY = 0.25
46
+ FLAP_STRENGTH = -5
47
+ PIPE_SPEED = 3
48
+ PIPE_GAP = 150
49
+ PIPE_FREQUENCY = 1800 # milliseconds
50
+ GROUND_HEIGHT = 100
51
+ FONT_SIZE = 32
52
+
53
+ # Colors
54
+ SKY_BLUE = (113, 197, 207)
55
+ GREEN = (111, 196, 69)
56
+ DARK_GREEN = (76, 145, 65)
57
+ BIRD_YELLOW = (255, 204, 0)
58
+ BIRD_ORANGE = (255, 136, 0)
59
+ WHITE = (255, 255, 255)
60
+ BLACK = (0, 0, 0)
61
+ RED = (231, 76, 60)
62
+
63
+ # Set up the display
64
+ screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
65
+ pygame.display.set_caption("Flappy Bird")
66
+ clock = pygame.time.Clock()
67
+
68
+ # Font
69
+ font = pygame.font.SysFont(None, FONT_SIZE)
70
+ big_font = pygame.font.SysFont(None, FONT_SIZE * 2)
71
+
72
+ class Bird:
73
+ def __init__(self):
74
+ self.x = SCREEN_WIDTH // 3
75
+ self.y = SCREEN_HEIGHT // 2
76
+ self.velocity = 0
77
+ self.radius = 20
78
+ self.alive = True
79
+ self.flap_count = 0
80
+
81
+ def flap(self):
82
+ self.velocity = FLAP_STRENGTH
83
+ self.flap_count += 1
84
+
85
+ def update(self):
86
+ # Apply gravity
87
+ self.velocity += GRAVITY
88
+ self.y += self.velocity
89
+
90
+ # Keep bird on screen
91
+ if self.y < self.radius:
92
+ self.y = self.radius
93
+ self.velocity = 0
94
+
95
+ # Check if bird hit the ground
96
+ if self.y > SCREEN_HEIGHT - GROUND_HEIGHT - self.radius:
97
+ self.y = SCREEN_HEIGHT - GROUND_HEIGHT - self.radius
98
+ self.alive = False
99
+
100
+ def draw(self):
101
+ # Draw bird body
102
+ pygame.draw.circle(screen, BIRD_YELLOW, (self.x, self.y), self.radius)
103
+
104
+ # Draw bird eye
105
+ pygame.draw.circle(screen, BLACK, (self.x + 10, self.y - 5), 6)
106
+ pygame.draw.circle(screen, WHITE, (self.x + 12, self.y - 7), 2)
107
+
108
+ # Draw bird beak
109
+ beak_points = [(self.x + 15, self.y), (self.x + 35, self.y - 5), (self.x + 35, self.y + 5)]
110
+ pygame.draw.polygon(screen, BIRD_ORANGE, beak_points)
111
+
112
+ # Draw wing
113
+ wing_y_offset = 5 if self.flap_count % 10 < 5 else -5
114
+ wing_points = [
115
+ (self.x - 10, self.y),
116
+ (self.x - 20, self.y - 10 + wing_y_offset),
117
+ (self.x, self.y + 5 + wing_y_offset)
118
+ ]
119
+ pygame.draw.polygon(screen, BIRD_ORANGE, wing_points)
120
+
121
+ def get_rect(self):
122
+ return pygame.Rect(self.x - self.radius, self.y - self.radius,
123
+ self.radius * 2, self.radius * 2)
124
+
125
+ class Pipe:
126
+ def __init__(self):
127
+ self.gap_y = random.randint(150, SCREEN_HEIGHT - GROUND_HEIGHT - 150)
128
+ self.x = SCREEN_WIDTH
129
+ self.width = 70
130
+ self.passed = False
131
+
132
+ def update(self):
133
+ self.x -= PIPE_SPEED
134
+
135
+ def draw(self):
136
+ # Draw top pipe
137
+ pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.gap_y - PIPE_GAP // 2))
138
+ pygame.draw.rect(screen, DARK_GREEN, (self.x, self.gap_y - PIPE_GAP // 2 - 20, self.width, 20))
139
+
140
+ # Draw bottom pipe
141
+ pipe_top = self.gap_y + PIPE_GAP // 2
142
+ pygame.draw.rect(screen, GREEN, (self.x, pipe_top, self.width, SCREEN_HEIGHT - pipe_top))
143
+ pygame.draw.rect(screen, DARK_GREEN, (self.x, pipe_top, self.width, 20))
144
+
145
+ def collide(self, bird):
146
+ bird_rect = bird.get_rect()
147
+
148
+ # Top pipe rect
149
+ top_pipe_rect = pygame.Rect(self.x, 0, self.width, self.gap_y - PIPE_GAP // 2)
150
+
151
+ # Bottom pipe rect
152
+ bottom_pipe_rect = pygame.Rect(self.x, self.gap_y + PIPE_GAP // 2,
153
+ self.width, SCREEN_HEIGHT - self.gap_y - PIPE_GAP // 2)
154
+
155
+ return bird_rect.colliderect(top_pipe_rect) or bird_rect.colliderect(bottom_pipe_rect)
156
+
157
+ class Ground:
158
+ def __init__(self):
159
+ self.y = SCREEN_HEIGHT - GROUND_HEIGHT
160
+ self.height = GROUND_HEIGHT
161
+ self.offset = 0
162
+
163
+ def update(self):
164
+ self.offset = (self.offset + PIPE_SPEED) % 40
165
+
166
+ def draw(self):
167
+ pygame.draw.rect(screen, (222, 184, 135), (0, self.y, SCREEN_WIDTH, self.height))
168
+
169
+ # Draw ground details
170
+ for i in range(0, SCREEN_WIDTH + 40, 40):
171
+ pygame.draw.rect(screen, (210, 150, 100),
172
+ (i - self.offset, self.y, 20, self.height))
173
+
174
+ # Draw grass
175
+ pygame.draw.rect(screen, GREEN, (0, self.y, SCREEN_WIDTH, 15))
176
+
177
+ def draw_clouds():
178
+ for i in range(5):
179
+ x = (pygame.time.get_ticks() // 50 + i * 100) % (SCREEN_WIDTH + 200) - 100
180
+ y = 50 + i * 30
181
+ pygame.draw.circle(screen, WHITE, (x, y), 20)
182
+ pygame.draw.circle(screen, WHITE, (x + 15, y - 10), 15)
183
+ pygame.draw.circle(screen, WHITE, (x + 15, y + 10), 15)
184
+ pygame.draw.circle(screen, WHITE, (x + 30, y), 20)
185
+
186
+ def main():
187
+ bird = Bird()
188
+ pipes = []
189
+ ground = Ground()
190
+ score = 0
191
+ last_pipe = pygame.time.get_ticks()
192
+ game_state = "start" # "start", "playing", "game_over"
193
+
194
+ while True:
195
+ current_time = pygame.time.get_ticks()
196
+
197
+ # Event handling
198
+ for event in pygame.event.get():
199
+ if event.type == pygame.QUIT:
200
+ pygame.quit()
201
+ sys.exit()
202
+
203
+ if event.type == pygame.KEYDOWN:
204
+ if event.key == pygame.K_SPACE:
205
+ if game_state == "start":
206
+ game_state = "playing"
207
+ elif game_state == "playing":
208
+ bird.flap()
209
+ elif game_state == "game_over":
210
+ # Reset game
211
+ bird = Bird()
212
+ pipes = []
213
+ score = 0
214
+ last_pipe = current_time
215
+ game_state = "playing"
216
+
217
+ if event.type == pygame.MOUSEBUTTONDOWN:
218
+ if game_state == "start":
219
+ game_state = "playing"
220
+ elif game_state == "playing":
221
+ bird.flap()
222
+ elif game_state == "game_over":
223
+ # Reset game
224
+ bird = Bird()
225
+ pipes = []
226
+ score = 0
227
+ last_pipe = current_time
228
+ game_state = "playing"
229
+
230
+ # Fill the background
231
+ screen.fill(SKY_BLUE)
232
+
233
+ # Draw clouds
234
+ draw_clouds()
235
+
236
+ # Create new pipes
237
+ if game_state == "playing" and current_time - last_pipe > PIPE_FREQUENCY:
238
+ pipes.append(Pipe())
239
+ last_pipe = current_time
240
+
241
+ # Update pipes
242
+ for pipe in pipes[:]:
243
+ if game_state == "playing":
244
+ pipe.update()
245
+
246
+ pipe.draw()
247
+
248
+ # Check for collisions
249
+ if game_state == "playing" and pipe.collide(bird):
250
+ bird.alive = False
251
+ game_state = "game_over"
252
+
253
+ # Check if bird passed the pipe
254
+ if not pipe.passed and pipe.x + pipe.width < bird.x:
255
+ pipe.passed = True
256
+ if game_state == "playing":
257
+ score += 1
258
+
259
+ # Remove pipes that are off screen
260
+ if pipe.x + pipe.width < 0:
261
+ pipes.remove(pipe)
262
+
263
+ # Update and draw ground
264
+ if game_state == "playing":
265
+ ground.update()
266
+ ground.draw()
267
+
268
+ # Update and draw bird
269
+ if game_state == "playing":
270
+ bird.update()
271
+ bird.draw()
272
+
273
+ # Check if bird hit the ground
274
+ if not bird.alive and game_state == "playing":
275
+ game_state = "game_over"
276
+
277
+ # Draw score
278
+ score_text = font.render(f"Score: {score}", True, WHITE)
279
+ screen.blit(score_text, (10, 10))
280
+
281
+ # Draw game state messages
282
+ if game_state == "start":
283
+ title_text = big_font.render("FLAPPY BIRD", True, WHITE)
284
+ screen.blit(title_text, (SCREEN_WIDTH//2 - title_text.get_width()//2, 150))
285
+
286
+ start_text = font.render("Press SPACE or CLICK to start", True, WHITE)
287
+ screen.blit(start_text, (SCREEN_WIDTH//2 - start_text.get_width()//2, 250))
288
+
289
+ elif game_state == "game_over":
290
+ game_over_text = big_font.render("GAME OVER", True, RED)
291
+ screen.blit(game_over_text, (SCREEN_WIDTH//2 - game_over_text.get_width()//2, 150))
292
+
293
+ final_score = font.render(f"Score: {score}", True, WHITE)
294
+ screen.blit(final_score, (SCREEN_WIDTH//2 - final_score.get_width()//2, 220))
295
+
296
+ restart_text = font.render("Press SPACE or CLICK to restart", True, WHITE)
297
+ screen.blit(restart_text, (SCREEN_WIDTH//2 - restart_text.get_width()//2, 270))
298
+
299
+ # Update the display
300
+ pygame.display.flip()
301
+
302
+ # Cap the frame rate
303
+ clock.tick(60)
304
+
305
+ if __name__ == "__main__":
306
+ main()
307
+ ```
308
+
309
+ ## How to Play:
310
+ 1. Press SPACE or click the mouse to start the game
311
+ 2. Press SPACE or click the mouse to make the bird flap and fly upward
312
+ 3. Navigate through the pipes without hitting them
313
+ 4. Each pipe you pass gives you 1 point
314
+ 5. If you hit a pipe or the ground, the game ends
315
+ 6. Press SPACE or click to restart after game over
316
+
317
+ ## Features:
318
+ - Smooth bird physics with gravity and flapping
319
+ - Randomly generated pipes with consistent gaps
320
+ - Animated bird with flapping wings
321
+ - Scrolling ground with texture
322
+ - Moving clouds in the background
323
+ - Score tracking
324
+ - Start screen and game over screen
325
+ - Visual feedback for collisions
326
+
327
+ ## Requirements:
328
+ - Python 3.x
329
+ - Pygame library (install with `pip install pygame`)
330
+
331
+ The game includes all the core mechanics of Flappy Bird:
332
+ - Bird movement with gravity
333
+ - Pipe obstacles to navigate through
334
+ - Collision detection
335
+ - Score tracking
336
+ - Game states (start, playing, game over)
337
+
338
+ Enjoy playing!
339
+
340
+
341
+
342
+ ~~~
343
+
344
+
345
+
346
+ ### Generate the model
347
+
348
+ Here is the sample command to reproduce the model. 3*80G
349
+
350
+ ```python
351
+ import torch
352
+ from transformers import AutoModelForCausalLM, AutoTokenizer
353
+ import transformers
354
+ from auto_round import AutoRound
355
+
356
+ model_name = "Qwen/Qwen3-Coder-480B-A35B-Instruct"
357
+
358
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
359
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="cpu", torch_dtype="auto", trust_remote_code=True)
360
+
361
+ block = model.model.layers
362
+ device_map = {}
363
+ layer_config = {}
364
+ for n, m in model.named_modules():
365
+ if n == "lm_head" or isinstance(m, torch.nn.Embedding):
366
+ layer_config[n] = {"bits": 8}
367
+
368
+ for n, m in block.named_modules():
369
+ if isinstance(m, (torch.nn.Linear, transformers.modeling_utils.Conv1D)):
370
+ if "experts" in n and ("shared_experts" not in n):
371
+ if int(n.split('.')[-2]) < 30:
372
+ device = "cuda:0"
373
+ elif int(n.split('.')[-2]) >= 30 and int(n.split('.')[-2]) < 95:
374
+ device = "cuda:1"
375
+
376
+ elif int(n.split('.')[-2]) >= 95:
377
+ device = "cuda:2"
378
+ else:
379
+ device = "cuda:0"
380
+
381
+ n = n[2:]
382
+
383
+ device_map.update({n: device})
384
+
385
+ autoround = AutoRound(
386
+ model=model, tokenizer=tokenizer, device_map=device_map, nsamples=512, dataset="github-code-clean",
387
+ layer_config=layer_config, low_gpu_mem_usage=True)
388
+ autoround.quantize_and_save(format="gguf:q4_k_m", output_dir="/dataset/Qwen3-Coder-480B-A35B-Instruct-q4km")
389
+
390
+ ```
391
+
392
+
393
+
394
+ ## Ethical Considerations and Limitations
395
+
396
+ The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
397
+
398
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
399
+
400
+ ## Caveats and Recommendations
401
+
402
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
403
+
404
+ Here are a couple of useful links to learn more about Intel's AI software:
405
+
406
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
407
+
408
+ ## Disclaimer
409
+
410
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
411
+
412
+ ## Cite
413
+
414
+ @article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
415
+
416
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)