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: 2,222 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | """HumanEval (Python coding): complete each function, run its unit tests, pass@1 greedy."""
import argparse
import os
import subprocess
import sys
import tempfile
from datasets import load_dataset
from ar.data.tokenizer import Tokenizer
from ar.eval.batch_gen import generate_batch
from ar.eval.generate import load_model
# a new top-level statement means the function body is finished
STOP = ["\ndef ", "\nclass ", "\nif __name__", "\nprint(", "\n#"]
def passes(program, timeout=10):
# run the model-written code in a separate process with a time limit,
# so a crash or infinite loop can't take down the evaluation
with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as f:
f.write(program)
path = f.name
try:
return subprocess.run([sys.executable, path], capture_output=True,
timeout=timeout).returncode == 0
except subprocess.TimeoutExpired:
return False
finally:
os.remove(path)
if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("--model", required=True)
p.add_argument("--batch", type=int, default=16)
args = p.parse_args()
device = "cuda"
tok = Tokenizer()
model = load_model(args.model, device)
ds = load_dataset("openai/openai_humaneval", split="test")
solved = 0
for i in range(0, len(ds), args.batch):
chunk = ds.select(range(i, min(i + args.batch, len(ds))))
outs = generate_batch(model, tok, [ex["prompt"] for ex in chunk], seq_len=1536,
max_new=384, stop=STOP, device=device)
for ex, completion in zip(chunk, outs):
program = (ex["prompt"] + completion + "\n\n" + ex["test"]
+ f"\n\ncheck({ex['entry_point']})\n")
solved += passes(program)
done = min(i + args.batch, len(ds))
print(f"[{done}/{len(ds)}] pass@1 so far: {100 * solved / done:.1f}%", flush=True)
if i == 0:
print("--- example completion ---\n" + chunk[0]["prompt"] + outs[0]
+ "\n--------------------------", flush=True)
print(f"HumanEval pass@1 (greedy): {100 * solved / len(ds):.1f}% ({solved}/{len(ds)})") |