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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("internlm/internlm-chat-20b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- 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
Update README.md
Browse files
README.md
CHANGED
|
@@ -76,8 +76,8 @@ Overall, InternLM-20B comprehensively outperforms open-source models in the 13B
|
|
| 76 |
To load the InternLM 7B Chat model using Transformers, use the following code:
|
| 77 |
```python
|
| 78 |
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 79 |
-
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-
|
| 80 |
-
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm-
|
| 81 |
>>> model = model.eval()
|
| 82 |
>>> inputs = tokenizer(["Coming to the beautiful nature, we found"], return_tensors="pt")
|
| 83 |
>>> for k,v in inputs.items():
|
|
@@ -146,8 +146,8 @@ InternLM 20B 在模型结构上选择了深结构,层数设定为60层,超
|
|
| 146 |
通过以下的代码加载 InternLM 20B 模型
|
| 147 |
```python
|
| 148 |
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 149 |
-
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-
|
| 150 |
-
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm-
|
| 151 |
>>> model = model.eval()
|
| 152 |
>>> inputs = tokenizer(["来到美丽的大自然,我们发现"], return_tensors="pt")
|
| 153 |
>>> for k,v in inputs.items():
|
|
|
|
| 76 |
To load the InternLM 7B Chat model using Transformers, use the following code:
|
| 77 |
```python
|
| 78 |
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 79 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-chat-20b", trust_remote_code=True)
|
| 80 |
+
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm-chat-20b", trust_remote_code=True).cuda()
|
| 81 |
>>> model = model.eval()
|
| 82 |
>>> inputs = tokenizer(["Coming to the beautiful nature, we found"], return_tensors="pt")
|
| 83 |
>>> for k,v in inputs.items():
|
|
|
|
| 146 |
通过以下的代码加载 InternLM 20B 模型
|
| 147 |
```python
|
| 148 |
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 149 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-chat-20b", trust_remote_code=True)
|
| 150 |
+
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm-chat-20b", trust_remote_code=True).cuda()
|
| 151 |
>>> model = model.eval()
|
| 152 |
>>> inputs = tokenizer(["来到美丽的大自然,我们发现"], return_tensors="pt")
|
| 153 |
>>> for k,v in inputs.items():
|