Text Generation
Transformers
Safetensors
qwen2
multilingual
sea
sailor
conversational
text-generation-inference
Instructions to use sail/Sailor2-20B-Pre with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sail/Sailor2-20B-Pre with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sail/Sailor2-20B-Pre") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sail/Sailor2-20B-Pre") model = AutoModelForCausalLM.from_pretrained("sail/Sailor2-20B-Pre") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use sail/Sailor2-20B-Pre with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sail/Sailor2-20B-Pre" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sail/Sailor2-20B-Pre", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sail/Sailor2-20B-Pre
- SGLang
How to use sail/Sailor2-20B-Pre 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 "sail/Sailor2-20B-Pre" \ --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": "sail/Sailor2-20B-Pre", "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 "sail/Sailor2-20B-Pre" \ --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": "sail/Sailor2-20B-Pre", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sail/Sailor2-20B-Pre with Docker Model Runner:
docker model run hf.co/sail/Sailor2-20B-Pre
[WIP] Upload folder using huggingface_hub (multi-commit ed81deca65a5f611bd6a6fbafb7ea4a7f2b745029bb02268015e18a625a62875)
#1
by dreamerdeo - opened
Upload folder using huggingface_hub
Multi commit ID: ed81deca65a5f611bd6a6fbafb7ea4a7f2b745029bb02268015e18a625a62875
Scheduled commits:
- Upload 1 file(s) totalling 4.2G (55e55a718629c6c2d8c067503b89cbc8e06e0e1f3c7386f892c71354dc64dc6e)
- Upload 1 file(s) totalling 4.1G (9ba6e5e5bf5467a933fe8c99d836f520c3398626688986a220bf75a1d14c5053)
- Upload 1 file(s) totalling 4.1G (39094868be83875f3f89d050a6777b5c3e7e6883f594414f2cc7a2cb5c71a55e)
- Upload 1 file(s) totalling 4.1G (69d25664b936b1f44dc95abb1be996c69851950020b7effbbcef8d8f10e3f9e7)
- Upload 1 file(s) totalling 4.1G (b1f38bca20c3ba089b8b72451acc6f5abb7a0ca05a03ba9e04c9ec0ba06a7e0b)
- Upload 1 file(s) totalling 4.1G (84ba31fe015f6032398db1f730319f6341ec903e5fde6f492901d4e71d61fd53)
- Upload 1 file(s) totalling 4.1G (40e807bcbd89b056a2c41a92dc7519d359e674e9bddc6bb51b8b8fdbcc240a7a)
- Upload 1 file(s) totalling 4.1G (7b8accd324ebb183c0560f1700f1a12417f09ad351f7a6aa32b2717f467f8039)
- Upload 1 file(s) totalling 3.7G (75e3bafcca2692483ea0987918847edc3e018245b03439cfa9cc2f5f33d3323e)
- Upload 1 file(s) totalling 4.2G (509feebe9d7a768cef5b5258a35a850a806e1905896d1395501f4a8a5d8d7fcf)
- Upload 1 file(s) totalling 4.1G (f1df8f7004a6a021f249704d12de6612850c5ed5a6f410c0af56fa9a66db5a28)
- Upload 1 file(s) totalling 4.1G (fa25bd298b0d3e7dbbca528a40a8dfc71da6350edd6f72864092ec5488f599b0)
- Upload 1 file(s) totalling 4.1G (63fdc05318b8d9f93135795126b86b853d6764934ee97ac1834f6987dae8b7ed)
- Upload 1 file(s) totalling 4.1G (0745155b035aabc8830d4a27861da83e5f31931f263f8e50668640d6bc15b84b)
- Upload 1 file(s) totalling 4.1G (e9a783dc75086b026fcf38162f66ea1d67a2fd06a76001afe88c95bc292daef9)
- Upload 1 file(s) totalling 4.1G (dbe777432eec00353187f5d34c974e5e626c8786a8b0348074855607b0cc3ac7)
- Upload 1 file(s) totalling 4.1G (7519f46a90d862f2d6f7f0b198d8a9b2cbb986daeb63333d63706aa85196e226)
- Upload 1 file(s) totalling 3.7G (93cf49dd5dd98187334926ecdc2961e29b85a1c19d5776a2aa97f792512ab8bc)
- Upload 16 file(s) totalling 1.6G (d2596597c1cdcb93c2f4df92978161d8e7bd4a1528bf4d2395f2113ae6dd30fb)
- Upload 6 file(s) totalling 1.6G (2c7f2c7dc86fd5574166cc7f6983b66aa9c0f7db99724cb2be5fe9a4ac5710bb)
This is a PR opened using the huggingface_hub library in the context of a multi-commit. PR can be commented as a usual PR. However, please be aware that manually updating the PR description, changing the PR status, or pushing new commits, is not recommended as it might corrupt the commit process. Learn more about multi-commits in this guide.