Instructions to use csdc-atl/baichuan-7B-chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use csdc-atl/baichuan-7B-chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="csdc-atl/baichuan-7B-chat", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("csdc-atl/baichuan-7B-chat", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use csdc-atl/baichuan-7B-chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "csdc-atl/baichuan-7B-chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "csdc-atl/baichuan-7B-chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/csdc-atl/baichuan-7B-chat
- SGLang
How to use csdc-atl/baichuan-7B-chat 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 "csdc-atl/baichuan-7B-chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "csdc-atl/baichuan-7B-chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "csdc-atl/baichuan-7B-chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "csdc-atl/baichuan-7B-chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use csdc-atl/baichuan-7B-chat with Docker Model Runner:
docker model run hf.co/csdc-atl/baichuan-7B-chat
baichuan-7B-chat
介绍
baichuan-7B-chat是在私有对话指令数据上微调的多轮对话模型。
- 基座模型是baichuan-7B,是由百川智能开发的一个开源可商用的大规模预训练语言模型。
- 训练数据为私有多轮对话指令数据。
代码调用
可以通过如下代码调用 baichuan-7B-chat 模型来生成对话:
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
>>> tokenizer = AutoTokenizer.from_pretrained("csdc-atl/baichuan-7B-chat", trust_remote_code=True)
>>> model = AutoModelForCausalLM.from_pretrained("csdc-atl/baichuan-7B-chat", trust_remote_code=True).half().cuda()
>>> response, history = model.chat(tokenizer, "“面朝大海,春暖花开”的出处是?", history=[])
>>> print(response)
“面朝大海,春暖花开”是一句著名的诗歌,出自中国现代诗人海子之手。这首诗表达了对大海的热爱和对春天的向往,同时也反映了诗人对生命和自然的感悟和思考。这首诗被广泛传诵和引用,成为了中国现代诗歌中的经典之作。
>>> response, history = model.chat(tokenizer, "能不能把这一首诗完整背诵一下", history=history)
>>> print(response)
当然可以,以下是“面朝大海,春暖花开”的原文:
面朝大海,春暖花开
从明天起,做一个幸福的人
喂马,劈柴,周游世界
从明天起,关心粮食和蔬菜
我有一所房子,面朝大海,春暖花开
从明天起,和每一个亲人通信
告诉他们我的幸福
那幸福的闪电告诉我的
我将告诉每一个人
给每一条河每一座山取一个温暖的名字
陌生人,我也为你祝福
愿你有一个灿烂的前程
愿你有情人终成眷属
愿你在尘世获得幸福
我只愿面朝大海,春暖花开
局限性
本项目中的模型存在局限性,包括但不限于:
- 在面对事实性知识任务时,可能会生成不正确的信息或者产生不稳定的输出(有时可以返回正确答案,有时不能)。
协议
本仓库的代码依照 Apache-2.0 协议开源。
baichuan-7B-chat模型支持商用。但按照baichuan-7B的要求,如果将baichuan-7B衍生品用作商业用途,需要联系baichuan-7B的许可方。
- Downloads last month
- 58