文档

API详情

更新时间:

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-7b-sft-v1

开源的推理能力增强的中英双语 LLaMA 模型

SDK使用

前提条件

单轮问答

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

说明

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

设置API-KEY

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

import dashscope
from dashscope import Generation
from http import HTTPStatus

response = 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);
  }
}

参数配置

参数

类型

默认值

说明

model

string

-

指定用于对话的BiLLa模型名,目前仅支持 billa-7b-sft-v1

prompt

string

-

用户当前输入的期望模型执行指令。

返回结果

  • 返回结果示例

{
    "status_code": 200,
    "request_id": "39a41abe-1bed-430a-b9b5-277130c7eb82",
    "code": "",
    "message": "",
    "output": {
        "text": "好的,以下是一份限塑的倡议书提纲:\n\nI. 引言\n\n- 阐明海洋污染的严重性,并介绍倡议书的目的和主要内容\n\nII. 海洋塑料污染的严重性\n\n- 详细描述海洋中塑料垃圾对海洋生态环境的危害,如何对海洋生态环境造成不可逆转的损害\n\n- 引用相关的研究和数据,让读者更加深入地了解海洋塑料污染的严重性\n\nIII. 推广限塑行动\n\n- 介绍限塑行动的必 要性和重要性,以及塑料制品的优点和缺点\n\n- 分析目前市场上可以使用的替代品,并向读者推荐可以减少使用塑料制品的替代品\n\n- 鼓励读者参与限塑行动,从小做起,做到减少塑料垃圾的贡献\n\nIV. 号召更多人加入限塑行动\n\n- 鼓励读者与身边的朋友和家人分享限塑行动的相关知识,让更多的人了解限塑行动的必要性\n\n- 号召更多企业加入限塑行动,为海洋环保做出贡献\n\n- 提供更多资源和渠道,让读者更加深入地了解限塑行动,并积极参与到这个行动中\n\nV. 结语\n\n- 总结限塑行动的必要性和重要性,并向读者表示感谢和祝福\n\n- 呼吁更多的人加入限塑 行动,为保护海洋环境做出自己的贡献\n\n希望这份限塑的倡议书提纲能够帮助您号召更多的人关注海洋环境保护,为建设美丽的海洋家园做出自己的贡献。"    }
}
  • 返回参数说明

返回参数

类型

说明

status_code

int

200(HTTPStatus.OK)表示请求成功,否则表示请求失败,可以通过code获取错误码,通过message字段获取错误详细信息。

request_Id

string

系统生成的标志本次调用的id。

code

string

表示请求失败,表示错误码,成功忽略。

message

string

失败,表示失败详细信息,成功忽略。

output

dict

调用结果信息,对于BiLLa模型,包含输出text。

text

string

模型生成回复。

usage

dict

计量信息,表示本次请求计量数据。当前模型无计量信息,此处为默认值。

input_tokens

int

用户输入文本转换成Token后的长度。

output_tokens

int

模型生成回复转换为Token后的长度。

HTTP调用接口

功能描述

billa-7b-sft-v1 模型同时支持 HTTP 调用来完成客户的响应。

前提条件

提交接口调用

POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation

入参描述

传参方式

字段

类型

必选

描述

示例值

Header

Content-Type

String

请求类型:application/json

application/json

Authorization

String

API-Key,例如:Bearer d1**2a

Bearer d1**2a

Body

model

String

指明需要调用的模型,固定值billa-7b-sft-v1

billa-7b-sft-v1

input.prompt

String

文本内容,支持中英文。

哪个公园距离我更近

出参描述

字段

类型

描述

示例值

output.text

String

本次请求的算法输出内容。

我建议你去颐和园

request_id

String

本次请求的系统唯一码

7574ee8f-38a3-4b1e-9280-11c33ab46e51

请求示例

以下示例展示通过CURL命令来调用billa-7b-sft-v1模型的脚本。

说明

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

curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation' \
--header 'Authorization: Bearer <your-dashscope-api-key>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "billa-7b-sft-v1",
    "input": {
        "prompt": "Human: Write a Python function that checks if a given number is even or odd.\nAssistant: "
    },
    "parameters":{
    }
}'

响应示例

{
    "output":{
        "text":"```python\ndef is_even(num):\n    return num % 2 == 0\n```\n\nThis function takes an integer `num` as an input and returns `True` if the number is even or `False` if the number is odd. It calculates the remainder of the number when divided by 2 using the modulus operator (`%`). If the remainder is 0, then the number is even."
    },
    "request_id":"d89c06fb-46a1-47b6-acb9-bfb17f814969"
}

异常响应示例

在访问请求出错的情况下,输出的结果中会通过 code 和 message 指明出错原因。

{
    "code":"InvalidApiKey",
    "message":"Invalid API-key provided.",
    "request_id":"d89c06fb-46a1-47b6-acb9-bfb17f814969"
}

状态码说明

DashScope灵积模型服务通用状态码请查阅:返回状态码说明

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