DeepSeek R1 提供多个参数规模的版本,从轻量级的 1.5B 参数模型到高性能的 70B 版本。它基于 Qwen 7B 架构的精简优化版本,既保持强大性能,又具备更高的计算效率。DeepSeekR1

一、DeepSeek R1 简介

 

DeepSeek R1 是一款开源 AI 模型,其性能可与 OpenAI 的 GPT-4 和 Claude 3.5 Sonnet 等顶级模型媲美,尤其在数学、编程和推理等任务上表现出色。最重要的是,它是免费、私密的,可以在本地硬件上离线运行。

DeepSeek R1 提供多个参数规模的版本,从轻量级的 1.5B 参数模型到高性能的 70B 版本。它基于 Qwen 7B 架构的精简优化版本,既保持强大性能,又具备更高的计算效率。

其主要亮点包括:

  • 完全开源,可自由使用。
  • 支持本地运行,无需依赖云服务器。
  • 数据完全可控,确保隐私安全。

 

二、为什么选择本地部署?

本地运行 AI 模型有以下优势:

  • 隐私保障:所有数据均存储在本地,避免敏感信息泄露。
  • 零额外成本:DeepSeek R1 免费运行,无需订阅或额外费用。
  • 完全控制:可以进行微调和本地优化,无需外部依赖。

三、硬件要求

 

四、安装步骤

步骤 1:安装 Ollama

Ollama 是一款本地 AI 运行工具,可帮助用户轻松运行 DeepSeek R1。

下载地址:https://ollama.com/download

安装完成后,Ollama 提供了在终端直接运行 AI 模型的功能。

步骤 2:下载 DeepSeek R1 模型

在终端中运行以下命令,根据你的硬件选择合适的模型:

# 下载 1.5B 版本(适用于 CPU 及低配 GPU)
ollama run deepseek-r1:1.5b

# 下载 8B 版本
ollama run deepseek-r1:8b

# 下载 14B 版本
ollama run deepseek-r1:14b

# 下载 32B 版本
ollama run deepseek-r1:32b

# 下载 70B 版本(最高性能)
ollama run deepseek-r1:70b
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.

如果你不确定选择哪个版本,可以运行默认指令:

ollama run deepseek-r1
  • 1.

默认情况下,该指令会下载 7B 版本。

模型下载速度取决于网络状况,可能需要几分钟到几十分钟不等。

步骤 3:安装 Chatbox(可选)

为了获得更好的交互体验,可以安装 Chatbox 作为 GUI 界面。

下载地址:https://chatboxai.app/en#

安装完成后,进行以下配置:

  • 在“配置 API 模型”选项中选择 Ollama API。
  • 设置 API 主机为:http://127.0.0.1:11434
  • 选择 DeepSeek R1 作为默认模型。
  • 保存设置。

五、功能演示

成功安装后,你可以测试 DeepSeek R1 的能力。例如,让它生成一个用 Python 编写的贪吃蛇游戏代码。

输入 Prompt:

帮我用python写个贪吃蛇的游戏
  • 1.

示例代码(优化修正版本):

import turtle

import time

import random



# 窗口设置

window = turtle.Screen()

window.title("贪吃蛇 by Python")

window.bgcolor("black")

window.setup(width=600, height=600)

window.tracer(0)  # 关闭自动刷新



# 蛇头

snake_head = turtle.Turtle()

snake_head.speed(0)

snake_head.shape("square")

snake_head.color("white")

snake_head.penup()

snake_head.goto(0, 0)

snake_head.direction = "stop"



# 食物

food = turtle.Turtle()

food.speed(0)

food.shape("circle")

food.color("red")

food.penup()

food.goto(0, 100)



segments = []  # 蛇身体段

score = 0  # 得分



# 得分显示

pen = turtle.Turtle()

pen.speed(0)

pen.color("white")

pen.penup()

pen.hideturtle()

pen.goto(0, 260)

pen.write("得分: 0", align="center", font=("Arial", 24, "normal"))



# 移动函数

def move():

    if snake_head.direction == "up":

        y = snake_head.ycor()

        snake_head.sety(y + 20)

    if snake_head.direction == "down":

        y = snake_head.ycor()

        snake_head.sety(y - 20)

    if snake_head.direction == "left":

        x = snake_head.xcor()

        snake_head.setx(x - 20)

    if snake_head.direction == "right":

        x = snake_head.xcor()

        snake_head.setx(x + 20)



# 方向控制函数

def go_up():

    if snake_head.direction != "down":

        snake_head.direction = "up"



def go_down():

    if snake_head.direction != "up":

        snake_head.direction = "down"



def go_left():

    if snake_head.direction != "right":

        snake_head.direction = "left"



def go_right():

    if snake_head.direction != "left":

        snake_head.direction = "right"



# 键盘绑定

window.listen()

window.onkeypress(go_up, "w")

window.onkeypress(go_down, "s")

window.onkeypress(go_left, "a")

window.onkeypress(go_right, "d")



# 碰撞检测

def check_collision():

    # 边界检测

    if snake_head.xcor() > 290 or snake_head.xcor() < -290:

        return True

    if snake_head.ycor() > 290 or snake_head.ycor() < -290:

        return True

    # 身体碰撞检测

    for segment in segments:

        if snake_head.distance(segment) < 20:

            return True

    return False



# 主游戏循环

while True:

    window.update()



    # 检查是否吃到食物

    if snake_head.distance(food) < 20:

        # 移动食物到随机位置

        x = random.randint(-290, 290)

        y = random.randint(-290, 290)

        food.goto(x, y)



        # 增加身体段

        new_segment = turtle.Turtle()

        new_segment.speed(0)

        new_segment.shape("square")

        new_segment.color("grey")

        new_segment.penup()

        segments.append(new_segment)



        # 增加得分

        score += 10

        pen.clear()

        pen.write(f"得分: {score}", align="center", font=("Arial", 24, "normal"))



    # 移动身体段(从后往前)

    for index in range(len(segments)-1, 0, -1):

        x = segments[index-1].xcor()

        y = segments[index-1].ycor()

        segments[index].goto(x, y)



    # 移动第一个身体段到头部位置

    if len(segments) > 0:

        x = snake_head.xcor()

        y = snake_head.ycor()

        segments[0].goto(x, y)



    move()



    # 碰撞检测

    if check_collision():

        time.sleep(1)

        snake_head.goto(0, 0)

        snake_head.direction = "stop"

        # 隐藏身体段

        for segment in segments:

            segment.goto(1000, 1000)

        segments.clear()

        score = 0

        pen.clear()

        pen.write(f"得分: {score}", align="center", font=("Arial", 24, "normal"))


    time.sleep(0.1)
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
  • 158.
  • 159.
  • 160.
  • 161.
  • 162.
  • 163.
  • 164.
  • 165.
  • 166.
  • 167.
  • 168.
  • 169.
  • 170.
  • 171.
  • 172.
  • 173.
  • 174.
  • 175.
  • 176.
  • 177.
  • 178.
  • 179.
  • 180.
  • 181.
  • 182.
  • 183.
  • 184.
  • 185.
  • 186.
  • 187.
  • 188.
  • 189.
  • 190.
  • 191.
  • 192.
  • 193.
  • 194.
  • 195.
  • 196.
  • 197.
  • 198.
  • 199.
  • 200.
  • 201.
  • 202.
  • 203.
  • 204.
  • 205.
  • 206.
  • 207.
  • 208.
  • 209.
  • 210.
  • 211.
  • 212.
  • 213.
  • 214.
  • 215.
  • 216.
  • 217.
  • 218.
  • 219.
  • 220.
  • 221.
  • 222.
  • 223.
  • 224.
  • 225.
  • 226.
  • 227.
  • 228.
  • 229.
  • 230.
  • 231.
  • 232.
  • 233.
  • 234.
  • 235.
  • 236.
  • 237.
  • 238.
  • 239.
  • 240.
  • 241.
  • 242.
  • 243.
  • 244.
  • 245.
  • 246.
  • 247.
  • 248.
  • 249.
  • 250.
  • 251.
  • 252.
  • 253.
  • 254.
  • 255.
  • 256.
  • 257.
  • 258.
  • 259.
  • 260.
  • 261.
  • 262.
  • 263.
  • 264.
  • 265.
  • 266.
  • 267.
  • 268.
  • 269.
  • 270.
  • 271.
  • 272.
  • 273.
  • 274.
  • 275.
  • 276.
  • 277.
  • 278.
  • 279.
  • 280.
  • 281.
  • 282.
  • 283.
  • 284.
  • 285.
  • 286.

运行这个程序前需要确保:

  • 已安装 Python 环境
  • 需要安装 `turtle` 模块(通常 Python 标准库自带)

 

操作说明:

  • W键:向上移动
  • S键:向下移动
  • A键:向左移动
  • D键:向右移动
  • 吃到红色食物会增长身体并加分
  • 撞到墙壁或自己身体会游戏重置

 

游戏特点:

  • 简单的图形界面
  • 分数统计功能
  • 碰撞检测
  • 蛇身自动增长机制
  • 游戏失败重置功能

 

你可以根据需求进一步添加以下功能:

  • 添加开始/暂停按钮
  • 增加难度等级
  • 记录最高分
  • 添加音效
  • 设计更复杂的关卡

 

六、总结

通过本教程,你已经成功在本地部署了 DeepSeek R1,无论你是 AI 爱好者、开发者,还是仅仅对本地 AI 感兴趣,都可以尝试运行并训练自己的专属 AI 资料库。

借助 Ollama 和 Chatbox 等工具,本地运行 AI 变得更加简单和高效。现在就开始探索吧!

文章来自:51CTO

Loading

作者 yinhua

发表回复