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
File size: 947 Bytes
7d6eee4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | {
"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
} |