Text Generation
Transformers
Safetensors
English
internlm2
feature-extraction
ai-safety
safetyguard
safety
benchmark
internlm
evaluation
judge
conversational
custom_code
Instructions to use OpenSafetyLab/MD-Judge-v0_2-internlm2_7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenSafetyLab/MD-Judge-v0_2-internlm2_7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenSafetyLab/MD-Judge-v0_2-internlm2_7b", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("OpenSafetyLab/MD-Judge-v0_2-internlm2_7b", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenSafetyLab/MD-Judge-v0_2-internlm2_7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenSafetyLab/MD-Judge-v0_2-internlm2_7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenSafetyLab/MD-Judge-v0_2-internlm2_7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OpenSafetyLab/MD-Judge-v0_2-internlm2_7b
- SGLang
How to use OpenSafetyLab/MD-Judge-v0_2-internlm2_7b 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 "OpenSafetyLab/MD-Judge-v0_2-internlm2_7b" \ --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": "OpenSafetyLab/MD-Judge-v0_2-internlm2_7b", "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 "OpenSafetyLab/MD-Judge-v0_2-internlm2_7b" \ --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": "OpenSafetyLab/MD-Judge-v0_2-internlm2_7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use OpenSafetyLab/MD-Judge-v0_2-internlm2_7b with Docker Model Runner:
docker model run hf.co/OpenSafetyLab/MD-Judge-v0_2-internlm2_7b
add chattemplate in tokenizer_config.json
Browse files
README.md
CHANGED
|
@@ -66,7 +66,7 @@ Compare our this model with other models on different public safety testsets usi
|
|
| 66 |
|
| 67 |
Since we have added the chat_template in `tokenzier_config.json`, you can direct use our model without complicated chat_template.
|
| 68 |
|
| 69 |
-
Here is the [VLLM](https://docs.vllm.ai/en/latest/getting_started/installation/gpu/index.html) usage
|
| 70 |
|
| 71 |
```python
|
| 72 |
from transformers import AutoTokenizer
|
|
@@ -88,7 +88,7 @@ output = llm.generate(prompt, sampling_params=SamplingParams(max_tokens=256))
|
|
| 88 |
print(output[0]['outputs'][0].text.strip())
|
| 89 |
```
|
| 90 |
|
| 91 |
-
Here is the [Transformer](https://github.com/huggingface/transformers) usage
|
| 92 |
|
| 93 |
```python
|
| 94 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
|
| 66 |
|
| 67 |
Since we have added the chat_template in `tokenzier_config.json`, you can direct use our model without complicated chat_template.
|
| 68 |
|
| 69 |
+
Here is the [VLLM](https://docs.vllm.ai/en/latest/getting_started/installation/gpu/index.html) usage example:
|
| 70 |
|
| 71 |
```python
|
| 72 |
from transformers import AutoTokenizer
|
|
|
|
| 88 |
print(output[0]['outputs'][0].text.strip())
|
| 89 |
```
|
| 90 |
|
| 91 |
+
Here is the [Transformer](https://github.com/huggingface/transformers) usage example:
|
| 92 |
|
| 93 |
```python
|
| 94 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|