wenhuach commited on
Commit
f6e8dfa
·
verified ·
1 Parent(s): 85bc914

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +261 -0
README.md ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - Qwen/Qwen3-235B-A22B-Instruct-2507
5
+ ---
6
+
7
+ ## Model Details
8
+
9
+ This model is a mixed gguf:q2ks of [Qwen/Qwen3-235B-A22B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-235B-A22B-Instruct-2507) 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.
10
+
11
+ ## How To Use
12
+
13
+ ### LLamacpp Inference
14
+
15
+ ~~~bash
16
+ ./llama-cli -hf Intel/Qwen3-235B-A22B-Instruct-2507-gguf-q2ks-mixed-AutoRound-inc:q2_k_s --conversation
17
+ ~~~
18
+
19
+
20
+ ~~~python
21
+ """
22
+ > Hi
23
+ Hello! How can I help you today? 😊
24
+
25
+ > code a flappy bird in Python
26
+ Sure! Here's a simple **Flappy Bird** game implemented in Python using the **Pygame** library.
27
+
28
+ ---
29
+
30
+ ### 🔧 Requirements:
31
+ Make sure you have **Pygame** installed:
32
+
33
+ ```bash
34
+ pip install pygame
35
+ ```
36
+
37
+ ---
38
+
39
+ ### 🐤 Flappy Bird in Python
40
+
41
+ ```python
42
+ import pygame
43
+ import random
44
+ import sys
45
+
46
+ # Initialize Pygame
47
+ pygame.init()
48
+
49
+ # Screen dimensions
50
+ WIDTH, HEIGHT = 400, 600
51
+ screen = pygame.display.set_mode((WIDTH, HEIGHT))
52
+ pygame.display.set_caption("Flappy Bird")
53
+
54
+ # Colors
55
+ WHITE = (255, 255, 255)
56
+ BLACK = (0, 0, 0)
57
+ GREEN = (0, 128, 0)
58
+ SKY_BLUE = (135, 206, 235)
59
+
60
+ # Game settings
61
+ GRAVITY = 0.5
62
+ FLAP_STRENGTH = -10
63
+ PIPE_SPEED = 3
64
+ PIPE_GAP = 150
65
+ PIPE_FREQUENCY = 1500 # milliseconds
66
+
67
+ # Bird class
68
+ class Bird:
69
+ def __init__(self):
70
+ self.x = 50
71
+ self.y = HEIGHT // 2
72
+ self.velocity = 0
73
+ self.width = 20
74
+ self.height = 20
75
+
76
+ def flap(self):
77
+ self.velocity = FLAP_STRENGTH
78
+
79
+ def update(self):
80
+ self.velocity += GRAVITY
81
+ self.y += self.velocity
82
+ if self.y < 0:
83
+ self.y = 0
84
+ if self.y > HEIGHT:
85
+ self.y = HEIGHT
86
+
87
+ def draw(self):
88
+ pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
89
+
90
+ # Pipe class
91
+ class Pipe:
92
+ def __init__(self):
93
+ self.x = WIDTH
94
+ self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
95
+ self.bottom = self.top + PIPE_GAP
96
+ self.width = 50
97
+ self.passed = False
98
+
99
+ def update(self):
100
+ self.x -= PIPE_SPEED
101
+ return self.x > -self.width
102
+
103
+ def draw(self):
104
+ pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
105
+ pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
106
+
107
+ def collide(self, bird):
108
+ if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
109
+ if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
110
+ return True
111
+ return False
112
+
113
+ # Main game loop
114
+ def game():
115
+ bird = Bird()
116
+ pipes = []
117
+ score = 0
118
+ clock = pygame.time.Clock()
119
+ last_pipe = pygame.time.get_ticks()
120
+
121
+ running = True
122
+ game_active = True
123
+
124
+ font = pygame.font.SysFont(None, 55)
125
+
126
+ while running:
127
+ screen.fill(SKY_BLUE)
128
+ dt = clock.tick(60)
129
+ current_time = pygame.time.get_ticks()
130
+
131
+ # Event handling
132
+ for event in pygame.event.get():
133
+ if event.type == pygame.QUIT:
134
+ pygame.quit()
135
+ sys.exit()
136
+ if event.type == pygame.KEYDOWN:
137
+ if event.key == pygame.K_SPACE and game_active:
138
+ bird.flap()
139
+ if event.key == pygame.K_r and not game_active:
140
+ game()
141
+
142
+ if game_active:
143
+ # Update bird
144
+ bird.update()
145
+
146
+ # Generate new pipes
147
+ if current_time - last_pipe > PIPE_FREQUENCY:
148
+ pipes.append(Pipe())
149
+ last_pipe = current_time
150
+
151
+ # Update and draw pipes
152
+ pipes = [p for p in pipes if p.update()]
153
+ for pipe in pipes:
154
+ pipe.draw()
155
+ if pipe.collide(bird):
156
+ game_active = False
157
+
158
+ # Score logic
159
+ if pipe.x + pipe.width < bird.x and not pipe.passed:
160
+ score += 1
161
+ pipe.passed = True
162
+
163
+ # Draw bird
164
+ bird.draw()
165
+
166
+ # Check if bird hits the ground or flies too high
167
+ if bird.y >= HEIGHT or bird.y <= 0:
168
+ game_active = False
169
+
170
+ # Display score
171
+ score_text = font.render(f"Score: {score}", True, BLACK)
172
+ screen.blit(score_text, (10, 10))
173
+
174
+ else:
175
+ # Game over screen
176
+ game_over_text = font.render("Game Over!", True, BLACK)
177
+ restart_text = font.render("Press 'R' to Restart", True, BLACK)
178
+ screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
179
+ screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
180
+
181
+ pygame.display.update()
182
+
183
+ # Start the game
184
+ game()
185
+ ```
186
+
187
+ ---
188
+
189
+ ### 🎮 How to Play:
190
+ - Press **Spacebar** to flap the bird upward.
191
+ - Avoid hitting the pipes or the ground.
192
+ - When you die, press **'R'** to restart.
193
+
194
+ ---
195
+
196
+ ### ✅ Features:
197
+ - Gravity and flap mechanics.
198
+ - Random pipe generation.
199
+ - Collision detection.
200
+ - Score tracking.
201
+ - Simple graphics using shapes.
202
+
203
+ ---
204
+
205
+ Let me know if you'd like to add images, sounds, or improve the visuals! 🐦💨
206
+
207
+
208
+ """
209
+
210
+ ~~~
211
+
212
+ ### Generate the model
213
+
214
+ auto-round>0.5.1
215
+
216
+ ~~~python
217
+ import torch
218
+ from transformers import AutoModelForCausalLM, AutoTokenizer
219
+ from auto_round import AutoRound
220
+
221
+ model_name = "Qwen/Qwen3-235B-A22B-Instruct-2507"
222
+
223
+ model = AutoModelForCausalLM.from_pretrained(model_name,
224
+ device_map="cpu", torch_dtype="auto")
225
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
226
+ layer_config = {}
227
+ for n, m in model.named_modules():
228
+ if n == "lm_head" or isinstance(m,torch.nn.Embedding):
229
+ layer_config[n] = {"bits": 8}
230
+ elif isinstance(m, torch.nn.Linear) and (not "expert" in n or "shared_experts" in n) and n != "lm_head":
231
+ layer_config[n] = {"bits": 4}
232
+
233
+ autoround = AutoRound(model, tokenizer, iters=0, layer_config=layer_config, nsamples=512)
234
+ autoround.quantize_and_save("/models/Qwen3-235B-A22B-Instruct-2507-q2ks", format="gguf:q2_k_s")
235
+
236
+ ~~~
237
+
238
+
239
+ ## Ethical Considerations and Limitations
240
+
241
+ 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.
242
+
243
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
244
+
245
+ ## Caveats and Recommendations
246
+
247
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
248
+
249
+ Here are a couple of useful links to learn more about Intel's AI software:
250
+
251
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
252
+
253
+ ## Disclaimer
254
+
255
+ 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.
256
+
257
+ ## Cite
258
+
259
+ @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} }
260
+
261
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)