Instructions to use R-Kentaren/grok-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use R-Kentaren/grok-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="R-Kentaren/grok-2")# Load model directly from transformers import AutoProcessor, AutoModelForCausalLM processor = AutoProcessor.from_pretrained("R-Kentaren/grok-2") model = AutoModelForCausalLM.from_pretrained("R-Kentaren/grok-2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use R-Kentaren/grok-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "R-Kentaren/grok-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "R-Kentaren/grok-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/R-Kentaren/grok-2
- SGLang
How to use R-Kentaren/grok-2 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 "R-Kentaren/grok-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "R-Kentaren/grok-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "R-Kentaren/grok-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "R-Kentaren/grok-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use R-Kentaren/grok-2 with Docker Model Runner:
docker model run hf.co/R-Kentaren/grok-2
| { | |
| "architectures": [ | |
| "Grok1ForCausalLM" | |
| ], | |
| "embedding_multiplier_scale": 90.50966799187809, | |
| "output_multiplier_scale": 0.5, | |
| "vocab_size": 131072, | |
| "hidden_size": 8192, | |
| "intermediate_size": 32768, | |
| "moe_intermediate_size": 16384, | |
| "max_position_embeddings": 131072, | |
| "num_experts_per_tok": 2, | |
| "num_local_experts": 8, | |
| "residual_moe": true, | |
| "num_attention_heads": 64, | |
| "num_key_value_heads": 8, | |
| "num_hidden_layers": 64, | |
| "head_dim": 128, | |
| "rms_norm_eps": 1e-05, | |
| "final_logit_softcapping": 50, | |
| "attn_logit_softcapping": 30.0, | |
| "router_logit_softcapping": 30.0, | |
| "rope_theta": 208533496, | |
| "attn_temperature_len": 1024, | |
| "sliding_window_size": -1, | |
| "global_attn_every_n": 1, | |
| "model_type": "git", | |
| "torch_dtype": "bfloat16", | |
| "rope_type": "original", | |
| "original_max_position_embeddings": 8192, | |
| "scaling_factor": 16.0, | |
| "extrapolation_factor": 1.0, | |
| "attn_factor": 1.0, | |
| "beta_fast": 8, | |
| "beta_slow": 1 | |
| } |