Text Generation
Transformers
PyTorch
internlm
feature-extraction
text-generation-inference
custom_code
Instructions to use lmdeploy/internlm-chat-7b-w4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lmdeploy/internlm-chat-7b-w4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lmdeploy/internlm-chat-7b-w4", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("lmdeploy/internlm-chat-7b-w4", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lmdeploy/internlm-chat-7b-w4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lmdeploy/internlm-chat-7b-w4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lmdeploy/internlm-chat-7b-w4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/lmdeploy/internlm-chat-7b-w4
- SGLang
How to use lmdeploy/internlm-chat-7b-w4 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 "lmdeploy/internlm-chat-7b-w4" \ --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": "lmdeploy/internlm-chat-7b-w4", "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 "lmdeploy/internlm-chat-7b-w4" \ --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": "lmdeploy/internlm-chat-7b-w4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use lmdeploy/internlm-chat-7b-w4 with Docker Model Runner:
docker model run hf.co/lmdeploy/internlm-chat-7b-w4
support transformers 4.34.0
#1
by unsubscribe - opened
- tokenization_internlm.py +7 -7
tokenization_internlm.py
CHANGED
|
@@ -65,6 +65,13 @@ class InternLMTokenizer(PreTrainedTokenizer):
|
|
| 65 |
**kwargs,
|
| 66 |
):
|
| 67 |
self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
super().__init__(
|
| 69 |
bos_token=bos_token,
|
| 70 |
eos_token=eos_token,
|
|
@@ -73,13 +80,6 @@ class InternLMTokenizer(PreTrainedTokenizer):
|
|
| 73 |
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
| 74 |
**kwargs,
|
| 75 |
)
|
| 76 |
-
self.vocab_file = vocab_file
|
| 77 |
-
self.add_bos_token = add_bos_token
|
| 78 |
-
self.add_eos_token = add_eos_token
|
| 79 |
-
self.decode_with_prefix_space = decode_with_prefix_space
|
| 80 |
-
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 81 |
-
self.sp_model.Load(vocab_file)
|
| 82 |
-
self._no_prefix_space_tokens = None
|
| 83 |
|
| 84 |
""" Initialisation"""
|
| 85 |
|
|
|
|
| 65 |
**kwargs,
|
| 66 |
):
|
| 67 |
self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
|
| 68 |
+
self.vocab_file = vocab_file
|
| 69 |
+
self.add_bos_token = add_bos_token
|
| 70 |
+
self.add_eos_token = add_eos_token
|
| 71 |
+
self.decode_with_prefix_space = decode_with_prefix_space
|
| 72 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 73 |
+
self.sp_model.Load(vocab_file)
|
| 74 |
+
self._no_prefix_space_tokens = None
|
| 75 |
super().__init__(
|
| 76 |
bos_token=bos_token,
|
| 77 |
eos_token=eos_token,
|
|
|
|
| 80 |
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
| 81 |
**kwargs,
|
| 82 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
""" Initialisation"""
|
| 85 |
|