Instructions to use internlm/internlm-chat-20b-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use internlm/internlm-chat-20b-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="internlm/internlm-chat-20b-4bit", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("internlm/internlm-chat-20b-4bit", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use internlm/internlm-chat-20b-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "internlm/internlm-chat-20b-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "internlm/internlm-chat-20b-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/internlm/internlm-chat-20b-4bit
- SGLang
How to use internlm/internlm-chat-20b-4bit 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/internlm-chat-20b-4bit" \ --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": "internlm/internlm-chat-20b-4bit", "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 "internlm/internlm-chat-20b-4bit" \ --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": "internlm/internlm-chat-20b-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use internlm/internlm-chat-20b-4bit with Docker Model Runner:
docker model run hf.co/internlm/internlm-chat-20b-4bit
although tokenizer.model exists , deploy is complaining that it does not
python3 -m lmdeploy.serve.turbomind.deploy
--model-name internlm-chat-20b
--model-path ./internlm-chat-20b
--model-format awq
--group-size 128
create workspace in directory ./workspace
copy triton model templates from "/home/gediz/.pyenv/versions/lmdeploy/lib/python3.10/site-packages/lmdeploy/serve/turbomind/triton_models" to "./workspace/triton_models" successfully
tokenizer model ./internlm-chat-20b/tokenizer.model does not exist
ls -lah
drwxr-xr-x 3 gediz gediz 4.0K Sep 29 19:41 .
drwx------ 24 gediz gediz 4.0K Sep 29 19:57 ..
-rw-r--r-- 1 gediz gediz 905 Sep 29 19:35 config.json
-rw-r--r-- 1 gediz gediz 5.1K Sep 29 19:35 configuration_internlm.py
-rw-r--r-- 1 gediz gediz 111 Sep 29 19:35 generation_config.json
drwxr-xr-x 9 gediz gediz 4.0K Sep 29 19:41 .git
-rw-r--r-- 1 gediz gediz 1.5K Sep 29 19:35 .gitattributes
-rw-r--r-- 1 gediz gediz 27M Sep 29 19:35 inputs_stats.pth
-rw-r--r-- 1 gediz gediz 1.9M Sep 29 19:35 key_stats.pth
-rw-r--r-- 1 gediz gediz 43K Sep 29 19:35 modeling_internlm.py
-rw-r--r-- 1 gediz gediz 38M Sep 29 19:35 outputs_stats.pth
-rw-r--r-- 1 gediz gediz 9.4G Sep 29 19:41 pytorch_model-00001-of-00002.bin
-rw-r--r-- 1 gediz gediz 1.9G Sep 29 19:36 pytorch_model-00002-of-00002.bin
-rw-r--r-- 1 gediz gediz 111K Sep 29 19:35 pytorch_model.bin.index.json
-rw-r--r-- 1 gediz gediz 4.0K Sep 29 19:35 README.md
-rw-r--r-- 1 gediz gediz 95 Sep 29 19:35 special_tokens_map.json
-rw-r--r-- 1 gediz gediz 8.8K Sep 29 19:35 tokenization_internlm.py
-rw-r--r-- 1 gediz gediz 343 Sep 29 19:35 tokenizer_config.json
-rw-r--r-- 1 gediz gediz 1.6M Sep 29 19:35 tokenizer.model
-rw-r--r-- 1 gediz gediz 1.9M Sep 29 19:35 value_stats.pth
May pass absolute path for --model-path
You may want to check the official website for the .bin file