自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

國內(nèi)首個「混合推理模型」Qwen3開源,盤點它的N種對接方式!

人工智能
最新的 Qwen3 系列模型具備雙模推理能力(深入思考/快速響應(yīng))、支持 119 種語言及方言,并強化了 Agent 功能與代碼執(zhí)行能力,全面滿足復(fù)雜問題處理與全球化應(yīng)用需求。

今日凌晨,通義千問團隊正式開源了 Qwen3 大模型,并且一口氣發(fā)布了 8 個型號,其中包括 0.6B、1.7B、4B、8B、14B、32B 以及 30B-A3B 和 235B-A22B,使用者可以根據(jù)自己的業(yè)務(wù)情況,選擇合適的版本進行使用。

更讓人驚喜的是,最新的 Qwen3 系列模型具備雙模推理能力(深入思考/快速響應(yīng))、支持 119 種語言及方言,并強化了 Agent 功能與代碼執(zhí)行能力,全面滿足復(fù)雜問題處理與全球化應(yīng)用需求。

PS:Qwen3 也是國內(nèi)首個「混合推理模型」,「快思考」與「慢思考」集成進同一個模型,對簡單需求可低算力「秒回」答案,對復(fù)雜問題可多步驟「深度思考」,大大節(jié)省算力消耗。

Qwen3 旗艦?zāi)P?Qwen3-235B-A22B 在代碼、數(shù)學(xué)、通用能力等基準測試中,與 DeepSeek-R1、o1、o3-mini、Grok-3 和 Gemini-2.5-Pro 等頂級模型相比,表現(xiàn)出極具競爭力的結(jié)果。此外,小型 MoE 模型 Qwen3-30B-A3B 的激活參數(shù)數(shù)量是 QwQ-32B 的 10%,表現(xiàn)更勝一籌,甚至像 Qwen3-4B 這樣的小模型也能匹敵 Qwen2.5-72B-Instruct 的性能,以下是測試報告:

圖片

對接 Qwen3

常見對接大模型的方案有以下幾種:

  1. 官方對接方式:例如,調(diào)用阿里百煉平臺對接 Qwen3。
  2. 本地模型對接方式:安裝 Ollama 部署 Qwen3,對接 Ollama 實現(xiàn)調(diào)用。
  3. 三方平臺對接方式:使用千帆或火山引擎等三方平臺,對接調(diào)用 Qwen3。

但目前因為 Qwen3 剛剛發(fā)布,所以只能使用前兩種對接方式,截止發(fā)稿時,三方平臺還未上線 Qwen3,但也夠用了。

具體實現(xiàn)

接下來我們就以官方的調(diào)用方式,來實現(xiàn)一下 Qwen3 的具體代碼對接吧,這里提供 Spring AI 和 LangChain4j 兩種對接實現(xiàn)。

Spring AI 對接 Qwen3

1.添加依賴

Spring AI 并沒有內(nèi)置阿里云百煉平臺,但百煉平臺支持 OpenAI 協(xié)議,因此我們可以使用 OpenAI 對接百煉平臺,因此我們只需要添加 OpenAI 依賴即可。

<dependency>
  <groupId>org.springframework.ai</groupId>
  <artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>

2.設(shè)置配置信息

spring:
  ai:
    openai:
      base-url: https://dashscope.aliyuncs.com/compatible-mode/
      api-key: ${ALIYUN-AK}
      chat:
        options:
          model: qwen3-235b-a22b

其中:

  • base-url 填寫百煉平臺地址。
  • api-key 為準備階段在百煉平臺申請的 AK 憑證。
  • model 設(shè)置為 qwen3-235b-a22b 模型。

支持的模型列表參考官方文檔:https://help.aliyun.com/zh/model-studio/models?spm=a2c4g.11186623.0.0.78d848237YTeH1#cefdf0875dorc

3.編寫調(diào)用代碼

import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ds")
publicclass TestController {

    privatefinal OpenAiChatModel chatModel;

    @Autowired
    public TestController(OpenAiChatModel chatModel) {
        this.chatModel = chatModel;
    }

    @RequestMapping("/chat")
    public String chat(@RequestParam("msg") String msg) {
        String result = chatModel.call(msg);
        System.out.println("返回結(jié)果:" + result);
        return result;
    }
}

LangChain4j 對接 Qwen3

LangChain4j 內(nèi)置集成了阿里云百煉平臺,所以可以直接對接。

1.添加依賴

<dependency>
  <groupId>dev.langchain4j</groupId>
  <artifactId>langchain4j-community-dashscope-spring-boot-starter</artifactId>
</dependency>

可以為“l(fā)angchain4j-community-xxx”其添加統(tǒng)一版本管理:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>dev.langchain4j</groupId>
      <artifactId>langchain4j-community-bom</artifactId>
      <version>1.0.0-beta3</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

2.設(shè)置配置信息

注意這里需要配置“chat-model”節(jié)點,官方文檔有問題,如果不配置 chat-model 則不能自動注入百煉模型:

langchain4j:
  community:
    dashscope:
      base-url: https://dashscope.aliyuncs.com/compatible-mode/
      chat-model:
        api-key: ${ALIYUN-AK}
        model-name: qwen-plus

支持的模型列表:https://help.aliyun.com/zh/model-studio/models

3.編寫調(diào)用代碼

import dev.langchain4j.model.chat.ChatLanguageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/qw")
publicclass QwenController {

    @Autowired
    private ChatLanguageModel qwenChatModel;

    @RequestMapping("/chat")
    public String chat(String question) {
        return qwenChatModel.chat(question);
    }
}

小結(jié)

當然,以上對接方式是全量輸出(得到結(jié)果之后一次性返回),生產(chǎn)級別我們通常要使用流式輸出,并且需要實現(xiàn)連續(xù)(上下文)對話,以及歷史對話信息持久化等功能,文章篇幅有限,這里就不一一實現(xiàn)了,大家可以下來自己試試。

責任編輯:武曉燕 來源: 磊哥和Java
相關(guān)推薦

2025-04-29 08:05:44

2025-04-29 08:14:14

2025-04-29 07:39:45

2023-03-06 09:20:33

CSS顏色混合

2025-02-25 09:02:26

2024-12-26 07:10:00

2025-02-25 10:08:38

2025-02-25 09:13:16

2024-12-25 09:30:00

2025-02-25 08:15:09

2025-03-05 00:22:00

2025-02-25 14:46:59

2024-12-25 20:13:35

2025-04-01 09:46:08

2024-09-10 21:11:55

2025-04-29 09:06:00

2025-04-27 09:19:00

強化學(xué)習(xí)模型AI

2025-04-23 08:30:05

2025-02-14 11:18:57

2024-09-24 11:01:03

點贊
收藏

51CTO技術(shù)棧公眾號