Downloads · 30 days
0
Laurie/baichuan-7b-lora-alpaca-cn
baichuan-7b-lora-alpaca-cn is a text generation model from Laurie. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Downloads · 30 days
0
Access
Public
Updated Jun 16, 2023
Repo size
16.8 MB
Likes
4
Public
Click a slice to open those files.
.bin16.8 MB · 99%
From the Hugging Face model README
使用transformers推理:
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
from peft import PeftModel
tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/baichuan-7B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("baichuan-inc/baichuan-7B", device_map="auto", trust_remote_code=True)
model = PeftModel.from_pretrained(model, "Laurie/baichuan-7b-lora-alpaca-cn")
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
query = "天空为什么是蓝色的?"
inputs = tokenizer(["<human>:{}\n<bot>:".format(query)], return_tensors="pt")
inputs = inputs.to("cuda")
generate_ids = model.generate(**inputs, max_new_tokens=256, streamer=streamer)