Text Generation
Transformers
Safetensors
Chinese
English
minicpm
conversational
custom_code
4-bit precision
awq
Instructions to use openbmb/MiniCPM4.1-8B-AutoAWQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/MiniCPM4.1-8B-AutoAWQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openbmb/MiniCPM4.1-8B-AutoAWQ", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM4.1-8B-AutoAWQ", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openbmb/MiniCPM4.1-8B-AutoAWQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/MiniCPM4.1-8B-AutoAWQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM4.1-8B-AutoAWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/openbmb/MiniCPM4.1-8B-AutoAWQ
- SGLang
How to use openbmb/MiniCPM4.1-8B-AutoAWQ 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 "openbmb/MiniCPM4.1-8B-AutoAWQ" \ --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": "openbmb/MiniCPM4.1-8B-AutoAWQ", "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 "openbmb/MiniCPM4.1-8B-AutoAWQ" \ --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": "openbmb/MiniCPM4.1-8B-AutoAWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use openbmb/MiniCPM4.1-8B-AutoAWQ with Docker Model Runner:
docker model run hf.co/openbmb/MiniCPM4.1-8B-AutoAWQ
Update README.md
Browse files
README.md
CHANGED
|
@@ -37,10 +37,10 @@ tokenizer = AutoTokenizer.from_pretrained(
|
|
| 37 |
)
|
| 38 |
device = next(model.model.parameters()).device
|
| 39 |
|
| 40 |
-
# if
|
| 41 |
-
|
| 42 |
-
# if
|
| 43 |
-
formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt = True, enable_thinking = False)
|
| 44 |
|
| 45 |
input_ids = tokenizer.encode(formatted_prompt, return_tensors='pt').to(device)
|
| 46 |
outputs = model.generate(
|
|
@@ -48,10 +48,10 @@ outputs = model.generate(
|
|
| 48 |
max_new_tokens=1000,
|
| 49 |
do_sample=True
|
| 50 |
)
|
| 51 |
-
# if
|
| 52 |
-
|
| 53 |
-
# if
|
| 54 |
-
ans = [i.split("<|im_start|> assistant\n<think>\n\n</think>", 1)[1].strip() for i in tokenizer.batch_decode(outputs)]
|
| 55 |
```
|
| 56 |
|
| 57 |
<p align="center">
|
|
|
|
| 37 |
)
|
| 38 |
device = next(model.model.parameters()).device
|
| 39 |
|
| 40 |
+
# if open think mode, use the following code
|
| 41 |
+
formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt = True, enable_thinking = True)
|
| 42 |
+
# if close think mode, use the following code
|
| 43 |
+
# formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt = True, enable_thinking = False)
|
| 44 |
|
| 45 |
input_ids = tokenizer.encode(formatted_prompt, return_tensors='pt').to(device)
|
| 46 |
outputs = model.generate(
|
|
|
|
| 48 |
max_new_tokens=1000,
|
| 49 |
do_sample=True
|
| 50 |
)
|
| 51 |
+
# if open think mode, use the following code
|
| 52 |
+
ans = [i.split("<|im_start|> assistant\n", 1)[1].strip() for i in tokenizer.batch_decode(outputs)]
|
| 53 |
+
# if close think mode, use the following code
|
| 54 |
+
# ans = [i.split("<|im_start|> assistant\n<think>\n\n</think>", 1)[1].strip() for i in tokenizer.batch_decode(outputs)]
|
| 55 |
```
|
| 56 |
|
| 57 |
<p align="center">
|