前言
这两天又被DeepSeek刷屏了,真是没有一点点防备,没有一点点预告,DeepSeek又开源了一个V3版本模型 DeepSeek-V3-0324,且悄咪咪的在官网上更新了。听说这次更新后的V3版本不仅延续了之前模型的卓越表现,此次更新更是在 创作、编程和数学能力上有着不错的表现,尤其是编程能力可能已超过Claude 3.5。
模型开源信息
模型发布日志:api-docs.deepseek.com/zh-cn/news/...
模型参数:
- 模型参数约 660B
- 开源版本上下文长度为 128K(网页端、App 和 API 提供 64K 上下文)
模型下载地址:
- Model Scope: modelscope.cn/models/deep...
- Huggingface: huggingface.co/deepseek-ai...
体验方式
官网
官网地址:chat.deepseek.com
可以看到知识库信息已更新到2024年7月
OpenRouter
OpenRouter官网地址:openrouter.ai
可以看到 DeepSeek V3 0324 在OpenRouter上目前是免费使用的
我们可以在线使用,也可以使用OpenRouter API进行调用,想OpenRouter更多信息,可以看往期:大模型统一接入路由器OpenRouter
使用效果
基本推理
这里我将尝试使用之前AI容易出错的问题进行再次测试
第一个问题:
9.9和9.11哪个大?
DeepSeek默认还是比较数值
✅ 经过引导后,DeepSeek给出了更完整的回答
第二个问题:
strawberry中有几个r?
✅ 这个问题是有进步的
前端UI效果
css
创建一个包含 CSS 和 JavaScript 的单个 HTML 文件,以生成一个动画天气卡片。
- 该卡片应直观地表示以下具有不同动画的天气状况:风(例如,移动的云、摇摆的树木或风线)、雨(例如,下落的雨滴、形成水坑)、太阳(例如,闪耀的光线、明亮的背景)、雪(例如,飘落的雪花、积雪)。
卡片应有一个深色背景。提供该单个文件中的所有 HTML、CSS 和 JavaScript 代码。JavaScript 应包括一种切换不同天气状况的方法(例如,一个函数或一组按钮),以演示每种天气状况的动画。
虽然效果不是很完美,但是从动画效果上看还是有进步的,而且精准标记了天气文字。
css
使用HTML生成一个人工智能发展史页面,内容丰富详细,排版简约美观
编程效果
第一个问题:
使用 Python 编写一个模拟程序演示一个球在一个旋转的六边形内弹跳,要求符合物理重力学
ini
import pygame
import sys
import math
import numpy as np
from pygame.locals import *
# 初始化pygame
pygame.init()
# 设置窗口
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('旋转六边形内的弹球模拟')
# 颜色
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
GRAY = (200, 200, 200)
# 物理参数
FPS = 60
GRAVITY = 0.5
RESTITUTION = 0.8 # 弹性系数
FRICTION = 0.99 # 摩擦系数
# 六边形参数
HEX_RADIUS = 200 # 六边形半径
HEX_CENTER = (WIDTH // 2, HEIGHT // 2) # 六边形中心
hex_angle = 0 # 六边形旋转角度
rotation_speed = 0.01 # 旋转速度
# 球参数
BALL_RADIUS = 15
ball_pos = [HEX_CENTER[0], HEX_CENTER[1] - HEX_RADIUS // 2]
ball_vel = [2, 0]
ball_color = RED
# 获取六边形顶点坐标
def get_hexagon_points(center, radius, angle=0):
points = []
for i in range(6):
theta = angle + math.pi * 2 * i / 6
x = center[0] + radius * math.cos(theta)
y = center[1] + radius * math.sin(theta)
points.append((x, y))
return points
# 计算点到线段的距离
def point_to_line_distance(point, line_start, line_end):
x, y = point
x1, y1 = line_start
x2, y2 = line_end
# 线段长度的平方
l2 = (x2 - x1)**2 + (y2 - y1)**2
if l2 == 0:
return math.sqrt((x - x1)**2 + (y - y1)**2) # 线段退化为点
# 计算投影比例
t = max(0, min(1, ((x - x1) * (x2 - x1) + (y - y1) * (y2 - y1)) / l2))
# 投影点
projection = (x1 + t * (x2 - x1), y1 + t * (y2 - y1))
# 返回点到投影点的距离
return math.sqrt((x - projection[0])**2 + (y - projection[1])**2)
# 计算反射向量
def reflect_vector(vel, normal):
# 规范化法向量
normal = np.array(normal)
normal = normal / np.linalg.norm(normal)
# 计算反射向量
vel = np.array(vel)
reflected = vel - 2 * np.dot(vel, normal) * normal
return reflected.tolist()
# 检测球与六边形边的碰撞
def check_collision(ball_pos, ball_vel, hex_points):
for i in range(6):
start = hex_points[i]
end = hex_points[(i + 1) % 6]
# 计算球到线段的距离
distance = point_to_line_distance(ball_pos, start, end)
if distance <= BALL_RADIUS:
# 计算线段的方向向量
line_vec = (end[0] - start[0], end[1] - start[1])
# 计算线段的法向量(指向六边形内部)
normal = (-line_vec[1], line_vec[0])
# 确保法向量指向六边形内部
# 通过检查中心点到法向量的方向
center_to_point = (ball_pos[0] - HEX_CENTER[0], ball_pos[1] - HEX_CENTER[1])
if np.dot(normal, center_to_point) > 0:
normal = (-normal[0], -normal[1])
# 计算反射后的速度
new_vel = reflect_vector(ball_vel, normal)
# 应用弹性系数和摩擦系数
new_vel[0] *= RESTITUTION * FRICTION
new_vel[1] *= RESTITUTION * FRICTION
# 防止球卡在边界
push_distance = BALL_RADIUS - distance + 1
push_dir = (normal[0] / np.linalg.norm(normal), normal[1] / np.linalg.norm(normal))
ball_pos[0] += push_dir[0] * push_distance
ball_pos[1] += push_dir[1] * push_distance
return new_vel
return ball_vel
# 游戏主循环
clock = pygame.time.Clock()
running = True
while running:
# 处理事件
for event in pygame.event.get():
if event.type == QUIT:
running = False
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
running = False
elif event.key == K_r: # 重置球的位置
ball_pos = [HEX_CENTER[0], HEX_CENTER[1] - HEX_RADIUS // 2]
ball_vel = [2, 0]
# 更新六边形旋转
hex_angle += rotation_speed
# 更新球的位置和速度(应用重力)
ball_vel[1] += GRAVITY
ball_pos[0] += ball_vel[0]
ball_pos[1] += ball_vel[1]
# 获取当前六边形顶点
hex_points = get_hexagon_points(HEX_CENTER, HEX_RADIUS, hex_angle)
# 检测碰撞并更新速度
ball_vel = check_collision(ball_pos, ball_vel, hex_points)
# 清屏
screen.fill(BLACK)
# 绘制六边形
pygame.draw.polygon(screen, GRAY, hex_points, 2)
# 绘制球
pygame.draw.circle(screen, ball_color, (int(ball_pos[0]), int(ball_pos[1])), BALL_RADIUS)
# 更新显示
pygame.display.flip()
# 控制帧率
clock.tick(FPS)
pygame.quit()
sys.exit()
✅ 效果还是蛮不错的
第二个问题:41. 缺失的第一个正数
ini
给你一个未排序的整数数组 nums ,请你找出其中没有出现的最小的正整数。
请你实现时间复杂度为 O(n) 并且只使用常数级别额外空间的解决方案。
示例 1:
输入:nums = [1,2,0]
输出:3
解释:范围 [1,2] 中的数字都在数组中。
示例 2:
输入:nums = [3,4,-1,1]
输出:2
解释:1 在数组中,但 2 没有。
示例 3:
输入:nums = [7,8,9,11,12]
输出:1
解释:最小的正数 1 没有出现。
提示:
1 <= nums.length <= 10(5)
-2(31) <= nums[i] <= 2(31) - 1
===
使用js实现并补充下面函数
var firstMissingPositive = function(nums) {
};
ini
var firstMissingPositive = function(nums) {
const n = nums.length;
// 将所有非正数改为 n + 1
for (let i = 0; i < n; i++) {
if (nums[i] <= 0) {
nums[i] = n + 1;
}
}
// 标记存在的数字
for (let i = 0; i < n; i++) {
const num = Math.abs(nums[i]);
if (num <= n) {
nums[num - 1] = -Math.abs(nums[num - 1]);
}
}
// 找到第一个正数的索引
for (let i = 0; i < n; i++) {
if (nums[i] > 0) {
return i + 1;
}
}
// 如果所有 1 到 n 都存在,返回 n + 1
return n + 1;
};
✅ 回答正确,领扣也通过了测试用例
总结
本人平台编程方面使用DeepSeek比较多,DeepSeek V3这次模型更新相相较于之前版本提升还是挺大的,代码准确率和前端UI编写上都有了明显提升,前端页面还支持了直接运行预览功能,再也不用粘贴代码看效果了👍🏻,下面让我们期待下DeepSeek-R2版本。
常见问题
当前访问人数有点多,可能会出现访问过多提示,重新异常后多试几次
友情提示
见原文:【DeepSeek】DeepSeek-V3-0324发布,代码能力比肩Claude 3.5?
本文同步自微信公众号 "程序员小溪" ,这里只是同步,想看及时消息请移步我的公众号,不定时更新我的学习经验。