Instructions to use bartowski/internlm2-chat-7b-llama with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bartowski/internlm2-chat-7b-llama with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bartowski/internlm2-chat-7b-llama") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bartowski/internlm2-chat-7b-llama") model = AutoModelForCausalLM.from_pretrained("bartowski/internlm2-chat-7b-llama") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bartowski/internlm2-chat-7b-llama with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bartowski/internlm2-chat-7b-llama" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bartowski/internlm2-chat-7b-llama", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/bartowski/internlm2-chat-7b-llama
- SGLang
How to use bartowski/internlm2-chat-7b-llama 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 "bartowski/internlm2-chat-7b-llama" \ --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": "bartowski/internlm2-chat-7b-llama", "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 "bartowski/internlm2-chat-7b-llama" \ --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": "bartowski/internlm2-chat-7b-llama", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use bartowski/internlm2-chat-7b-llama with Docker Model Runner:
docker model run hf.co/bartowski/internlm2-chat-7b-llama
Update chat template
#2
by eduagarcia - opened
- tokenizer_config.json +59 -2
tokenizer_config.json
CHANGED
|
@@ -25,16 +25,73 @@
|
|
| 25 |
"rstrip": false,
|
| 26 |
"single_word": false,
|
| 27 |
"special": true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
"auto_map": {
|
| 31 |
"AutoTokenizer": [
|
| 32 |
-
"
|
| 33 |
null
|
| 34 |
]
|
| 35 |
},
|
| 36 |
"bos_token": "<s>",
|
| 37 |
-
"clean_up_tokenization_spaces":
|
|
|
|
| 38 |
"eos_token": "</s>",
|
| 39 |
"legacy": true,
|
| 40 |
"model_max_length": 1000000000000000019884624838656,
|
|
|
|
| 25 |
"rstrip": false,
|
| 26 |
"single_word": false,
|
| 27 |
"special": true
|
| 28 |
+
},
|
| 29 |
+
"92543": {
|
| 30 |
+
"content": "<|im_start|>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"92542": {
|
| 38 |
+
"content": "<|im_end|>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": true
|
| 44 |
+
},
|
| 45 |
+
"92541": {
|
| 46 |
+
"content": "<|action_start|>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": true
|
| 52 |
+
},
|
| 53 |
+
"92540": {
|
| 54 |
+
"content": "<|action_end|>",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": true
|
| 60 |
+
},
|
| 61 |
+
"92539": {
|
| 62 |
+
"content": "<|interpreter|>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": true
|
| 68 |
+
},
|
| 69 |
+
"92538": {
|
| 70 |
+
"content": "<|plugin|>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": true
|
| 76 |
}
|
| 77 |
},
|
| 78 |
+
"additional_special_tokens": [
|
| 79 |
+
"<|im_start|>",
|
| 80 |
+
"<|im_end|>",
|
| 81 |
+
"<|action_start|>",
|
| 82 |
+
"<|action_end|>",
|
| 83 |
+
"<|interpreter|>",
|
| 84 |
+
"<|plugin|>"
|
| 85 |
+
],
|
| 86 |
"auto_map": {
|
| 87 |
"AutoTokenizer": [
|
| 88 |
+
"internlm/internlm2-chat-7b--tokenization_internlm2.InternLM2Tokenizer",
|
| 89 |
null
|
| 90 |
]
|
| 91 |
},
|
| 92 |
"bos_token": "<s>",
|
| 93 |
+
"clean_up_tokenization_spaces": false,
|
| 94 |
+
"chat_template": "{{ bos_token }}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
| 95 |
"eos_token": "</s>",
|
| 96 |
"legacy": true,
|
| 97 |
"model_max_length": 1000000000000000019884624838656,
|