程序调用 AI 大模型 -- Java

程序调用 AI 大模型 – Java

1、SDK 接入

安装阿里云百炼SDK_大模型服务平台百炼(Model Studio)-阿里云帮助中心

<dependency><groupId>com.alibaba</groupId><artifactId>dashscope-sdk-java</artifactId><!-- 请将 'the-latest-version' 替换为最新版本号:https://mvnrepository.com/artifact/com.alibaba/dashscope-sdk-java --><version>the-latest-version</version>
</dependency>
// 建议dashscope SDK的版本 >= 2.12.0
import java.util.Arrays;
import java.lang.System;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;public class Main {public static GenerationResult callWithMessage() throws ApiException, NoApiKeyException, InputRequiredException {Generation gen = new Generation();Message systemMsg = Message.builder().role(Role.SYSTEM.getValue()).content("You are a helpful assistant.").build();Message userMsg = Message.builder().role(Role.USER.getValue()).content("你是谁?").build();GenerationParam param = GenerationParam.builder()// 若没有配置环境变量,请用百炼API Key将下行替换为:.apiKey("sk-xxx").apiKey(System.getenv("DASHSCOPE_API_KEY"))// 此处以qwen-plus为例,可按需更换模型名称。模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models.model("qwen-plus").messages(Arrays.asList(systemMsg, userMsg)).resultFormat(GenerationParam.ResultFormat.MESSAGE).build();return gen.call(param);}public static void main(String[] args) {try {GenerationResult result = callWithMessage();System.out.println(JsonUtils.toJson(result));} catch (ApiException | NoApiKeyException | InputRequiredException e) {// 使用日志框架记录异常信息System.err.println("An error occurred while calling the generation service: " + e.getMessage());}System.exit(0);}
}

2、HTTP 接入

对于 SDK 不支持的编程语言或需要更灵活控制的场景,可以直接使用 HTTP 请求调用 AI 大模型的 API。

使用建议:优先使用 SDK ,不支持 SDK ,再考虑 HTTP 调用

curl --location "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{"model": "qwen-plus","input":{"messages":[      {"role": "system","content": "You are a helpful assistant."},{"role": "user","content": "你是谁?"}]},"parameters": {"result_format": "message"}
}'

转换为使用Hutool工具类的Java代码

package com.ping.aiagent.demo.invoke;import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ping.aiagent.contant.TestAPI;/*** HTTP 方式调用 AI*/
public class DashscopeRequest {public static void main(String[] args) {// API密钥String apiKey = TestAPI.API_KEY;// 构建请求URLString url = "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation";// 构建请求JSON体JSONObject requestBody = new JSONObject();requestBody.set("model", "qwen-plus");JSONObject input = new JSONObject();// 创建消息数组JSONArray messages = new JSONArray();// 添加系统消息messages.add(new JSONObject().set("role", "system").set("content", "You are a helpful assistant."));// 添加用户消息messages.add(new JSONObject().set("role", "user").set("content", "你是谁?"));input.set("messages", messages);JSONObject parameters = new JSONObject();parameters.set("result_format", "message");requestBody.set("input", input);requestBody.set("parameters", parameters);// 发送POST请求String response = HttpRequest.post(url).header("Authorization", "Bearer " + apiKey).header("Content-Type", "application/json").body(requestBody.toString()).timeout(20000).execute().body();System.out.println(response);}
}

3、Spring AI

Spring AI 是 Spring 生态系统的新成员,旨在简化 AI 功能与 Spring 应用的集成。Spring AI 官方文档

Spring AI 默认没有支持所有的大模型(尤其是国产的)。

Spring AI AlibabaSpring AI Alibaba 官网_快速构建 JAVA AI 应用

阿里对 Spring AI 做了一个兼容和升级,可以更好的和阿里系的大模型兼容。

<dependency><groupId>com.alibaba.cloud.ai</groupId><artifactId>spring-ai-alibaba-starter</artifactId><version>1.0.0-M5.1</version>
</dependency><repositories><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url><snapshots><enabled>false</enabled></snapshots></repository>
</repositories>

更改配置文件

spring:application:name: ping-ai-agentai:dashscope:api-key: < API KEY >chat:options:model: qwq-plus
package com.ping.aiagent.demo.invoke;import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;/*** Spring AI 模型框架调用 AI 大模型*/
@Component
public class SpringAiAiInvoke implements CommandLineRunner {@Resourceprivate ChatModel dashscopeChatModel; // 先通过名称 找不到再通过类型 一定要是这个名称// 还可以通过 ChatClient 对话客户端的方式去调用 能够提供更多的高级 AI 交互功能@Overridepublic void run(String... args) throws Exception {AssistantMessage assistantMessage = dashscopeChatModel.call(new Prompt("你好呀")).getResult().getOutput(); // 取出 getResult 对象的内容System.out.println(assistantMessage.getText()); // 拿到文本响应}
}

4、LangChain4j

知名 AI 框架 LangChain 的 Java 版本。

LangChain 官方是没有支持阿里系大模型的,只能用社区版本整合的大模型包。LangChain4j模型集成。

接入阿里云灵积模型,参考官方文档:DashScope 模型集成。

<dependency><groupId>dev.langchain4j</groupId><artifactId>langchain4j-community-dashscope</artifactId><version>1.0.0-beta2</version>
</dependency>

本地部署和接入 AI 大模型

1、本地安装大模型。

官网安装

无需自己执行脚本安装,也省去了复杂的环境配置。

Ollama 不仅提供了友好的命令行界面,还支持 API 调用,方便与各种应用程序集成。参考:官方 API 文档。

检测模型是否运行:localhost:11434。

2、Spring AI 调用 Ollama 大模型

Spring AI 原生支持调用 Ollama 大模型,直接参考 [官方文档](Ollama-阿里云Spring AI Alibaba官网官网) 编写配置和代码即可。

配置依赖。

<!--  https://java2ai.com/docs/1.0.0-M6.1/models/ollama/  -->
<dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-ollama-spring-boot-starter</artifactId><version>1.0.0-M6</version>
</dependency><!--  需要引入仓库配置,才能下载到最新的 Spring AI 的相关依赖  -->
<repositories><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url><snapshots><enabled>false</enabled></snapshots></repository>
</repositories>

调用配置

spring:ai:ollama:base-url: http://localhost:11434chat:model: llama3

扩展:火山引擎

火山方舟管理控制台

1、HTTP 接入

curl https://ark.cn-beijing.volces.com/api/v3/chat/completions \-H "Content-Type: application/json" \-H "Authorization: Bearer <Your Api Key>" \-d $'{"model": "doubao-seed-1-6-250615","messages": [{"content": [{"image_url": {"url": "https://ark-project.tos-cn-beijing.ivolces.com/images/view.jpeg"},"type": "image_url"},{"text": "图片主要讲了什么?","type": "text"}],"role": "user"}]
}'

转换为使用Hutool工具类的Java代码

package com.ping.aiagent.demo.invoke;import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ping.aiagent.contant.TestAPI;public class VolcengineImageChat {public static void main(String[] args) {String url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions";String token = TestAPI.VolcengineImageChat_Api_KET;if (token == null || token.trim().isEmpty()) {throw new IllegalArgumentException("API密钥不能为空");}String imageUrl = "https://cdn.jsdmirror.com/gh/qiuping01/my-images/202508191817326.jpg";try {int statusCode = HttpRequest.get(imageUrl).timeout(10000).execute().getStatus();if (statusCode != 200) {System.err.println("警告: 图片URL可能无法访问,状态码: " + statusCode);}} catch (Exception e) {System.err.println("警告: 无法验证图片URL: " + e.getMessage());}JSONObject requestBody = new JSONObject();requestBody.set("model", "doubao-seed-1-6-250615");JSONArray messages = new JSONArray();JSONArray contentArray = new JSONArray();JSONObject imageObject = new JSONObject();imageObject.set("type", "image_url");JSONObject imageUrlObject = new JSONObject();imageUrlObject.set("url", imageUrl);imageObject.set("image_url", imageUrlObject);contentArray.add(imageObject);JSONObject textObject = new JSONObject();textObject.set("type", "text");textObject.set("text", "图片主要讲了什么?");contentArray.add(textObject);JSONObject userMessage = new JSONObject();userMessage.set("role", "user");userMessage.set("content", contentArray);messages.add(userMessage);requestBody.set("messages", messages);int maxRetries = 3;int retryCount = 0;String response = null;while (retryCount < maxRetries) {try {System.out.println("发送请求到: " + url);long startMs = System.currentTimeMillis();response = HttpRequest.post(url).header("Content-Type", "application/json").header("Authorization", "Bearer " + token).body(requestBody.toString()).timeout(120000).execute().body();long costMs = System.currentTimeMillis() - startMs;// 直观输出printPrettyResponse(response, imageUrl, "图片主要讲了什么?", costMs);break;} catch (Exception e) {retryCount++;System.err.println("请求失败,第 " + retryCount + " 次重试...");System.err.println("错误信息: " + e.getMessage());if (retryCount >= maxRetries) {System.err.println("已达到最大重试次数,放弃请求");throw new RuntimeException("请求失败,已达到最大重试次数", e);}try {Thread.sleep(2000L * retryCount);} catch (InterruptedException ie) {Thread.currentThread().interrupt();throw new RuntimeException("重试等待被中断", ie);}}}}private static void printPrettyResponse(String response, String imageUrl, String userQuestion, long costMs) {if (response == null || response.isEmpty()) {System.out.println("未收到响应");return;}JSONObject resp;try {resp = JSONUtil.parseObj(response);} catch (Exception e) {System.out.println("收到非JSON响应,原始内容:\n" + response);return;}// 错误处理if (resp.containsKey("error")) {JSONObject error = resp.getJSONObject("error");System.out.println("\n================== 豆包 AI 响应(错误) ==================");System.out.println("错误代码: " + error.getStr("code", "-"));System.out.println("错误信息: " + error.getStr("message", "-"));System.out.println("原始响应(JSON):\n" + JSONUtil.toJsonPrettyStr(resp));System.out.println("========================================================");return;}String id = resp.getStr("id", "-");String model = resp.getStr("model", "-");JSONObject usage = resp.getJSONObject("usage");Integer promptTokens = usage.getInt("prompt_tokens", null);Integer completionTokens = usage.getInt("completion_tokens", null);Integer totalTokens = usage.getInt("total_tokens", null);// 提取助手回答(兼容字符串或分段数组)String assistantAnswer = extractAssistantAnswer(resp);System.out.println("\n================== 豆包 AI 响应(已格式化) ===============");System.out.println("请求信息");System.out.println("- 图片URL    : " + imageUrl);System.out.println("- 用户问题    : " + userQuestion);System.out.println("- 耗时        : " + costMs + " ms");System.out.println("\n元信息");System.out.println("- 请求ID      : " + id);System.out.println("- 模型        : " + model);if (promptTokens != null || completionTokens != null || totalTokens != null) {System.out.println("- Token用量   : prompt=" + safeInt(promptTokens)+ ", completion=" + safeInt(completionTokens)+ ", total=" + safeInt(totalTokens));}System.out.println("\n助手回答");System.out.println(assistantAnswer == null || assistantAnswer.isEmpty() ? "(空)" : assistantAnswer);System.out.println("\n原始响应(JSON)"); // 便于排查System.out.println(JSONUtil.toJsonPrettyStr(resp));System.out.println("========================================================\n");}private static String extractAssistantAnswer(JSONObject resp) {try {JSONArray choices = resp.getJSONArray("choices");if (choices == null || choices.isEmpty()) {return "";}JSONObject first = choices.getJSONObject(0);if (first == null) return "";JSONObject message = first.getJSONObject("message");if (message == null) return "";Object content = message.get("content");if (content == null) return "";// 可能是字符串if (content instanceof CharSequence) {return String.valueOf(content).trim();}// 也可能是数组(多模态分段)if (content instanceof JSONArray) {JSONArray parts = (JSONArray) content;StringBuilder builder = new StringBuilder();for (int i = 0; i < parts.size(); i++) {JSONObject part = parts.getJSONObject(i);String type = part.getStr("type", "");if ("text".equalsIgnoreCase(type)) {builder.append(part.getStr("text", ""));} else if ("image_url".equalsIgnoreCase(type)) {JSONObject img = part.getJSONObject("image_url");String url = img == null ? "" : img.getStr("url", "");builder.append("\n[图片] ").append(url);}}return builder.toString().trim();}return String.valueOf(content).trim();} catch (Exception e) {return "";}}private static String safeInt(Integer v) {return v == null ? "-" : String.valueOf(v);}
}

2、SDK 调用

<dependency><groupId>com.volcengine</groupId><artifactId>volcengine-java-sdk-ark-runtime</artifactId><version>LATEST</version>
</dependency>
package com.volcengine.ark.runtime;import com.volcengine.ark.runtime.model.completion.chat.ChatCompletionContentPart;
import com.volcengine.ark.runtime.model.completion.chat.ChatCompletionRequest;
import com.volcengine.ark.runtime.model.completion.chat.ChatMessage;
import com.volcengine.ark.runtime.model.completion.chat.ChatMessageRole;
import com.volcengine.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;// 请确保您已将 API Key 存储在环境变量 ARK_API_KEY 中
// 初始化Ark客户端,从环境变量中读取您的API Key
public class ChatCompletionsVisionExample {// 从环境变量中获取您的 API Key。此为默认方式,您可根据需要进行修改static String apiKey = System.getenv("ARK_API_KEY");// 此为默认路径,您可根据业务所在地域进行配置static String baseUrl = "https://ark.cn-beijing.volces.com/api/v3";static ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);static Dispatcher dispatcher = new Dispatcher();static ArkService service = ArkService.builder().dispatcher(dispatcher).connectionPool(connectionPool).baseUrl(baseUrl).apiKey(apiKey).build();public static void main(String[] args) {System.out.println("----- image input -----");final List<ChatMessage> messages = new ArrayList<>();final List<ChatCompletionContentPart> multiParts = new ArrayList<>();multiParts.add(ChatCompletionContentPart.builder().type("image_url").imageUrl(new ChatCompletionContentPart.ChatCompletionContentPartImageURL("https://ark-project.tos-cn-beijing.ivolces.com/images/view.jpeg")).build());multiParts.add(ChatCompletionContentPart.builder().type("text").text("这是哪里?").build());final ChatMessage userMessage = ChatMessage.builder().role(ChatMessageRole.USER).multiContent(multiParts).build();messages.add(userMessage);ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder()// 指定您创建的方舟推理接入点 ID,此处已帮您修改为您的推理接入点 ID.model("doubao-seed-1-6-250615").messages(messages).build();service.createChatCompletion(chatCompletionRequest).getChoices().forEach(choice -> System.out.println(choice.getMessage().getContent()));service.shutdownExecutor();}
}

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

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

相关文章

VMware 虚拟机完全使用教程:从基础到高级应用

VMware 虚拟机完全使用教程&#xff1a;从基础到高级应用 一、引言 在当今数字化时代&#xff0c;计算机技术的飞速发展使得硬件性能不断提升&#xff0c;但同时也带来了资源浪费和管理复杂等问题。虚拟机技术应运而生&#xff0c;它能够在一台物理计算机上模拟出多台独立的计…

函数对象 vs 函数指针 vs lambda:该用哪个才高效?

博主介绍&#xff1a;程序喵大人 35 - 资深C/C/Rust/Android/iOS客户端开发10年大厂工作经验嵌入式/人工智能/自动驾驶/音视频/游戏开发入门级选手《C20高级编程》《C23高级编程》等多本书籍著译者更多原创精品文章&#xff0c;首发gzh&#xff0c;见文末&#x1f447;&#x…

Java团队项目开发规范——对象分层规范

分层与对象命名规范如上图所示&#xff0c;系统划分成3个层&#xff1a;Controller层&#xff0c;Service层&#xff0c;Domain层 Controller层&#xff1a; Controller层是接入层&#xff0c;提供对外或者前端的接口&#xff0c;该层主要作用是提供对外接口的封装。基于CQRS分…

低功耗模式

1. 什么是低功耗&#xff1f;低功耗模式&#xff1a;MCU 暂停部分时钟/外设&#xff0c;降低电流消耗&#xff0c;等待外部事件&#xff08;中断/复位/唤醒&#xff09;再恢复运行。应用场景&#xff1a;电池供电设备&#xff08;传感器、手持设备、IoT 节点&#xff09;——延…

GPT-5 官方前瞻:它将如何重塑你的数字生活?

你是否曾想过&#xff0c;有一天你的浏览器不再是一个被动等待指令的工具&#xff0c;而是一个能主动为你分忧解难的智能伙伴&#xff1f;OpenAI 的 CEO Sam Altman 最近的发言&#xff0c;以及关于 GPT-5 的种种迹象&#xff0c;都预示着这个未来比我们想象的更近。这不仅是一…

驱动开发系列65 - NVIDIA 开源GPU驱动open-gpu-kernel-modules 目录结构

一:OS相关部分 kernel-open/ 内核接口层 kernel-open/nvidia/ nvidia.ko 的接口层,负责GPU初始化,显存管理,PCIe通信,中断处理,电源管理等底层功能。 kernel-open/nvidia-drm/ nvidia-drm.ko 的接口层,提供标准图形接口,让Xorg、Wayland、Kwin、GNOME等桌面环境能够通…

GPT-4.1旗舰模型:复杂任务的最佳选择及API集成实践

GPT-4.1旗舰模型&#xff1a;复杂任务的最佳选择及API集成实践 概述 GPT-4.1作为新一代旗舰大模型&#xff0c;凭借其卓越的智能表现、强大的跨领域问题解决能力&#xff0c;成为复杂任务处理的首选。本文将详细解析GPT-4.1的核心能力、接口用法、计费方式、功能对比及API集成…

paimon保姆级教程简介

还在纠结 Flink 配 Hudi 还是 Iceberg&#xff1f;别选了&#xff0c;快来试试 Flink 的“天选之子”—— Apache Paimon&#xff01; 忘掉复杂的 Lambda 架构&#xff0c;拥抱真正的流批一体。我们的 Paimon 视频教程&#xff0c;带你用 Flink 原生湖仓格式&#xff0c;轻松构…

Transformer中的编码器和解码器是什么?

今天&#xff0c;我们来具体介绍Transformer的架构设计。 一个完整的Transformer模型就像一个高效的语言处理工厂&#xff0c;主要由两大车间组成&#xff1a;编码车间和解码车间。 首先来看这幅“世界名画”&#xff0c;你可以在介绍Transformer的场景中常常看到这幅图&#x…

uniapp 应用未安装:软件包与现有软件包存在冲突

应用未安装&#xff1a;软件包与现有软件包存在冲突常见原因包名&#xff08;AppID&#xff09;没变&#xff0c;但签名证书不同安卓会把同一包名的 App 当成同一个应用。如果你之前安装的版本用了 A 签名&#xff0c;现在你打包用了 B 签名&#xff0c;就会冲突&#xff0c;导…

MyCAT2的主从配置

1.创建数据源重置配置&#xff1a;/* mycat:resetConfig{} */添加读写的数据源/* mycat:createDataSource {"dbType": "mysql","idleTimeout": 60000,"initSqls": [],"initSqlsGetConnection": true,"instanceType&quo…

个人介绍CSDNmjhcsp

年龄&#xff1a;12岁 住址&#xff1a;山东潍坊 看的这&#xff0c;有人懵了&#xff0c;访问量4.8万的mjhcsp竟然是一个小孩&#xff01; 好吧&#xff0c;我的强项其实是C&#xff0c;但是C发表文章很少&#xff0c;我平常写一写java&#xff0c;云原生&#xff0c;Deeps…

01-Docker-简介、安装与使用

1. docker简介 Docker 是一个应用打包、分发、部署的工具你也可以把它理解为一个轻量的虚拟机&#xff0c;它只虚拟你软件需要的运行环境&#xff0c;多余的一点都不要&#xff0c;而普通虚拟机则是一个完整而庞大的系统&#xff0c;包含各种不管你要不要的软件。 2. 相关概念 …

阿里云参数配置化

阿里云参数配置化 一、问题描述 当我们直接在AliOSSUtils.java中对所需的阿里云OSS相关参数进行赋值时&#xff0c;当相关参数发生改变&#xff0c;但是又在多次进行了赋值这些参数&#xff0c;那么就需要逐一进行修改&#xff0c;所以我们直接在SpringBoot项目的配置文件appli…

Diamond开发经验(1)

前言: 学习Lattice的芯片开发的过程中&#xff0c;很多实际开发过程中遇到的问题是没办法绕过的&#xff0c;虽然我今天被绕了一天&#xff08;此句多余&#xff0c;单纯记录美好心情哈哈哈哈&#xff09;将这些解决方法梳理成文章供大家参考&#xff0c;十个问题组成一篇文章。…

神经网络训练过程详解

神经网络训练过程详解 神经网络训练过程是一个动态的、迭代的学习过程&#xff0c;接下来基于一段代码展示模型是如何逐步学习数据规律的。 神经网络拟合二次函数&#xff1a;代码详解 下面将详细解释这段代码&#xff0c;它使用神经网络拟合一个带有噪声的二次函数 y x 2x …

LeetCode100-560和为K的子数组

本文基于各个大佬的文章上点关注下点赞&#xff0c;明天一定更灿烂&#xff01;前言Python基础好像会了又好像没会&#xff0c;所有我直接开始刷leetcode一边抄样例代码一边学习吧。本系列文章用来记录学习中的思考&#xff0c;写给自己看的&#xff0c;也欢迎大家在评论区指导…

【PZ-ZU47DR-KFB】璞致FPGA ZYNQ UltraScalePlus RFSOC QSPI Flash 固化常见问题说明

1 Flash 固化Flash 固化需要先生成 BOOT.bin 文件&#xff0c;这边以裸机的串口工程进行讲解如何生成 BOOT.bin 文件及 Flash 固化操作。有读者会遇到&#xff0c;只使用 PL 端的情况&#xff0c;也需要进行 Flash 固化。我们需要添加 PS 端最小配置&#xff08;包含 Flash 配置…

数据结构:查找表

一、数据结构的概念数据结构是指相互之间存在一种或多种特定关系的数据元素的集合。它不仅仅是存储数据的方式&#xff0c;更强调数据之间的逻辑关系和操作方法。数据结构主要从以下几个角度来理解&#xff1a;1. 数据之间的关系逻辑结构&#xff1a;集合结构&#xff1a;元素之…

自建知识库,向量数据库 (十)之 文本向量化——仙盟创梦IDE

自建文章向量化技术&#xff1a;AI 浪潮下初学者的进阶指南 在人工智能&#xff08;AI&#xff09;蓬勃发展的浪潮中&#xff0c;向量化作为将文本数据转化为数值向量表示的关键技术&#xff0c;成为理解和处理文本的基石。本文将结合给定的代码示例&#xff0c;深入探讨自建文…