Instructions to use internlm/internlm2-math-base-20b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use internlm/internlm2-math-base-20b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="internlm/internlm2-math-base-20b", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("internlm/internlm2-math-base-20b", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use internlm/internlm2-math-base-20b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "internlm/internlm2-math-base-20b" # 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/internlm2-math-base-20b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/internlm/internlm2-math-base-20b
- SGLang
How to use internlm/internlm2-math-base-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/internlm2-math-base-20b" \ --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/internlm2-math-base-20b", "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 "internlm/internlm2-math-base-20b" \ --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/internlm2-math-base-20b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use internlm/internlm2-math-base-20b with Docker Model Runner:
docker model run hf.co/internlm/internlm2-math-base-20b
Update configuration_internlm.py
Browse files
configuration_internlm.py
CHANGED
|
@@ -108,6 +108,7 @@ class InternLMConfig(PretrainedConfig):
|
|
| 108 |
bias=True,
|
| 109 |
rope_theta=10000,
|
| 110 |
rope_scaling=None,
|
|
|
|
| 111 |
**kwargs,
|
| 112 |
):
|
| 113 |
self.vocab_size = vocab_size
|
|
@@ -129,6 +130,10 @@ class InternLMConfig(PretrainedConfig):
|
|
| 129 |
self.rope_theta = rope_theta
|
| 130 |
self.rope_scaling = rope_scaling
|
| 131 |
self._rope_scaling_validation()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
super().__init__(
|
| 133 |
pad_token_id=pad_token_id,
|
| 134 |
bos_token_id=bos_token_id,
|
|
|
|
| 108 |
bias=True,
|
| 109 |
rope_theta=10000,
|
| 110 |
rope_scaling=None,
|
| 111 |
+
attn_implementation="eager",
|
| 112 |
**kwargs,
|
| 113 |
):
|
| 114 |
self.vocab_size = vocab_size
|
|
|
|
| 130 |
self.rope_theta = rope_theta
|
| 131 |
self.rope_scaling = rope_scaling
|
| 132 |
self._rope_scaling_validation()
|
| 133 |
+
|
| 134 |
+
self.attn_implementation = attn_implementation
|
| 135 |
+
if self.attn_implementation is None:
|
| 136 |
+
self.attn_implementation = "eager"
|
| 137 |
super().__init__(
|
| 138 |
pad_token_id=pad_token_id,
|
| 139 |
bos_token_id=bos_token_id,
|