文档

快速使用

更新时间:

BELLE-LLaMA

说明

支持的领域 / 任务:aigc

BELLE-LLaMA模型是由BELLE出品的大规模语言模型,它在灵积平台上的模型名称为"belle-llama-13b-2m-v1"。BELLE(BE Large Language Model Engine),一款基于BLOOM和LLAMA针对中文优化、模型调优切仅使用由ChatGPT生成的数据,为中文指令提供更好的支持。促进中文对话大模型开源社区的发展,愿景是成为能够帮到每一个人的LLM Engine。相比如何做好大语言模型的预训练,BELLE更关注如何在开源预训练大语言模型的基础上,帮助每一个人都能够得到一个属于自己的、效果尽可能好的具有指令表现能力的语言模型,降低大语言模型、特别是中文大语言模型的研究和应用门槛。为此,BELLE项目会持续开放指令训练数据、相关模型、训练代码、应用场景等,也会持续评估不同训练数据、训练算法等对模型表现的影响。BELLE针对中文做了优化,模型调优仅使用由ChatGPT生产的数据(不包含任何其他数据)。

当前在灵积平台部署服务时使用的ModelScope社区模型id:AI-ModelScope/BELLE-LLaMA-13B-2M,模型版本:v1.0.1。

更多信息可以参考ModelScope上BELLE-LLaMA的开源repo

快速开始

前提条件

示例代码

以下示例展示了调用BELLE-LLaMA API对一个用户指令进行响应的代码。

说明

需要使用您的API-KEY替换示例中的 your-dashscope-api-key ,代码才能正常运行。

设置API KEY

export DASHSCOPE_API_KEY=YOUR_DASHSCOPE_API_KEY
重要

BELLE-LLaMA模型API调用需"申请体验"并通过后才可使用,否则API调用将返回错误状态码。

# For prerequisites running the following sample, visit https://help.aliyun.com/document_detail/611472.html

import dashscope
from http import HTTPStatus

response = dashscope.Generation.call(
    model='belle-llama-13b-2m-v1',
    prompt='Human:你好\n\nAssistant:'
)
# The response status_code is HTTPStatus.OK indicate success,
# otherwise indicate request is failed, you can get error code
# and message from code and message.
if response.status_code == HTTPStatus.OK:
    print(response.output)  # The output text
    print(response.usage)  # The usage information
else:
    print(response.code)  # The error code.
    print(response.message)  # The error message.
// Copyright (c) Alibaba, Inc. and its affiliates.

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.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 void usage()
      throws NoApiKeyException, ApiException, InputRequiredException {
    Generation gen = new Generation();
    GenerationParam param = GenerationParam
    .builder()
    .model("belle-llama-13b-2m-v1")
    .prompt("Human:你好\n\nAssistant:")
    .build();
    GenerationResult result = gen.call(param);
    System.out.println(JsonUtils.toJson(result));
  }
  public static void main(String[] args){
        try {
          usage();
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
          System.out.println(e.getMessage());        
        }
        System.exit(0);
  }
}

调用成功后,将会返回如下示例结果。

{"text": "你好!有什么我可以帮助你的吗?"}
{"input_tokens": 0, "output_tokens": 0}

了解更多

有关BELLE-LLaMA模型API的详细调用文档可前往API详情页面进行了解。

  • 本页导读 (0)
文档反馈