Instructions to use AjayRangoji/AR-4B-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AjayRangoji/AR-4B-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AjayRangoji/AR-4B-base", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("AjayRangoji/AR-4B-base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AjayRangoji/AR-4B-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AjayRangoji/AR-4B-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AjayRangoji/AR-4B-base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AjayRangoji/AR-4B-base
- SGLang
How to use AjayRangoji/AR-4B-base 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 "AjayRangoji/AR-4B-base" \ --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": "AjayRangoji/AR-4B-base", "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 "AjayRangoji/AR-4B-base" \ --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": "AjayRangoji/AR-4B-base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AjayRangoji/AR-4B-base with Docker Model Runner:
docker model run hf.co/AjayRangoji/AR-4B-base
File size: 1,613 Bytes
df64241 | 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 37 38 39 40 41 | from dataclasses import dataclass
@dataclass
class ARConfig:
"""All the numbers that define the AR model's shape.
Swap these to build a different-sized model with the same code
(e.g. a tiny version for debugging).
"""
vocab_size: int = 151936 # size of the tokenizer vocabulary
dim: int = 2560 # hidden size (width of the residual stream)
n_layers: int = 36 # number of decoder blocks stacked
n_heads: int = 32 # query heads
n_kv_heads: int = 8 # key/value heads (GQA: 32 queries share 8 kv)
head_dim: int = 128 # size of each attention head
hidden_dim: int = 9728 # inner width of the SwiGLU MLP
max_seq_len: int = 40960 # longest sequence the model supports
rope_theta: float = 1_000_000.0 # RoPE base frequency
rms_norm_eps: float = 1e-6 # RMSNorm epsilon
tie_embeddings: bool = True # share input embedding and output head weights
# a very small variant for fast offline code testing (tiny numbers)
def tiny_config() -> ARConfig:
return ARConfig(
vocab_size=1000, dim=128, n_layers=2,
n_heads=4, n_kv_heads=2, head_dim=32,
hidden_dim=512, max_seq_len=256,
)
# a ~0.5B variant for validating the training loop on a single GPU
# (same architecture shape as the full model, just narrower and shallower)
def small_config() -> ARConfig:
return ARConfig(
vocab_size=151936, dim=1024, n_layers=24,
n_heads=16, n_kv_heads=4, head_dim=128, # keeps the 4:1 GQA ratio
hidden_dim=2816, max_seq_len=40960,
) |