GGUF
conversational
wenhuach commited on
Commit
9031c8c
·
verified ·
1 Parent(s): bef62c0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +277 -3
README.md CHANGED
@@ -1,3 +1,277 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ## Model Details
10
+
11
+ This model is a mixed gguf q2ks 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 and non expert layers are fallback to 4 bits. Please refer to Section `Generate the model` for more details.
12
+
13
+ Please follow the license of the original model.
14
+
15
+ ## How To Use
16
+
17
+ Llamacpp inference
18
+
19
+ ~~~bash
20
+ /llama-cli -hf Intel/Qwen3-Coder-480B-A35B-Instruct-gguf-q2ks-mixed-AutoRound:q2_k_s --conversation
21
+
22
+ ~~~
23
+
24
+ ~~~ba
25
+ > code a flappy bird in python
26
+ Here's a complete Flappy Bird implementation using Pygame:
27
+
28
+ ```python
29
+ import pygame
30
+ import random
31
+ import sys
32
+
33
+ # Initialize pygame
34
+ pygame.init()
35
+
36
+ # Game constants
37
+ WIDTH, HEIGHT = 400, 600
38
+ FPS = 60
39
+ GRAVITY = 0.5
40
+ JUMP = -10
41
+ PIPE_SPEED = 3
42
+ PIPE_GAP = 150
43
+ PIPE_FREQUENCY = 1500 # milliseconds
44
+
45
+ # Colors
46
+ WHITE = (255, 255, 255)
47
+ BLACK = (0, 0, 0)
48
+ GREEN = (0, 255, 0)
49
+ BLUE = (0, 100, 255)
50
+
51
+ # Create game window
52
+ screen = pygame.display.set_mode((WIDTH, HEIGHT))
53
+ pygame.display.set_caption("Flappy Bird")
54
+ clock = pygame.time.Clock()
55
+
56
+ # Font
57
+ font = pygame.font.SysFont(None, 36)
58
+
59
+ class Bird:
60
+ def __init__(self):
61
+ self.x = 50
62
+ self.y = HEIGHT // 2
63
+ self.velocity = 0
64
+ self.radius = 15
65
+
66
+ def jump(self):
67
+ self.velocity = JUMP
68
+
69
+ def update(self):
70
+ self.velocity += GRAVITY
71
+ self.y += self.velocity
72
+
73
+ def draw(self):
74
+ pygame.draw.circle(screen, BLUE, (self.x, int(self.y)), self.radius)
75
+
76
+ def get_rect(self):
77
+ return pygame.Rect(
78
+ self.x - self.radius,
79
+ self.y - self.radius,
80
+ self.radius * 2,
81
+ self.radius * 2
82
+ )
83
+
84
+ class Pipe:
85
+ def __init__(self):
86
+ self.x = WIDTH
87
+ self.height = random.randint(50, HEIGHT - PIPE_GAP - 50)
88
+ self.width = 50
89
+ self.passed = False
90
+
91
+ def update(self):
92
+ self.x -= PIPE_SPEED
93
+
94
+ def draw(self):
95
+ # Top pipe
96
+ pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.height))
97
+ # Bottom pipe
98
+ pygame.draw.rect(screen, GREEN, (self.x, self.height + PIPE_GAP, self.width, HEIGHT))
99
+
100
+ def collide(self, bird):
101
+ bird_rect = bird.get_rect()
102
+ top_pipe = pygame.Rect(self.x, 0, self.width, self.height)
103
+ bottom_pipe = pygame.Rect(self.x, self.height + PIPE_GAP, self.width, HEIGHT)
104
+ return bird_rect.colliderect(top_pipe) or bird_rect.colliderect(bottom_pipe)
105
+
106
+ def off_screen(self):
107
+ return self.x < -self.width
108
+
109
+ def draw_ground():
110
+ pygame.draw.line(screen, BLACK, (0, HEIGHT - 50), (WIDTH, HEIGHT - 50), 5)
111
+
112
+ def main():
113
+ bird = Bird()
114
+ pipes = []
115
+ score = 0
116
+ last_pipe = pygame.time.get_ticks()
117
+ game_over = False
118
+
119
+ while True:
120
+ # Event handling
121
+ for event in pygame.event.get():
122
+ if event.type == pygame.QUIT:
123
+ pygame.quit()
124
+ sys.exit()
125
+ if event.type == pygame.KEYDOWN:
126
+ if event.key == pygame.K_SPACE:
127
+ if game_over:
128
+ # Restart game
129
+ bird = Bird()
130
+ pipes = []
131
+ score = 0
132
+ last_pipe = pygame.time.get_ticks()
133
+ game_over = False
134
+ else:
135
+ bird.jump()
136
+
137
+ if not game_over:
138
+ # Update bird
139
+ bird.update()
140
+
141
+ # Generate new pipes
142
+ current_time = pygame.time.get_ticks()
143
+ if current_time - last_pipe > PIPE_FREQUENCY:
144
+ pipes.append(Pipe())
145
+ last_pipe = current_time
146
+
147
+
148
+ # Update pipes and check for score
149
+ for pipe in pipes:
150
+ pipe.update()
151
+ if not pipe.passed and pipe.x < bird.x:
152
+ pipe.passed = True
153
+ score += 1
154
+
155
+ # Remove off-screen pipes
156
+ pipes = [pipe for pipe in pipes if not pipe.off_screen()]
157
+
158
+ # Check collisions
159
+ if bird.y > HEIGHT - 50 - bird.radius or bird.y < bird.radius:
160
+ game_over = True
161
+ for pipe in pipes:
162
+ if pipe.collide(bird):
163
+ game_over = True
164
+
165
+ # Draw everything
166
+ screen.fill(WHITE)
167
+ for pipe in pipes:
168
+ pipe.draw()
169
+ bird.draw()
170
+ draw_ground()
171
+
172
+ # Draw score
173
+ score_text = font.render(f"Score: {score}", True, BLACK)
174
+ screen.blit(score_text, (10, 10))
175
+
176
+ # Draw game over message
177
+ if game_over:
178
+ game_over_text = font.render("Game Over! Press SPACE to restart", True, BLACK)
179
+ screen.blit(game_over_text, (WIDTH//2 - game_over_text.get_width()//2, HEIGHT//2))
180
+
181
+ pygame.display.flip()
182
+ clock.tick(FPS)
183
+
184
+ if __name__ == "__main__":
185
+ main()
186
+ ```
187
+
188
+ ### Features:
189
+ 1. **Bird Physics**:
190
+ - Gravity pulls the bird down
191
+ - Space bar makes the bird jump upward
192
+
193
+ 2. **Pipe System**:
194
+ - Pipes generate randomly with gaps
195
+ - Pipes move from right to left
196
+ - Collision detection with bird
197
+
198
+ 3. **Scoring**:
199
+ - Score increases when bird passes through pipes
200
+ - Displayed at top-left of screen
201
+
202
+ 4. **Game States**:
203
+ - Active gameplay
204
+ - Game over screen with restart option
205
+
206
+ ### Controls:
207
+ - **SPACE**: Jump (during gameplay) / Restart (after game over)
208
+
209
+ ### Requirements:
210
+ - Python 3.x
211
+ - Pygame (`pip install pygame`)
212
+
213
+ ### Game Mechanics:
214
+ 1. The bird automatically falls due to gravity
215
+ 2. Players must press SPACE to make the bird jump
216
+ 3. Avoid hitting pipes or the ground
217
+ 4. Each pipe passed increases the score by 1
218
+ 5. When game over occurs, press SPACE to restart
219
+
220
+ This implementation includes all core Flappy Bird mechanics in a single file with minimal dependencies. The game features smooth animations, collision detection, and score tracking.
221
+
222
+
223
+ ~~~
224
+
225
+
226
+
227
+ ### Generate the model
228
+
229
+ Here is the sample command to reproduce the model
230
+
231
+ ```python
232
+ import torch
233
+ from transformers import AutoModelForCausalLM, AutoTokenizer
234
+ from auto_round import AutoRound
235
+
236
+ model_name = "/data2/Qwen3-Coder-480B-A35B-Instruct"
237
+
238
+ model = AutoModelForCausalLM.from_pretrained(model_name,
239
+ device_map="cpu", torch_dtype="auto")
240
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
241
+ layer_config = {}
242
+ for n, m in model.named_modules():
243
+ if n == "lm_head" or isinstance(m, torch.nn.Embedding):
244
+ layer_config[n] = {"bits": 8}
245
+ elif isinstance(m, torch.nn.Linear) and (not "expert" in n or "shared_experts" in n) and n != "lm_head":
246
+ layer_config[n] = {"bits": 4}
247
+
248
+ autoround = AutoRound(model, tokenizer, iters=0, layer_config=layer_config, nsamples=512, dataset="github-code-clean")
249
+ autoround.quantize_and_save("/dataset/Qwen3-Coder-480B-A35B-Instruct-q2ks", format="gguf:q2_k_s")
250
+
251
+ ```
252
+
253
+
254
+
255
+ ## Ethical Considerations and Limitations
256
+
257
+ 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.
258
+
259
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
260
+
261
+ ## Caveats and Recommendations
262
+
263
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
264
+
265
+ Here are a couple of useful links to learn more about Intel's AI software:
266
+
267
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
268
+
269
+ ## Disclaimer
270
+
271
+ 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.
272
+
273
+ ## Cite
274
+
275
+ @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} }
276
+
277
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)