Qwen3 4b Code Reasoning
模型简介
Qwen 3 代码推理模型是一个专注于代码生成和逻辑推理的 AI 模型,特别适合编程相关任务。
模型特点
代码生成能力
能够根据需求生成高质量的代码,如贪吃蛇游戏等完整程序
逻辑推理能力
可以准确回答逻辑相关的问题,并进行详细思考
长上下文支持
支持超过10000 tokens的上下文窗口
模型能力
代码生成
逻辑推理
编程问答
代码补全
使用案例
编程教育
教学示例生成
生成完整的编程示例用于教学
如生成可运行的贪吃蛇游戏代码
开发辅助
代码片段生成
根据需求生成特定功能的代码片段
快速实现特定功能
🚀 Qwen 3 代码推理模型
Qwen 3 代码推理模型是一个基于 Qwen 3 的 40 亿参数小型模型,该模型在特定数据集上进行训练,专为编码任务而设计,能有效处理代码生成和逻辑问答等场景。
由 reveai.org 生成
🚀 快速开始
推荐参数
- 上下文窗口:> 10000
- 温度(Temperature):0.7
- 核采样概率(Top_p):60
- 采样数量(Top_k):0.99
- 最小概率阈值(Min_p):0.05
推荐使用方式
GGUF 版本
✨ 主要特性
优点
- 代码生成:能够根据需求生成高质量的代码。
- 逻辑问答:可以准确回答逻辑相关的问题。
缺点
- 过度思考:在处理某些问题时,可能会花费过多时间进行思考。
- 上下文溢出:当上下文窗口较大时,可能会出现溢出问题。
📦 安装指南
运行示例代码前,请确保安装 pygame
:
pip install pygame
💻 使用示例
基础用法
当询问“用 Python 编写一个贪吃蛇游戏。确保所有按键绑定(WASD)正常工作,并且原始贪吃蛇游戏的所有机制都能正常运行。 /think”时,模型会进行思考:
<think>
Okay, I need to write a Snake game in Python where all the keybindings (WASD) work properly and all the original mechanics are included. Let me think about how to approach this.
First, I remember that the classic Snake game works by having a snake move in a direction, grow when it eats food, and die if it hits the wall or itself. The keybindings should allow the snake to change direction using W, A, S, D. But I need to make sure that the movement is smooth and that the snake can't reverse direction immediately, which might cause it to collide with itself right away.
So, the plan is to use the pygame library because it's commonly used for game development in Python. I'll need to initialize the game window, set up the display, handle the game loop, manage the snake's movement, check for collisions, and handle the food.
Let me outline the steps:
Import necessary modules: Pygame, sys, random for generating food, time for delay.
Initialize Pygame: Set up the display, clock, fonts, etc.
Define constants: Screen size, grid size (like 20x20), snake speed, colors.
Create the Snake class: Each segment of the snake. The snake moves in a direction, and each segment follows the previous one.
Create the Food class: Randomly placed on the screen, and when eaten, the snake grows.
Game loop:
Handle events (WASD for direction).
Move the snake.
Check for collisions (walls or self).
Check if food is eaten, then increase length.
Update the display.
Control the game speed with a clock.
Handle keybindings: Make sure that the snake can't reverse direction. So, if the current direction is right, the next can't be left, and so on.
Wait, but in the original Snake game, ...(Too long)
</think>
以下是使用 pygame
库实现的完整的贪吃蛇游戏代码:
import pygame
import sys
import random
# Initialize Pygame
pygame.init()
# Game settings
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
BLOCK_SIZE = 20
GRID_WIDTH = SCREEN_WIDTH // BLOCK_SIZE
GRID_HEIGHT = SCREEN_HEIGHT // BLOCK_SIZE
# Colors
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
# Initialize screen
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Snake Game")
# Clock
clock = pygame.time.Clock()
# Snake
snake_segments = [(3, 3), (2, 3), (1, 3)]
direction = (1, 0) # Start moving right
# Food
def generate_food():
while True:
x = random.randint(0, GRID_WIDTH - 1)
y = random.randint(0, GRID_HEIGHT - 1)
if (x, y) not in snake_segments:
return (x, y)
food = generate_food()
# Game loop
running = True
ate_food = False
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
direction = (0, -1)
elif event.key == pygame.K_a:
direction = (-1, 0)
elif event.key == pygame.K_s:
direction = (0, 1)
elif event.key == pygame.K_d:
direction = (1, 0)
# Move the snake
new_head = (snake_segments[0][0] + direction[0], snake_segments[0][1] + direction[1])
snake_segments.insert(0, new_head)
if not ate_food:
snake_segments.pop()
ate_food = False
# Check for collisions
if (new_head[0] < 0 or new_head[0] >= GRID_WIDTH or
new_head[1] < 0 or new_head[1] >= GRID_HEIGHT):
pygame.quit()
sys.exit()
if new_head in snake_segments[1:]:
pygame.quit()
sys.exit()
# Check if food is eaten
if new_head == food:
food = generate_food()
ate_food = True
# Draw everything
screen.fill(BLACK)
for segment in snake_segments:
pygame.draw.rect(screen, GREEN, (segment[0] * BLOCK_SIZE, segment[1] * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE))
pygame.draw.rect(screen, RED, (food[0] * BLOCK_SIZE, food[1] * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE))
pygame.display.flip()
# Control the game speed
clock.tick(10)
pygame.quit()
sys.exit()
运行步骤
- 安装
pygame
库:
pip install pygame
- 将上述代码保存为文件,例如
snake_game.py
。 - 使用 Python 运行该文件:
python snake_game.py
🚀 提示
- 游戏节奏较快,你可以通过增大
clock.tick(10)
中的值来减慢速度(例如clock.tick(15)
)。 - 贪吃蛇初始位于屏幕中央,食物随机放置。
尽情享受 贪吃蛇游戏 吧!🐍🎮
📄 许可证
本项目采用 Apache-2.0 许可证。
相关信息
属性 | 详情 |
---|---|
基础模型 | unsloth/Qwen3 - 4B、Qwen/Qwen3 - 4B |
训练数据集 | nvidia/OpenCodeReasoning、vicgalle/creative - rubrics - gpt - 4.5 - o3 - R1 |
标签 | unsloth、trl、sft、code、coding、cot、reasoning、thinking、think |
任务类型 | 文本生成 |
Phi 2 GGUF
其他
Phi-2是微软开发的一个小型但强大的语言模型,具有27亿参数,专注于高效推理和高质量文本生成。
大型语言模型 支持多种语言
P
TheBloke
41.5M
205
Roberta Large
MIT
基于掩码语言建模目标预训练的大型英语语言模型,采用改进的BERT训练方法
大型语言模型 英语
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基础模型的蒸馏版本,在保持相近性能的同时更轻量高效,适用于序列分类、标记分类等自然语言处理任务。
大型语言模型 英语
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一个多语言大语言模型,针对多语言对话用例进行了优化,在常见的行业基准测试中表现优异。
大型语言模型 英语
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基于100种语言的2.5TB过滤CommonCrawl数据预训练的多语言模型,采用掩码语言建模目标进行训练。
大型语言模型 支持多种语言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基于Transformer架构的英语预训练模型,通过掩码语言建模目标在海量文本上训练,支持文本特征提取和下游任务微调
大型语言模型 英语
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI发布的开放预训练Transformer语言模型套件,参数量从1.25亿到1750亿,旨在对标GPT-3系列性能,同时促进大规模语言模型的开放研究。
大型语言模型 英语
O
facebook
6.3M
198
1
基于transformers库的预训练模型,适用于多种NLP任务
大型语言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多语言大语言模型系列,包含8B、70B和405B参数规模,支持8种语言和代码生成,优化了多语言对话场景。
大型语言模型
Transformers 支持多种语言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基础版是由Google开发的文本到文本转换Transformer模型,参数规模2.2亿,支持多语言NLP任务。
大型语言模型 支持多种语言
T
google-t5
5.4M
702
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98
智启未来,您的人工智能解决方案智库
简体中文