Instructions to use internlm/Intern-S2-397B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use internlm/Intern-S2-397B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="internlm/Intern-S2-397B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("internlm/Intern-S2-397B") model = AutoModelForMultimodalLM.from_pretrained("internlm/Intern-S2-397B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use internlm/Intern-S2-397B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "internlm/Intern-S2-397B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "internlm/Intern-S2-397B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/internlm/Intern-S2-397B
- SGLang
How to use internlm/Intern-S2-397B 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 "internlm/Intern-S2-397B" \ --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": "internlm/Intern-S2-397B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "internlm/Intern-S2-397B" \ --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": "internlm/Intern-S2-397B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use internlm/Intern-S2-397B with Docker Model Runner:
docker model run hf.co/internlm/Intern-S2-397B
|
Download deployment_guide.md from internlm/Intern-S2-397B: direct link, hf CLI and curl.
- Browser
- Download file 4.37 kB
-
https://huggingface.co/internlm/Intern-S2-397B/resolve/main/deployment_guide.md
- Command line
-
hf download hf://internlm/Intern-S2-397B/deployment_guide.md
-
curl -L -o deployment_guide.md https://huggingface.co/internlm/Intern-S2-397B/resolve/main/deployment_guide.md
4.37 kB
| # Intern-S2-397B Deployment Guide | |
| We recommend deploying the Intern-S2-397B model on H100 (x8) or H200 (x8) nodes. The next section provides deployment examples for the configurations listed below: | |
| - Basic serving without MTP | |
| - MTP speculative decoding | |
| - Long-context inference with YaRN RoPE configuration | |
| ## LMDeploy (>=0.14.0) | |
| - Basic Serving Without MTP | |
| ```bash | |
| # proxy server | |
| lmdeploy serve proxy --server-name ${proxy_server_ip} --server-port ${proxy_server_port} | |
| # api_server | |
| lmdeploy serve api_server \ | |
| internlm/Intern-S2-FP8 \ | |
| --model-name internlm/Intern-S2-397B \ | |
| --trust-remote-code \ | |
| --backend pytorch \ | |
| --dp 4 \ | |
| --ep 8 \ | |
| --enable-prefix-caching \ | |
| --proxy-url http://${proxy_server_ip}:${proxy_server_port} \ | |
| --reasoning-parser default \ | |
| --tool-call-parser interns2-preview | |
| ``` | |
| - Serving With MTP | |
| ```bash | |
| lmdeploy serve api_server \ | |
| internlm/Intern-S2-FP8 \ | |
| --model-name internlm/Intern-S2-397B \ | |
| --trust-remote-code \ | |
| --backend pytorch \ | |
| --dp 4 \ | |
| --ep 8 \ | |
| --enable-prefix-caching \ | |
| --proxy-url http://${proxy_server_ip}:${proxy_server_port} \ | |
| --reasoning-parser default \ | |
| --tool-call-parser interns2-preview \ | |
| --speculative-algorithm qwen3_5_mtp \ | |
| --speculative-num-draft-tokens 4 \ | |
| --max-batch-size 256 | |
| ``` | |
| - Long-Context Serving | |
| For long-context inference, configure both `--session-len` and YaRN RoPE parameters. The following example uses a 512k context length: | |
| ```bash | |
| lmdeploy serve api_server \ | |
| internlm/Intern-S2-FP8 \ | |
| --model-name internlm/Intern-S2-397B \ | |
| --trust-remote-code \ | |
| --backend pytorch \ | |
| --dp 4 \ | |
| --ep 8 \ | |
| --enable-prefix-caching \ | |
| --reasoning-parser default \ | |
| --tool-call-parser interns2-preview \ | |
| --session-len 512000 \ | |
| --max-batch-size 64 \ | |
| --hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}' | |
| ``` | |
| ## vLLM (>=v0.22.1) | |
| - Basic Serving Without MTP | |
| ```bash | |
| export VLLM_DEEP_GEMM_WARMUP=skip | |
| export VLLM_USE_DEEP_GEMM=0 | |
| export VLLM_FLASHINFER_MOE_BACKEND=latency | |
| vllm serve internlm/Intern-S2-FP8 \ | |
| --served-model-name internlm/Intern-S2-397B \ | |
| --trust-remote-code \ | |
| --tensor-parallel-size 8 \ | |
| --enable-auto-tool-choice \ | |
| --tool-call-parser qwen3_coder \ | |
| --reasoning-parser qwen3 \ | |
| --mm-encoder-tp-mode data | |
| ``` | |
| - Serving With MTP | |
| ```bash | |
| export VLLM_DEEP_GEMM_WARMUP=skip | |
| export VLLM_USE_DEEP_GEMM=0 | |
| export VLLM_FLASHINFER_MOE_BACKEND=latency | |
| vllm serve internlm/Intern-S2-FP8 \ | |
| --served-model-name internlm/Intern-S2-397B \ | |
| --trust-remote-code \ | |
| --tensor-parallel-size 8 \ | |
| --enable-auto-tool-choice \ | |
| --tool-call-parser qwen3_coder \ | |
| --mm-encoder-tp-mode data \ | |
| --reasoning-parser qwen3 \ | |
| --speculative-config '{"method":"mtp","num_speculative_tokens":3}' | |
| ``` | |
| - Long-Context Serving | |
| ```bash | |
| VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 vllm serve internlm/Intern-S2-FP8 \ | |
| --served-model-name internlm/Intern-S2-397B \ | |
| --tensor-parallel-size 8 \ | |
| --max-model-len 1010000 \ | |
| --reasoning-parser qwen3 \ | |
| --hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}' | |
| ``` | |
| ## SGLang (>=v0.5.13) | |
| - Basic Serving Without MTP | |
| ```bash | |
| python3 -m sglang.launch_server \ | |
| --model-path internlm/Intern-S2-FP8 \ | |
| --served-model-name internlm/Intern-S2-397B \ | |
| --trust-remote-code \ | |
| --tp-size 8 \ | |
| --mem-fraction-static 0.8 \ | |
| --enable-flashinfer-allreduce-fusion \ | |
| --reasoning-parser qwen3 \ | |
| --tool-call-parser qwen3_coder | |
| ``` | |
| - Serving With MTP | |
| ```bash | |
| SGLANG_ENABLE_SPEC_V2=1 \ | |
| python3 -m sglang.launch_server \ | |
| --model-path internlm/Intern-S2-FP8 \ | |
| --served-model-name internlm/Intern-S2-397B \ | |
| --trust-remote-code \ | |
| --tp-size 8 \ | |
| --reasoning-parser qwen3 \ | |
| --tool-call-parser qwen3_coder \ | |
| --mem-fraction-static 0.8 \ | |
| --mamba-scheduler-strategy extra_buffer \ | |
| --enable-flashinfer-allreduce-fusion \ | |
| --speculative-algo 'NEXTN' \ | |
| --speculative-eagle-topk 1 \ | |
| --speculative-num-steps 3 \ | |
| --speculative-num-draft-tokens 4 | |
| ``` | |