from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
model_path = "LinkSoul/Chinese-Llama-2-7b"
tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
model = AutoModelForCausalLM.from_pretrained(model_path).half().cuda()
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
instruction = """[INST] <<SYS>>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n<</SYS>>\n\n{} [/INST]"""
prompt = instruction.format("用英文回答,什么是夫妻肺片?")
generate_ids = model.generate(tokenizer(prompt, return_tensors='pt').input_ids.cuda(), max_new_tokens=4096, streamer=streamer)
Chinese-Llama-2-7b huggingface.co is an AI model on huggingface.co that provides Chinese-Llama-2-7b's model effect (), which can be used instantly with this LinkSoul Chinese-Llama-2-7b model. huggingface.co supports a free trial of the Chinese-Llama-2-7b model, and also provides paid use of the Chinese-Llama-2-7b. Support call Chinese-Llama-2-7b model through api, including Node.js, Python, http.
Chinese-Llama-2-7b huggingface.co is an online trial and call api platform, which integrates Chinese-Llama-2-7b's modeling effects, including api services, and provides a free online trial of Chinese-Llama-2-7b, you can try Chinese-Llama-2-7b online for free by clicking the link below.
LinkSoul Chinese-Llama-2-7b online free url in huggingface.co:
Chinese-Llama-2-7b is an open source model from GitHub that offers a free installation service, and any user can find Chinese-Llama-2-7b on GitHub to install. At the same time, huggingface.co provides the effect of Chinese-Llama-2-7b install, users can directly use Chinese-Llama-2-7b installed effect in huggingface.co for debugging and trial. It also supports api for free installation.