文档

快速使用

更新时间:
一键部署

Ziya-LLaMA

说明

支持的领域 / 任务:aigc

Ziya-LLaMA通用大模型是由IDEA研究院出品的大规模语言模型,它在大模型服务平台上的模型名称为"ziya-llama-13b-v1"。Ziya-LLaMA大模型V1是基于LLaMa的130亿参数的大规模预训练模型,具备翻译,编程,文本分类,信息抽取,摘要,文案生成,常识问答和数学计算等能力。目前Ziya-LLaMA通用大模型已完成大规模预训练、多任务有监督微调和人类反馈学习三阶段的训练过程。

当前在大模型服务平台部署服务时使用的ModelScope社区模型id:Fengshenbang/Ziya-LLaMA-13B-v1,模型版本:v1.0.3。

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

快速开始

前提条件

示例代码

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

说明

需要使用您的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 http import HTTPStatus

response = dashscope.Generation.call(
    model='ziya-llama-13b-v1',
    prompt='<human>:帮我写一份去西安的旅游计划\n<bot>:'
)
# 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("ziya-llama-13b-v1")
    .prompt("<human>:帮我写一份去西安的旅游计划\n<bot>:")
    .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": "<s><human> :帮我写一份去西安的旅游计划\n<bot> : 西安旅游计划:\nDay 1: \n- 上午:参观兵马俑\n- 下午:游览华清池和大雁塔\n- 晚上:品尝美食,如肉夹馍、凉皮等\nDay 2:\n- 上午:参观古城墙和钟楼鼓楼\n- 下午:参观明城墙、大明宫、回民街\n- 晚上:观赏陕北民间文化表演\nDay 3:\n- 上午:参观华清池公园、大唐芙蓉园\n- 下午:参观陕西历史博物馆\n- 晚上:游览夜景,如大唐芙蓉园夜景、钟楼鼓楼夜景等\nDay 4:\n- 上午:参观大雁塔\n- 下午:游览西安城墙遗址公园、莲湖公园\n- 晚上:品尝西安小吃,如羊肉泡馍、凉皮等\nDay 5:\n- 上午:参观华清池公园\n- 下午:游览大唐芙蓉园\n- 晚上:品尝当地美食,如饺子、羊肉火锅等\n这是一份基本的西安旅游计划,希望对您有所帮助!</s>"}
{"input_tokens": 0, "output_tokens": 0}

了解更多

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

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