Text Generation
Transformers
Safetensors
Chinese
baichuan
feature-extraction
art
marketing
llama-factory
conversational
custom_code
text-generation-inference
Instructions to use JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT
- SGLang
How to use JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT with Docker Model Runner:
docker model run hf.co/JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT
How to use from
SGLangUse Docker images
docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT" \
--host 0.0.0.0 \
--port 30000# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'Quick Links
Baichuan2-7B-Chat-DcardStylePost-SFT
💻 Usage
!pip install -qU transformers accelerate
from transformers import AutoTokenizer
import transformers
import torch
model = "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT"
messages = [{"role": "user", "content": "【任务】:\n你是口碑行销公司的资深写手,现在要撰写一篇Dcard 『闲聊版』的口碑文。\n麻烦熟读下列 【参考资料】将商品或品牌与生活情境的融合,并尽量贴近生活口吻,以不要被发现是业配文为重要目标。\n请依照【口碑切角】为文章的故事主轴撰写整篇文章,请参考并依照【规范】角色口吻来撰写文章,融入角色情境来完成整篇故事撰写,请注重人物角色特色及限制。\n\n-\n\n【规范】:\n\n1.需产出文章标题\n2.请以第一人称方式撰写文章\n3.请记住现在是时间是西元 2023 年\n4.Please write in zh-TW language .\n5.降低口碑文业配感\n6.写作者是一个19~25岁之间的女生的大学生或是社会新鲜人\n7.喜爱吃甜食,常常带著男友一起去踩点试吃看看\n8.除了介绍食物,也喜欢顺便男友发生好笑的趣事来跟食物介绍的故事结合\n9.为降低口碑文业配感,请多多举几个甜点推荐\n10.喜欢应用很多可爱的颜文字和emoji\n\n-\n\n【参考资料】\n▲可丽露\n>>龙眼蜜,所以吃起来不会这么甜,跟其他家的可丽露吃起来真的很有差异\n以野生龙眼蜜减低并取代部分甜度,带出微微酸感的蛋蜜香,外脆内湿润的口感,完整的蜂巢组织度,木质调的兰姆酒香,法国盐之花平衡了整体,经典细致的马达加斯加香草籽原味,请在出炉后的3小时内食用完毕或\"冷冻\"保存,回烤后食用最接近现烤口感!\n\n\n\n▲奶盖布丁\n>>法国盐之花,连盐巴都很用心的甜点师\n带咸度的法国盐之花奶盖,微甜浓郁而不腻口的布蕾布丁体,和著偏苦的手煮焦糖液,是一款有著丰富层次的大人味布丁! 图片为示意仅供参考,食用时请由上方挖到底,品尝完整风味~\n\n【口碑切角】\n男友就像金鱼一样,好像记忆都只有三秒,\n只有三秒就算了还说错很多很好笑的话XD\n我都会带甜点回去给男友吃~结果男友居然说玛莉露很好吃XD\n玛莉露是神奇宝贝,可丽露才是甜点啦!\n分享日常男友都会口误的甜点们"}]
tokenizer = AutoTokenizer.from_pretrained(model)
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
pipeline = transformers.pipeline(
"text-generation",
model=model,
torch_dtype=torch.float16,
device_map="auto",
)
outputs = pipeline(prompt, max_new_tokens=512, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
print(outputs[0]["generated_text"])
- Downloads last month
- 5
Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT" \ --host 0.0.0.0 \ --port 30000# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JiunYi/Baichuan2-7B-Chat-DcardStylePost-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'