Instructions to use tiny-random/minicpm4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/minicpm4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/minicpm4", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("tiny-random/minicpm4", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use tiny-random/minicpm4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/minicpm4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/minicpm4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/minicpm4
- SGLang
How to use tiny-random/minicpm4 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 "tiny-random/minicpm4" \ --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": "tiny-random/minicpm4", "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 "tiny-random/minicpm4" \ --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": "tiny-random/minicpm4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/minicpm4 with Docker Model Runner:
docker model run hf.co/tiny-random/minicpm4
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -38,7 +38,6 @@ prompt_text = tokenizer.apply_chat_template(
|
|
| 38 |
add_generation_prompt=True,
|
| 39 |
)
|
| 40 |
model_inputs = tokenizer([prompt_text], return_tensors="pt").to(device)
|
| 41 |
-
|
| 42 |
model_outputs = model.generate(
|
| 43 |
**model_inputs,
|
| 44 |
max_new_tokens=32,
|
|
@@ -48,7 +47,6 @@ model_outputs = model.generate(
|
|
| 48 |
output_token_ids = [
|
| 49 |
model_outputs[i][len(model_inputs[i]):] for i in range(len(model_inputs['input_ids']))
|
| 50 |
]
|
| 51 |
-
|
| 52 |
responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
|
| 53 |
print(responses)
|
| 54 |
```
|
|
|
|
| 38 |
add_generation_prompt=True,
|
| 39 |
)
|
| 40 |
model_inputs = tokenizer([prompt_text], return_tensors="pt").to(device)
|
|
|
|
| 41 |
model_outputs = model.generate(
|
| 42 |
**model_inputs,
|
| 43 |
max_new_tokens=32,
|
|
|
|
| 47 |
output_token_ids = [
|
| 48 |
model_outputs[i][len(model_inputs[i]):] for i in range(len(model_inputs['input_ids']))
|
| 49 |
]
|
|
|
|
| 50 |
responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
|
| 51 |
print(responses)
|
| 52 |
```
|