DeepSeek模型R1服务器繁忙,怎么解决?

在当今科技飞速发展的时代,人工智能领域不断涌现出令人瞩目的创新成果,其中DeepSeek模型无疑成为了众多关注焦点。它凭借着先进的技术和卓越的性能,在行业内掀起了一股热潮,吸引了无数目光。然而,如同许多前沿技术在发展初期所面临的挑战一样,DeepSeek模型在实际应用中也暴露出了一系列亟待解决的问题,这些问题犹如一道道屏障,限制了其更广泛的应用和深入的发展。而讯飞开放平台,凭借其强大的实力和丰富的经验,正致力于为解决这些痛点提供全面而有效的解决方案。

首先,服务不稳定是DeepSeek模型当前面临的一个突出问题。在实际应用中,用户对于服务的稳定性有着极高的要求。无论是企业的生产运营,还是个人的日常使用,都希望能够获得持续、稳定的服务支持。然而,DeepSeek模型由于各种因素的影响,时常出现服务波动的情况,这给用户带来了极大的困扰。比如,在进行重要任务处理时,突然的服务中断可能导致数据丢失、工作延误等一系列严重后果。讯飞开放平台深知服务稳定性的重要性,通过优化自身的技术架构和服务体系,采用先进的云计算技术和分布式存储方案,确保平台的高可用性和可靠性。同时,讯飞还建立了完善的监控和预警机制,能够实时监测服务的运行状态,及时发现并解决潜在的问题,为用户的使用提供了坚实的保障。

HTTP调用源代码:
 

package day;import com.google.gson.Gson;
import org.json.JSONArray;
import org.json.JSONObject;import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;public class MaasApiClient {public static Gson gson = new Gson();public static void main(String[] args) {try {URL url = new URL("http://maas-api.cn-huabei-1.xf-yun.com/v1/chat/completions");HttpURLConnection connection = (HttpURLConnection) url.openConnection();// 设置请求头connection.setRequestMethod("POST");connection.setRequestProperty("Content-Type", "application/json");connection.setRequestProperty("Authorization", "Bearer ");connection.setDoOutput(true);connection.setChunkedStreamingMode(0); // 啓用分塊傳輸// 构建JSON请求体JSONObject requestBody = new JSONObject();requestBody.put("model", "xdeepseekr1");JSONArray messages = new JSONArray();JSONObject message = new JSONObject();message.put("role", "user");message.put("content", "你是谁?");messages.put(message);requestBody.put("messages", messages);requestBody.put("temperature", 0.01);requestBody.put("stream", true);requestBody.put("max_tokens", 4096);// 发送请求try (OutputStream os = connection.getOutputStream()) {byte[] input = requestBody.toString().getBytes(StandardCharsets.UTF_8);os.write(input, 0, input.length);}// 处理流式返回try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {String line;while ((line = reader.readLine()) != null) {// System.out.println(line);if (!line.contains("[DONE]")) {line = line.replace("data: ", "");// System.out.println(line);JsonParse jsonParse = gson.fromJson(line, JsonParse.class);if (!line.isEmpty()) {List<Choices> choicesList = jsonParse.choices;for (Choices temp : choicesList) {System.out.print(temp.delta.reasoning_content);}}}}}connection.disconnect();} catch (Exception e) {e.printStackTrace();}}
}class JsonParse {List<Choices> choices;
}class Choices {Delta delta;
}class Delta {String reasoning_content;
}

Webscoket调用源代码:

package org.example;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import okhttp3.*;import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;public class BigModelNew extends WebSocketListener {// 以下信息从服务管控页面获取:https://training.xfyun.cn/modelServicepublic static final String hostUrl = "wss://maas-api.cn-huabei-1.xf-yun.com/v1.1/chat"; // 服务地址public static final String appid = "";public static final String apiSecret = "";public static final String apiKey = "";public static final String patch_id = "0";    //调用微调大模型时必传,否则不传。对应为模型服务卡片上的resourceIdpublic static final String domain = "xdeepseekr1";    //从服务管控获取要访问服务的serviceID:https://training.xfyun.cn/modelServicepublic static List<RoleContent> historyList = new ArrayList<>(); // 对话历史存储集合public static String totalAnswer = ""; // 大模型的答案汇总  你是满血671b版本吗// 环境治理的重要性  环保  人口老龄化  我爱我的祖国 你是谁 明天合肥的天气 我的名字叫大王 我叫什么名字// 点评一下安徽的发展和经济,以及工资和发展的差距,说的要直接,可以public static String NewQuestion = "";public static final Gson gson = new Gson();// 个性化参数private String userId;private Boolean wsCloseFlag;private static Boolean totalFlag = true; // 控制提示用户是否输入// 构造函数public BigModelNew(String userId, Boolean wsCloseFlag) {this.userId = userId;this.wsCloseFlag = wsCloseFlag;}// 主函数public static void main(String[] args) throws Exception {// 个性化参数入口,如果是并发使用,可以在这里模拟while (true) {if (totalFlag) {Scanner scanner = new Scanner(System.in);System.out.print("我:");totalFlag = false;NewQuestion = scanner.nextLine();// 构建鉴权urlString authUrl = getAuthUrl(hostUrl, apiKey, apiSecret);OkHttpClient client = new OkHttpClient.Builder().build();String url = authUrl.toString().replace("http://", "ws://").replace("https://", "wss://");Request request = new Request.Builder().url(url).build();for (int i = 0; i < 1; i++) {totalAnswer = "";WebSocket webSocket = client.newWebSocket(request, new BigModelNew(i + "", false));}} else {Thread.sleep(200);}}}public static boolean canAddHistory() {  // 由于历史记录最大上线1.2W左右,需要判断是能能加入历史int history_length = 0;for (RoleContent temp : historyList) {history_length = history_length + temp.content.length();}if (history_length > 12000) {historyList.remove(0);historyList.remove(1);historyList.remove(2);historyList.remove(3);historyList.remove(4);return false;} else {return true;}}// 线程来发送音频与参数class MyThread extends Thread {private WebSocket webSocket;public MyThread(WebSocket webSocket) {this.webSocket = webSocket;}public void run() {try {JSONObject requestJson = new JSONObject();String[] arr = new String[1];arr[0] = patch_id;JSONObject header = new JSONObject();  // header参数header.put("app_id", appid);header.put("uid", UUID.randomUUID().toString().substring(0, 10));header.put("patch_id", arr);JSONObject parameter = new JSONObject(); // parameter参数JSONObject chat = new JSONObject();chat.put("domain", domain); //调用微调大模型时,对应为模型服务卡片上的serviceidchat.put("temperature", 0.5);chat.put("max_tokens", 4096);  //请根据不同模型支持范围,适当调整该值的大小parameter.put("chat", chat);JSONObject payload = new JSONObject(); // payload参数JSONObject message = new JSONObject();JSONArray text = new JSONArray();// 历史问题获取if (historyList.size() > 0) {for (RoleContent tempRoleContent : historyList) {text.add(JSON.toJSON(tempRoleContent));}}// 最新问题RoleContent roleContent = new RoleContent();roleContent.role = "user";roleContent.content = NewQuestion;text.add(JSON.toJSON(roleContent));historyList.add(roleContent);message.put("text", text);payload.put("message", message);requestJson.put("header", header);requestJson.put("parameter", parameter);requestJson.put("payload", payload);System.err.println(requestJson); // 可以打印看每次的传参明细webSocket.send(requestJson.toString());// 等待服务端返回完毕后关闭while (true) {// System.err.println(wsCloseFlag + "---");Thread.sleep(200);if (wsCloseFlag) {break;}}webSocket.close(1000, "");} catch (Exception e) {e.printStackTrace();}}}@Overridepublic void onOpen(WebSocket webSocket, Response response) {super.onOpen(webSocket, response);System.out.print("大模型:");MyThread myThread = new MyThread(webSocket);myThread.start();}@Overridepublic void onMessage(WebSocket webSocket, String text) {// System.out.println(userId + "用来区分那个用户的结果" + text);JsonParse myJsonParse = gson.fromJson(text, JsonParse.class);if (myJsonParse.header.code != 0) {System.out.println("发生错误,错误码为:" + myJsonParse.header.code);System.out.println("本次请求的sid为:" + myJsonParse.header.sid);webSocket.close(1000, "");}List<Text> textList = myJsonParse.payload.choices.text;for (Text temp : textList) {System.out.print(temp.content);totalAnswer = totalAnswer + temp.content;}if (myJsonParse.header.status == 2) {// 可以关闭连接,释放资源System.out.println();System.out.println("*************************************************************************************");if (canAddHistory()) {RoleContent roleContent = new RoleContent();roleContent.setRole("assistant");roleContent.setContent(totalAnswer);historyList.add(roleContent);} else {historyList.remove(0);RoleContent roleContent = new RoleContent();roleContent.setRole("assistant");roleContent.setContent(totalAnswer);historyList.add(roleContent);}wsCloseFlag = true;totalFlag = true;}}@Overridepublic void onFailure(WebSocket webSocket, Throwable t, Response response) {super.onFailure(webSocket, t, response);try {if (null != response) {int code = response.code();System.out.println("onFailure code:" + code);System.out.println("onFailure body:" + response.body().string());if (101 != code) {System.out.println("connection failed");System.exit(0);}}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}// 鉴权方法public static String getAuthUrl(String hostUrl, String apiKey, String apiSecret) throws Exception {String newUrl = hostUrl.toString().replace("ws://", "http://").replace("wss://", "https://");URL url = new URL(newUrl);// 时间SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);format.setTimeZone(TimeZone.getTimeZone("GMT"));String date = format.format(new Date());// 拼接String preStr = "host: " + url.getHost() + "\n" + "date: " + date + "\n" + "GET " + url.getPath() + " HTTP/1.1";// System.err.println(preStr);// SHA256加密Mac mac = Mac.getInstance("hmacsha256");SecretKeySpec spec = new SecretKeySpec(apiSecret.getBytes(StandardCharsets.UTF_8), "hmacsha256");mac.init(spec);byte[] hexDigits = mac.doFinal(preStr.getBytes(StandardCharsets.UTF_8));// Base64加密String sha = Base64.getEncoder().encodeToString(hexDigits);// System.err.println(sha);// 拼接String authorization = String.format("api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"", apiKey, "hmac-sha256", "host date request-line", sha);// 拼接地址HttpUrl httpUrl = Objects.requireNonNull(HttpUrl.parse("https://" + url.getHost() + url.getPath())).newBuilder().//addQueryParameter("authorization", Base64.getEncoder().encodeToString(authorization.getBytes(StandardCharsets.UTF_8))).//addQueryParameter("date", date).//addQueryParameter("host", url.getHost()).//build();//System.err.println(httpUrl.toString());return httpUrl.toString();}//返回的json结果拆解class JsonParse {Header header;Payload payload;}class Header {int code;int status;String sid;}class Payload {Choices choices;}class Choices {List<Text> text;}class Text {String role;String content;}class RoleContent {String role;String content;public String getRole() {return role;}public void setRole(String role) {this.role = role;}public String getContent() {return content;}public void setContent(String content) {this.content = content;}}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/16750.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

w~自动驾驶~合集17

我自己的原文哦~ https://blog.51cto.com/whaosoft/13269720 #FastOcc 推理更快、部署友好Occ算法来啦&#xff01; 在自动驾驶系统当中&#xff0c;感知任务是整个自驾系统中至关重要的组成部分。感知任务的主要目标是使自动驾驶车辆能够理解和感知周围的环境元素&#…

操作系统|ARM和X86的区别,存储,指令集

文章目录 主频寄存器寄存器在硬件中的体现是什么寄存器的基本特性硬件实现寄存器类型 内存和寄存器的区别内存&#xff08;Memory&#xff09;和磁盘&#xff08;Disk&#xff09;指令的执行ARM Cortex-M3与Thumb-2指令集Thumb-2 与流水线虚拟地址指令的执行 多核CPU芯片间的通…

好好说话:深度学习扫盲

大创项目是和目标检测算法YOLO相关的&#xff0c;浅浅了解了一些有关深度学习的知识。在这里根据本人的理解做一些梳理。 深度学习是什么&#xff1f; 之前经常听到AI&#xff0c;机器学习&#xff0c;深度学习这三个概念&#xff0c;但是对于三者的区别一直很模糊。 AI&…

关于 IoT DC3 中设备(Device)的理解

在物联网系统中&#xff0c;设备&#xff08;Device&#xff09;是一个非常宽泛的概念&#xff0c;它可以指代任何能够接入系统并进行数据交互的实体。包括但不限于手机、电脑、服务器、网关、硬件设备甚至是某些软件程序等所有能接入到该平台的媒介。 内容 定义 目的 示例 …

接入 SSL 认证配置:满足等保最佳实践

前言 随着信息安全形势的日益严峻&#xff0c;等保&#xff08;信息安全等级保护&#xff09;要求成为各行业信息系统必须遵守的标准。在数据库领域&#xff0c;OpenGauss作为一款高性能、安全、可靠的开源关系型数据库&#xff0c;也需要满足等保要求&#xff0c;确保数据的安…

【论文阅读】Revisiting the Assumption of Latent Separability for Backdoor Defenses

https://github.com/Unispac/Circumventing-Backdoor-Defenses 摘要和介绍 在各种后门毒化攻击中&#xff0c;来自目标类别的毒化样本和干净样本通常在潜在空间中形成两个分离的簇。 这种潜在的分离性非常普遍&#xff0c;甚至在防御研究中成为了一种默认假设&#xff0c;我…

2024-2025年主流的开源向量数据库推荐

以下是2024-2025年主流的开源向量数据库推荐&#xff0c;涵盖其核心功能和应用场景&#xff1a; 1. Milvus 特点&#xff1a;专为大规模向量搜索设计&#xff0c;支持万亿级向量数据集的毫秒级搜索&#xff0c;适用于图像搜索、聊天机器人、化学结构搜索等场景。采用无状态架…

开源身份和访问管理方案之keycloak(一)快速入门

文章目录 什么是IAM什么是keycloakKeycloak 的功能 核心概念client管理 OpenID Connect 客户端 Client Scoperealm roleAssigning role mappings分配角色映射Using default roles使用默认角色Role scope mappings角色范围映射 UsersGroupssessionsEventsKeycloak Policy创建策略…

【工业场景】用YOLOv8实现火灾识别

火灾识别任务是工业领域急需关注的重点安全事项,其应用场景和背景意义主要体现在以下几个方面: 应用场景:工业场所:在工厂、仓库等工业场所中,火灾是造成重大财产损失和人员伤亡的主要原因之一。利用火灾识别技术可以及时发现火灾迹象,采取相应的应急措施,保障人员安全和…

FlinkCDC 实现 MySQL 数据变更实时同步

文章目录 1、基本介绍2、代码实战 2.1、数据源准备2.2、代码实战2.3、数据格式 1、基本介绍 Flink CDC 是 Apache Flink 提供的一个功能强大的组件&#xff0c;用于实时捕获和处理数据库中的数据变更。可以实时地从各种数据库&#xff08;如MySQL、PostgreSQL、Oracle、Mon…

金融风控项目-1

文章目录 一. 案例背景介绍二. 代码实现1. 加载数据2. 数据处理3. 查询 三. 业务解读 一. 案例背景介绍 通过对业务数据分析了解信贷业务状况 数据集说明 从开源数据改造而来&#xff0c;基本反映真实业务数据销售&#xff0c;客服可以忽略账单周期&#xff0c;放款日期账单金…

CANMV K230入手体验(1)u盘安装镜像

这是安装镜像后的磁盘管理。 使用镜像文件名为&#xff1a; CanMV-K230_01Studio_micropython_v1.2.2-0-g4b8cae1_nncase_v2.9.0.img。 安装结束。 套件的sd卡损坏&#xff0c;已申请更换。 小伙伴们注意sd卡的问题&#xff0c;一个上午过去了。C... 下图是资源管理器的截…

策略模式-小结

总结一下看到的策略模式&#xff1a; A:一个含有一个方法的接口 B:具体的实行方式行为1,2,3&#xff0c;实现上面的接口。 C:一个环境类&#xff08;或者上下文类&#xff09;&#xff0c;形式可以是&#xff1a;工厂模式&#xff0c;构造器注入模式&#xff0c;枚举模式。 …

springCloud-2021.0.9 之 GateWay 示例

文章目录 前言springCloud-2021.0.9 之 GateWay 示例1. GateWay 官网2. GateWay 三个关键名称3. GateWay 工作原理的高级概述4. 示例4.1. POM4.2. 启动类4.3. 过滤器4.4. 配置 5. 启动/测试 前言 如果您觉得有用的话&#xff0c;记得给博主点个赞&#xff0c;评论&#xff0c;收…

[FastAdmin] 上传图片并加水印,压缩图片

1.app\common\library\Upload.php 文件 upload方法 /*** 普通上传* return \app\common\model\attachment|\think\Model* throws UploadException*/public function upload($savekey null){if (empty($this->file)) {throw new UploadException(__(No file upload or serv…

windows系统远程桌面连接ubuntu18.04

记录一下自己在配置过程中遇到的问题&#xff0c;记录遇到的两大坑&#xff1a; windows系统通过xrdp远程桌面连接ubuntu18.04的蓝屏问题。参考以下第一章解决。 同一局域网内网段不同的连接问题。参考以下第三章解决&#xff0c;前提是SSH可连。 1. 在ubuntu上安装xrdp 参考&…

逻辑回归不能解决非线性问题,而svm可以解决

逻辑回归和支持向量机&#xff08;SVM&#xff09;是两种常用的分类算法&#xff0c;它们在处理数据时有一些不同的特点&#xff0c;特别是在面对非线性问题时。 1. 逻辑回归 逻辑回归本质上是一个线性分类模型。它的目的是寻找一个最适合数据的直线&#xff08;或超平面&…

23页PDF | 国标《GB/T 44109-2024 信息技术 大数据 数据治理实施指南 》发布

一、前言 《信息技术 大数据 数据治理实施指南》是中国国家标准化管理委员会发布的关于大数据环境下数据治理实施的指导性文件&#xff0c;旨在为组织开展数据治理工作提供系统性的方法和框架。报告详细阐述了数据治理的实施过程&#xff0c;包括规划、执行、评价和改进四个阶…

ESM3(1)-介绍:用语言模型模拟5亿年的进化历程

超过30亿年的进化在天然蛋白质空间中编码形成了一幅生物学图景。在此&#xff0c;作者证明在进化数据上进行大规模训练的语言模型&#xff0c;能够生成与已知蛋白质差异巨大的功能性蛋白质&#xff0c;并推出了ESM3&#xff0c;这是一款前沿的多模态生成式语言模型&#xff0c;…

在大型语言模型(LLM)框架内Transformer架构与混合专家(MoE)策略的概念整合

文章目录 传统的神经网络框架存在的问题一. Transformer架构综述1.1 transformer的输入1.1.1 词向量1.1.2 位置编码&#xff08;Positional Encoding&#xff09;1.1.3 编码器与解码器结构1.1.4 多头自注意力机制 二.Transformer分步详解2.1 传统词向量存在的问题2.2 详解编解码…