Text Generation
Transformers
Safetensors
English
Chinese
internlm2
feature-extraction
chemistry
conversational
custom_code
Instructions to use AI4Chem/ChemLLM-20B-Chat-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AI4Chem/ChemLLM-20B-Chat-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AI4Chem/ChemLLM-20B-Chat-SFT", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AI4Chem/ChemLLM-20B-Chat-SFT", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use AI4Chem/ChemLLM-20B-Chat-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AI4Chem/ChemLLM-20B-Chat-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AI4Chem/ChemLLM-20B-Chat-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AI4Chem/ChemLLM-20B-Chat-SFT
- SGLang
How to use AI4Chem/ChemLLM-20B-Chat-SFT 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 "AI4Chem/ChemLLM-20B-Chat-SFT" \ --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": "AI4Chem/ChemLLM-20B-Chat-SFT", "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 "AI4Chem/ChemLLM-20B-Chat-SFT" \ --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": "AI4Chem/ChemLLM-20B-Chat-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AI4Chem/ChemLLM-20B-Chat-SFT with Docker Model Runner:
docker model run hf.co/AI4Chem/ChemLLM-20B-Chat-SFT
Di Zhang commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -71,17 +71,21 @@ You can format it into this InternLM2 Dialogue format like,
|
|
| 71 |
```
|
| 72 |
def InternLM2_format(instruction,prompt,answer,history):
|
| 73 |
prefix_template=[
|
| 74 |
-
"<|
|
| 75 |
-
"{}"
|
|
|
|
| 76 |
]
|
| 77 |
prompt_template=[
|
| 78 |
-
"<|
|
| 79 |
-
"{}
|
| 80 |
-
"<|
|
|
|
|
|
|
|
|
|
|
| 81 |
]
|
| 82 |
-
system = f'{prefix_template[0]}
|
| 83 |
-
history = "
|
| 84 |
-
prompt = f'
|
| 85 |
return f"{system}{history}{prompt}"
|
| 86 |
```
|
| 87 |
And there is a good example for system prompt,
|
|
|
|
| 71 |
```
|
| 72 |
def InternLM2_format(instruction,prompt,answer,history):
|
| 73 |
prefix_template=[
|
| 74 |
+
"<|im_start|>system\n",
|
| 75 |
+
"{}",
|
| 76 |
+
"<|im_end|>\n"
|
| 77 |
]
|
| 78 |
prompt_template=[
|
| 79 |
+
"<|im_start|>user\n",
|
| 80 |
+
"{}",
|
| 81 |
+
"<|im_end|>\n"
|
| 82 |
+
"<|im_start|>assistant\n",
|
| 83 |
+
"{}",
|
| 84 |
+
"<|im_end|>\n"
|
| 85 |
]
|
| 86 |
+
system = f'{prefix_template[0]}{prefix_template[1].format(instruction)}{prefix_template[2]}'
|
| 87 |
+
history = "".join([f'{prompt_template[0]}{prompt_template[1].format(qa[0])}{prompt_template[2]}{prompt_template[3]}{prompt_template[4].format(qa[1])}{prompt_template[5]}' for qa in history])
|
| 88 |
+
prompt = f'{prompt_template[0]}{prompt_template[1].format(prompt)}{prompt_template[2]}{prompt_template[3]}'
|
| 89 |
return f"{system}{history}{prompt}"
|
| 90 |
```
|
| 91 |
And there is a good example for system prompt,
|