通义千问-14B-Chat-Int4 · 模型库 (modelscope.cn)
**通义千问-14B(Qwen-14B)**是阿里云研发的通义千问大模型系列的140亿参数规模的模型。Qwen-14B是基于Transformer的大语言模型, 在超大规模的预训练数据上进行训练得到。预训练数据类型多样,覆盖广泛,包括大量网络文本、专业书籍、代码等。同时,在Qwen-14B的基础上,我们使用对齐机制打造了基于大语言模型的AI助手Qwen-14B-Chat。本仓库为Qwen-14B-Chat的Int4量化模型的仓库。
显存使用
参考:https://zhuanlan.zhihu.com/p/656551530?utm_id=0
如何快速开始通义千问_灵积模型服务-阿里云帮助中心 (aliyun.com)
前提条件
-
已开通服务并获得API-KEY:开通DashScope并创建API-KEY。
-
已安装最新版SDK:安装DashScope SDK。
开通DashScope灵积模型服务
如何开通DashScope并创建API-KEY_灵积模型服务-阿里云帮助中心 (aliyun.com)
安装 DashScope SDK
Maven Repository: com.alibaba » dashscope-sdk-java (mvnrepository.com)
最新版本2.8.3:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dashscope-sdk-java</artifactId>
<version>2.8.3</version>
</dependency>
Java 代码
public class TestQwen {public static void callWithMessage()throws NoApiKeyException, ApiException, InputRequiredException {Generation gen = new Generation();Constants.apiKey = "sk-XXXXXXXXX"; // 申请的apiMessageManager msgManager = new MessageManager(10);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();msgManager.add(systemMsg);msgManager.add(userMsg);QwenParam param =QwenParam.builder().model(Generation.Models.QWEN_TURBO).messages(msgManager.get()).resultFormat(QwenParam.ResultFormat.MESSAGE).topP(0.8).enableSearch(true).build();GenerationResult result = gen.call(param);System.out.println(result);}public static void main(String[] args){try {callWithMessage();} catch (ApiException | NoApiKeyException | InputRequiredException e) {System.out.println(e.getMessage());}System.exit(0);}
}
运行效果:
API详情
通义千问有哪些支持的API,如何使用_灵积模型服务-阿里云帮助中心 (aliyun.com)
对于图片的理解:
public static void simpleMultiModalConversationCall() throws ApiException, NoApiKeyException, UploadFileException {Constants.apiKey = "sk-XXXXXXXXXXXXXX"; //你申请的apikeyMultiModalConversation conv = new MultiModalConversation();MultiModalMessageItemImage userImage = new MultiModalMessageItemImage("https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg");MultiModalMessageItemText userText = new MultiModalMessageItemText("这是什么?");MultiModalConversationMessage userMessage =MultiModalConversationMessage.builder().role(Role.USER.getValue()).content(Arrays.asList(userImage, userText)).build();MultiModalConversationParam param = MultiModalConversationParam.builder().model(MultiModalConversation.Models.QWEN_VL_CHAT_V1).message(userMessage).build();MultiModalConversationResult result = conv.call(param);System.out.print(result);}public static void main(String[] args) {try {simpleMultiModalConversationCall();} catch (ApiException | NoApiKeyException | UploadFileException e) {System.out.println(e.getMessage());}System.exit(0);}