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
| { | |
| "architectures": [ | |
| "MiniCPMForCausalLM" | |
| ], | |
| "attention_bias": false, | |
| "attention_dropout": 0.0, | |
| "auto_map": { | |
| "AutoConfig": "openbmb/MiniCPM4-8B--configuration_minicpm.MiniCPMConfig", | |
| "AutoModel": "openbmb/MiniCPM4-8B--modeling_minicpm.MiniCPMModel", | |
| "AutoModelForCausalLM": "openbmb/MiniCPM4-8B--modeling_minicpm.MiniCPMForCausalLM", | |
| "AutoModelForSeq2SeqLM": "openbmb/MiniCPM4-8B--modeling_minicpm.MiniCPMForCausalLM", | |
| "AutoModelForSequenceClassification": "openbmb/MiniCPM4-8B--modeling_minicpm.MiniCPMForSequenceClassification" | |
| }, | |
| "bos_token_id": 1, | |
| "dim_model_base": 32, | |
| "eos_token_id": [ | |
| 2, | |
| 73440 | |
| ], | |
| "hidden_act": "silu", | |
| "hidden_size": 64, | |
| "initializer_range": 0.1, | |
| "intermediate_size": 128, | |
| "max_position_embeddings": 32768, | |
| "model_type": "minicpm", | |
| "mup_denominator": 32, | |
| "num_attention_heads": 2, | |
| "num_hidden_layers": 2, | |
| "num_key_value_heads": 1, | |
| "pad_token_id": 2, | |
| "pretraining_tp": 1, | |
| "rms_norm_eps": 1e-06, | |
| "rope_scaling": { | |
| "long_factor": [ | |
| 0.9977997200264581, | |
| 1.014658295992452, | |
| 1.0349680404997148, | |
| 1.059429246056193, | |
| 1.0888815016813513, | |
| 1.1243301355211495, | |
| 1.166977103606075, | |
| 1.2182568066927284, | |
| 1.2798772354275727, | |
| 1.3538666751582975, | |
| 1.4426259039919596, | |
| 1.5489853358570191, | |
| 1.6762658237220625, | |
| 1.8283407612492941, | |
| 2.0096956085876183, | |
| 2.225478927469756 | |
| ], | |
| "original_max_position_embeddings": 32768, | |
| "rope_type": "longrope", | |
| "short_factor": [ | |
| 0.9977997200264581, | |
| 1.014658295992452, | |
| 1.0349680404997148, | |
| 1.059429246056193, | |
| 1.0888815016813513, | |
| 1.1243301355211495, | |
| 1.166977103606075, | |
| 1.2182568066927284, | |
| 1.2798772354275727, | |
| 1.3538666751582975, | |
| 1.4426259039919596, | |
| 1.5489853358570191, | |
| 1.6762658237220625, | |
| 1.8283407612492941, | |
| 2.0096956085876183, | |
| 2.225478927469756 | |
| ] | |
| }, | |
| "rope_theta": 10000.0, | |
| "scale_depth": 1.4, | |
| "scale_emb": 12, | |
| "sparse_config": null, | |
| "torch_dtype": "bfloat16", | |
| "transformers_version": "4.51.3", | |
| "use_cache": true, | |
| "vocab_size": 73448 | |
| } |