from textgen import GptModel
defgenerate_prompt(instruction):
returnf"""A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.USER: {instruction} ASSISTANT: """
model = GptModel("baichuan", "shibing624/vicuna-baichuan-13b-chat")
predict_sentence = generate_prompt("一岁宝宝发烧能吃啥药?")
r = model.predict([predict_sentence])
print(r) # ["1、首先大多数小儿退热药中含有解热镇痛成分阿司匹林或布洛芬等,这类药品虽然副作用较少..."]
Usage (HuggingFace Transformers)
Without
textgen
, you can use the model like this:
First, you pass your input through the transformer model, then you get the generated sentence.
Install package:
pip install transformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
model = AutoModelForCausalLM.from_pretrained("shibing624/vicuna-baichuan-13b-chat", device_map='auto', torch_dtype=torch.float16, trust_remote_code=True)
model.generation_config = GenerationConfig.from_pretrained("shibing624/vicuna-baichuan-13b-chat", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("shibing624/vicuna-baichuan-13b-chat", trust_remote_code=True)
device = torch.device(0) if torch.cuda.is_available() else torch.device("cpu")
defgenerate_prompt(instruction):
returnf"""A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.USER: {instruction} ASSISTANT: """
sents = ['一岁宝宝发烧能吃啥药', "who are you?"]
for s in sents:
q = generate_prompt(s)
inputs = tokenizer(q, return_tensors="pt")
inputs = inputs.to(device)
generate_ids = model.generate(
**inputs,
max_new_tokens=512,
)
output = tokenizer.batch_decode(generate_ids, skip_special_tokens=True)[0]
print(output)
print()
@software{textgen,
author = {Ming Xu},
title = {textgen: Implementation of language model finetune},
year = {2023},
url = {https://github.com/shibing624/textgen},
}
Runs of shibing624 vicuna-baichuan-13b-chat on huggingface.co
154
Total runs
5
24-hour runs
18
3-day runs
27
7-day runs
9
30-day runs
More Information About vicuna-baichuan-13b-chat huggingface.co Model
vicuna-baichuan-13b-chat huggingface.co is an AI model on huggingface.co that provides vicuna-baichuan-13b-chat's model effect (), which can be used instantly with this shibing624 vicuna-baichuan-13b-chat model. huggingface.co supports a free trial of the vicuna-baichuan-13b-chat model, and also provides paid use of the vicuna-baichuan-13b-chat. Support call vicuna-baichuan-13b-chat model through api, including Node.js, Python, http.
vicuna-baichuan-13b-chat huggingface.co is an online trial and call api platform, which integrates vicuna-baichuan-13b-chat's modeling effects, including api services, and provides a free online trial of vicuna-baichuan-13b-chat, you can try vicuna-baichuan-13b-chat online for free by clicking the link below.
shibing624 vicuna-baichuan-13b-chat online free url in huggingface.co:
vicuna-baichuan-13b-chat is an open source model from GitHub that offers a free installation service, and any user can find vicuna-baichuan-13b-chat on GitHub to install. At the same time, huggingface.co provides the effect of vicuna-baichuan-13b-chat install, users can directly use vicuna-baichuan-13b-chat installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
vicuna-baichuan-13b-chat install url in huggingface.co: