Instructions to use internlm/internlm-chat-20b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use internlm/internlm-chat-20b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="internlm/internlm-chat-20b", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("internlm/internlm-chat-20b", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use internlm/internlm-chat-20b 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" # 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", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/internlm/internlm-chat-20b
- SGLang
How to use internlm/internlm-chat-20b 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" \ --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", "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" \ --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", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use internlm/internlm-chat-20b with Docker Model Runner:
docker model run hf.co/internlm/internlm-chat-20b
Support dynamic ntk rope
Browse files
configuration_internlm.py
CHANGED
|
@@ -19,9 +19,8 @@
|
|
| 19 |
# limitations under the License.
|
| 20 |
""" InternLM model configuration"""
|
| 21 |
|
| 22 |
-
from transformers.utils import logging
|
| 23 |
from transformers.configuration_utils import PretrainedConfig
|
| 24 |
-
|
| 25 |
|
| 26 |
logger = logging.get_logger(__name__)
|
| 27 |
|
|
@@ -30,9 +29,9 @@ INTERNLM_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
|
| 30 |
|
| 31 |
class InternLMConfig(PretrainedConfig):
|
| 32 |
r"""
|
| 33 |
-
This is the configuration class to store the configuration of a [`InternLMModel`]. It is used to instantiate
|
| 34 |
-
model according to the specified arguments, defining the model architecture. Instantiating a
|
| 35 |
-
defaults will yield a similar configuration to that of the InternLM-7B.
|
| 36 |
|
| 37 |
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 38 |
documentation from [`PretrainedConfig`] for more information.
|
|
@@ -81,7 +80,7 @@ class InternLMConfig(PretrainedConfig):
|
|
| 81 |
model_type = "internlm"
|
| 82 |
_auto_class = "AutoConfig"
|
| 83 |
|
| 84 |
-
def __init__(
|
| 85 |
self,
|
| 86 |
vocab_size=103168,
|
| 87 |
hidden_size=4096,
|
|
@@ -98,6 +97,7 @@ class InternLMConfig(PretrainedConfig):
|
|
| 98 |
eos_token_id=2,
|
| 99 |
tie_word_embeddings=False,
|
| 100 |
bias=True,
|
|
|
|
| 101 |
**kwargs,
|
| 102 |
):
|
| 103 |
self.vocab_size = vocab_size
|
|
@@ -111,10 +111,11 @@ class InternLMConfig(PretrainedConfig):
|
|
| 111 |
self.rms_norm_eps = rms_norm_eps
|
| 112 |
self.use_cache = use_cache
|
| 113 |
self.bias = bias
|
|
|
|
| 114 |
super().__init__(
|
| 115 |
pad_token_id=pad_token_id,
|
| 116 |
bos_token_id=bos_token_id,
|
| 117 |
eos_token_id=eos_token_id,
|
| 118 |
tie_word_embeddings=tie_word_embeddings,
|
| 119 |
**kwargs,
|
| 120 |
-
)
|
|
|
|
| 19 |
# limitations under the License.
|
| 20 |
""" InternLM model configuration"""
|
| 21 |
|
|
|
|
| 22 |
from transformers.configuration_utils import PretrainedConfig
|
| 23 |
+
from transformers.utils import logging
|
| 24 |
|
| 25 |
logger = logging.get_logger(__name__)
|
| 26 |
|
|
|
|
| 29 |
|
| 30 |
class InternLMConfig(PretrainedConfig):
|
| 31 |
r"""
|
| 32 |
+
This is the configuration class to store the configuration of a [`InternLMModel`]. It is used to instantiate
|
| 33 |
+
an InternLM model according to the specified arguments, defining the model architecture. Instantiating a
|
| 34 |
+
configuration with the defaults will yield a similar configuration to that of the InternLM-7B.
|
| 35 |
|
| 36 |
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 37 |
documentation from [`PretrainedConfig`] for more information.
|
|
|
|
| 80 |
model_type = "internlm"
|
| 81 |
_auto_class = "AutoConfig"
|
| 82 |
|
| 83 |
+
def __init__( # pylint: disable=W0102
|
| 84 |
self,
|
| 85 |
vocab_size=103168,
|
| 86 |
hidden_size=4096,
|
|
|
|
| 97 |
eos_token_id=2,
|
| 98 |
tie_word_embeddings=False,
|
| 99 |
bias=True,
|
| 100 |
+
rotary={"base": 10000, "type": "dynamic"}, # pylint: disable=W0102
|
| 101 |
**kwargs,
|
| 102 |
):
|
| 103 |
self.vocab_size = vocab_size
|
|
|
|
| 111 |
self.rms_norm_eps = rms_norm_eps
|
| 112 |
self.use_cache = use_cache
|
| 113 |
self.bias = bias
|
| 114 |
+
self.rotary = rotary
|
| 115 |
super().__init__(
|
| 116 |
pad_token_id=pad_token_id,
|
| 117 |
bos_token_id=bos_token_id,
|
| 118 |
eos_token_id=eos_token_id,
|
| 119 |
tie_word_embeddings=tie_word_embeddings,
|
| 120 |
**kwargs,
|
| 121 |
+
)
|