文档

快速使用

更新时间:

BiLLa

说明

支持的领域 / 任务:aigc

BiLLa模型在灵积平台上的模型名称为"billa-7b-sft-v1"。BiLLa 是开源的推理能力增强的中英双语 LLaMA 模型. 模型的主要特点:

  • 较大提升 LLaMA 的中文理解能力, 并尽可能减少对原始 LLaMA 英文能力的损伤;

  • 训练过程增加较多的任务型数据, 利用 ChatGPT 生成解析, 强化模型理解任务求解逻辑;

  • 全量参数更新, 追求更好的生成效果。

当前在灵积平台部署服务时使用的ModelScope社区模型id:AI-ModelScope/BiLLa-7B-SFT,模型版本:v1.0.5。

更多信息可以参考ModelScope上BiLLa的开源repo

快速开始

前提条件

示例代码

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

说明

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

设置API-KEY

export DASHSCOPE_API_KEY=YOUR_DASHSCOPE_API_KEY
重要

BiLLa模型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='billa-7b-sft-v1',
    prompt='翻译成英文:春天来了,花朵都开了。'
)
# 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
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();
    String prompt = "翻译成英文:春天来了,花朵都开了。";
    GenerationParam param = GenerationParam
        .builder()
        .model("billa-7b-sft-v1")
        .prompt(prompt)
        .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": "Translation into English: Spring has come, and the flowers have all bloomed."}

了解更多

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

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