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
Download training_code/ar/model/block.py from AjayRangoji/AR-4B-base: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/AjayRangoji/AR-4B-base/resolve/main/training_code/ar/model/block.py
- Command line
-
hf download hf://AjayRangoji/AR-4B-base/training_code/ar/model/block.py
-
curl -L -o block.py https://huggingface.co/AjayRangoji/AR-4B-base/resolve/main/training_code/ar/model/block.py
1 kB
| import torch | |
| import torch.nn as nn | |
| from .rmsnorm import RMSNorm | |
| from .attention import GroupedQueryAttention | |
| from .mlp import SwiGLU | |
| class DecoderBlock(nn.Module): | |
| """One transformer block: attention sub-layer, then MLP sub-layer. | |
| Each sub-layer is pre-normed and wrapped in a residual (add-back) connection. | |
| """ | |
| def __init__(self, dim, n_heads, n_kv_heads, head_dim, hidden_dim, eps=1e-6): | |
| super().__init__() | |
| # a norm before each sub-layer | |
| self.attn_norm = RMSNorm(dim, eps) | |
| self.mlp_norm = RMSNorm(dim, eps) | |
| self.attn = GroupedQueryAttention(dim, n_heads, n_kv_heads, head_dim) | |
| self.mlp = SwiGLU(dim, hidden_dim) | |
| def forward(self, x, cos, sin, block_mask): | |
| # attention sub-layer: normalize, attend, add the result back | |
| x = x + self.attn(self.attn_norm(x), cos, sin, block_mask) | |
| # mlp sub-layer: normalize, process per-token, add the result back | |
| x = x + self.mlp(self.mlp_norm(x)) | |
| return x |