网站首页 > 文章精选 正文
2024年6月18日 DeepSeek 官方消息,DeepSeek 发布了一款名为 DeepSeek-Coder-V2的开源模型,这一模型在代码和数学能力方面超越了 GPT-4-Turbo。
DeepSeek-Coder-V2 是一个开源的混合专家 (MoE) 代码语言模型,在代码特定任务中达到了与 GPT4-Turbo 相当的性能。具体来说,DeepSeek-Coder-V2 从 DeepSeek-V2 的中间检查点进一步预训练,额外添加了 6 万亿个 token。通过这种持续的预训练,DeepSeek-Coder-V2 大幅增强了 DeepSeek-V2 的编码和数学推理能力,同时在一般语言任务中保持了相当的性能。与 DeepSeek-Coder-33B 相比,DeepSeek-Coder-V2 在代码相关任务的各个方面以及推理和通用能力方面都有了显著的进步。此外,DeepSeek-Coder-V2 对编程语言的支持从 86 种扩展到 338 种,同时将上下文长度从 16K 扩展到 128K。
github 地址https://github.com/deepseek-ai/DeepSeek-Coder-V2
官方出了4个模型,16B 2个版本 DeepSeek-Coder-V2-Lite-Base 、DeepSeek-Coder-V2-Lite-Instruct 模型以及236B 的 DeepSeek-Coder-V2-Base和DeepSeek-Coder-V2-Instruct 模型
模型下载地址:https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct
https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Base
https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Base
https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct
下面我们给大家在官方网站体验一下的代码生成能力
1.官方体验地址
https://chat.deepseek.com/
新户可以通过手机号码注册登录,这里我们就做详细开展了。登录后我们进入deepseek 对话窗口。
我们看到有2个模型,一个是通用对话模型v2,一个是代码助手V2模型,我们选择代码助手V2模型
2.官方体验测试
我们首先提问:你好,你是谁?
立刻返回消息,速度还挺快的。下面我让给它给生成一段程序代码。
我们的问题: 请我使用 python 生成俄罗斯方块的代码
接下来它给我生成我要的代码并做了代码详细注释
这部分是告诉我需要运行这个代码需要安装pygame 的依赖包。我们按照他们的步骤在本地电脑上安装这个依赖包,这个安装没有问题。
接下来它生成完整的代码
完整的代码如下:
import pygame
import random
# 初始化Pygame
pygame.init()
# 设置窗口大小
width, height = 300, 600
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("俄罗斯方块")
# 定义颜色
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
# 定义方块大小
block_size = 30
# 定义游戏区域
grid_width = 10
grid_height = 20
grid = [[0 for _ in range(grid_width)] for _ in range(grid_height)]
# 定义方块形状
shapes = [
[[1, 1, 1, 1]],
[[1, 1], [1, 1]],
[[1, 1, 0], [0, 1, 1]],
[[0, 1, 1], [1, 1, 0]],
[[1, 1, 1], [0, 1, 0]],
[[1, 1, 1], [1, 0, 0]],
[[1, 1, 1], [0, 0, 1]]
]
# 随机选择一个方块形状
def new_piece():
return random.choice(shapes)
# 检查方块是否可以移动到指定位置
def valid_move(shape, x, y):
for i in range(len(shape)):
for j in range(len(shape[i])):
if shape[i][j] and (x + j < 0 or x + j >= grid_width or y + i >= grid_height or grid[y + i][x + j]):
return False
return True
# 将方块放置到游戏区域
def place_piece(shape, x, y):
for i in range(len(shape)):
for j in range(len(shape[i])):
if shape[i][j]:
grid[y + i][x + j] = 1
# 清除满行
def clear_lines():
lines_cleared = 0
for i in range(grid_height):
if all(grid[i]):
del grid[i]
grid.insert(0, [0 for _ in range(grid_width)])
lines_cleared += 1
return lines_cleared
# 主循环
def main():
running = True
current_piece = new_piece()
x, y = grid_width // 2 - len(current_piece[0]) // 2, 0
clock = pygame.time.Clock()
fall_time = 0
fall_speed = 500
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
if valid_move(current_piece, x - 1, y):
x -= 1
if event.key == pygame.K_RIGHT:
if valid_move(current_piece, x + 1, y):
x += 1
if event.key == pygame.K_DOWN:
if valid_move(current_piece, x, y + 1):
y += 1
if event.key == pygame.K_UP:
rotated_piece = list(zip(*current_piece[::-1]))
if valid_move(rotated_piece, x, y):
current_piece = rotated_piece
# 方块下落
fall_time += clock.get_rawtime()
clock.tick()
if fall_time > fall_speed:
if valid_move(current_piece, x, y + 1):
y += 1
else:
place_piece(current_piece, x, y)
clear_lines()
current_piece = new_piece()
x, y = grid_width // 2 - len(current_piece[0]) // 2, 0
if not valid_move(current_piece, x, y):
running = False
fall_time = 0
# 绘制游戏区域
screen.fill(BLACK)
for i in range(grid_height):
for j in range(grid_width):
if grid[i][j]:
pygame.draw.rect(screen, WHITE, (j * block_size, i * block_size, block_size, block_size), 0)
for i in range(len(current_piece)):
for j in range(len(current_piece[i])):
if current_piece[i][j]:
pygame.draw.rect(screen, RED, ((x + j) * block_size, (y + i) * block_size, block_size, block_size), 0)
pygame.display.flip()
pygame.quit()
if __name__ == "__main__":
main( )
大概花费了10秒多钟的时间,它将我要的游戏代码(俄罗斯方块的代码)全部输出。我们将代码保存本地电脑上fangkuai.py
接下来我们输入cmd 窗口运行以上代码。(前面我们已经将pygame 依赖包安装完成)
python fangkuai.py
这里我们一行代码都没有修改,它居然能够运行起来。实际测试还不错。
接下来我们在给它提问:请在以上代码的基础上,增加积分功能
以上是代码的回复片段,详细代码这里就不仔细贴了。我们用同样的方式运行
python fangkuai2.py
上面的画面显示了积分功能。也是一样代码都没有修改。哈哈,这也太强大了吧。
当然有的小伙伴觉的 这个功能太简单了,能不能增加双人对战呢? 这个感兴趣小伙伴自己研究了,可以通过继续聊天的方式让DeepSeek-Coder-V2模型来帮我们实现。
3.本地电脑搭建
DeepSeek 刚开源DeepSeek-Coder-V2模型后,ollama 在几个小时后很快就已经适配和实现在ollama 上运行这个模型了。
2个模型 236B和 16B 这2个版本模型都已经有了。下面简单介绍一下本地电脑上部署安装DeepSeek-Coder-V2 这个模型。
模型下载
这里我们需要下载ollama 最新版本,下载地址https://ollama.com/#/
下载完成后,一路NEXT点击安装即可。windows平台安装还是非常简单的。 接下来我们下载模型
ollama pull deepseek-coder-v2:16b
输入以上命令,等待模型下载。
模型检查
ollama list
我们输入以上命令,在模型列表中显示以上模型。
模型运行
ollama run deepseek-coder-v2:16b
等待模型加载完成后就可以使用了
模型测试
我们可以通过CMD 窗口来实现聊天对话了。大家如果觉的不方便可以使用chatbox 来使用
chatbox 聊天测试
关于chatbox 工具的安装这里我们就不做详细展开了。下载地址https://github.com/Bin-Huang/chatbox/releases
我们简单说一下它的配置。安装好chatbox后,打开 设置
在模型选择列表中查找ollama
api 地址填写 127.0.0.1:11434 模型列表中选择deepseek-coder-v2:16b
完成以上设置保存,后面就可以聊天对话了。
我们把生成的代码复制保存,然后按照上面同样的方式运行。
同样这个16B的小模型生成的代码也同样能够运行。 太赞了。
4.总结
本次我们使用官方网站提供deepseek-coder-v2 236B模型给大家演示了 俄罗斯方块游戏的制作。后面我们又使用了ollama 在本地电脑上搭建了eepseek-coder-v2 16B 量化的小模型来生成贪吃蛇游戏。测试体验下来这个代码生成能力确实挺强的。感兴趣的小伙伴可以来尝试。本期分享就到这里,我们下个文章见。
猜你喜欢
- 2024-12-30 简单的使用SpringBoot整合SpringSecurity
- 2024-12-30 Spring Security 整合OAuth2 springsecurity整合oauth2+jwt+vue
- 2024-12-30 一个数组一行代码,Spring Security就接管了Swagger认证授权
- 2024-12-30 简单漂亮的(图床工具)开源图片上传工具——PicGo
- 2024-12-30 Spring Boot(十一):Spring Security 实现权限控制
- 2024-12-30 绝了!万字搞定 Spring Security,写得太好了
- 2024-12-30 SpringBoot集成Spring Security springboot集成springsecurity
- 2024-12-30 SpringSecurity密码加密方式简介 spring 密码加密
- 2024-12-30 Spring cloud Alibaba 从入门到放弃
- 2024-12-30 基于Spring Security OAuth2认证中心授权模式扩展
- 最近发表
- 标签列表
-
- newcoder (56)
- 字符串的长度是指 (45)
- drawcontours()参数说明 (60)
- unsignedshortint (59)
- postman并发请求 (47)
- python列表删除 (50)
- 左程云什么水平 (56)
- 计算机网络的拓扑结构是指() (45)
- 稳压管的稳压区是工作在什么区 (45)
- 编程题 (64)
- postgresql默认端口 (66)
- 数据库的概念模型独立于 (48)
- 产生系统死锁的原因可能是由于 (51)
- 数据库中只存放视图的 (62)
- 在vi中退出不保存的命令是 (53)
- 哪个命令可以将普通用户转换成超级用户 (49)
- noscript标签的作用 (48)
- 联合利华网申 (49)
- swagger和postman (46)
- 结构化程序设计主要强调 (53)
- 172.1 (57)
- apipostwebsocket (47)
- 唯品会后台 (61)
- 简历助手 (56)
- offshow (61)