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/finish_fw.sh from AjayRangoji/AR-4B-base: direct link, hf CLI and curl.
- Browser
- Download file 3.18 kB
-
https://huggingface.co/AjayRangoji/AR-4B-base/resolve/main/training_code/finish_fw.sh
- Command line
-
hf download hf://AjayRangoji/AR-4B-base/training_code/finish_fw.sh
-
curl -L -o finish_fw.sh https://huggingface.co/AjayRangoji/AR-4B-base/resolve/main/training_code/finish_fw.sh
3.18 kB
| # One-time: wait for the 4 English tokenizing jobs, check the grown files, then re-balance | |
| # the English weights by file size and RELOAD, so training uses the new data. | |
| # Run: nohup ./finish_fw.sh > logs/finish_fw.log 2>&1 & | |
| cd /fsx/ajay-stu/AR | |
| source .venv/bin/activate | |
| JOBS="39801,39802,39805,39806" | |
| # 1) wait (max 12 h) until all 4 jobs have left the queue | |
| for i in $(seq 144); do | |
| n=$(squeue -h -j $JOBS 2>/dev/null | wc -l) | |
| [ "$n" -eq 0 ] && break | |
| sleep 300 | |
| done | |
| [ "$n" -ne 0 ] && { echo "$(date -u) jobs still running after 12 h, nothing changed"; exit 1; } | |
| # 2) each job must have ended normally (not crashed, not stopped by the disk guard) | |
| for j in ${JOBS//,/ }; do | |
| grep -q "^\[done\]" logs/tok_ar-tok_$j.out || { echo "$(date -u) job $j did not finish normally, nothing changed"; exit 1; } | |
| done | |
| echo "$(date -u) all 4 jobs finished" | |
| # 3) check the files: full documents, ~20B tokens, new part is not a repeat of the start | |
| python - <<'PY' || { echo "$(date -u) file check FAILED, nothing changed"; exit 1; } | |
| import re, sys | |
| import numpy as np | |
| EOT = 151645 | |
| log = open("logs/resume_tok.log").read() | |
| ok = True | |
| for g in ("003", "004", "005", "006"): | |
| p = f"/fsx/ajay-stu/ar-data/bin/fw{g}/fineweb.bin" | |
| old = int(re.search(rf"fw{g}: have (\d+)", log).group(1)) # tokens before resuming | |
| a = np.memmap(p, dtype=np.uint32, mode="r") | |
| repeat = bool(np.array_equal(a[:2048], a[old:old + 2048])) # a failed skip restarts at doc 1 | |
| good = bool(a[-1] == EOT and a[old - 1] == EOT and not repeat and len(a) >= 19.9e9) | |
| print(f"fw{g}: {len(a)/1e9:.2f}B tokens, old part {old/1e9:.2f}B, repeats start: {repeat}, ok: {good}") | |
| ok = ok and good | |
| sys.exit(0 if ok else 1) | |
| PY | |
| # 4) re-balance the English weights by file size (English total stays the same) | |
| cp run_args.sh run_args.sh.bak_fw20 | |
| python - <<'PY' || { echo "$(date -u) weight update FAILED, restored"; cp run_args.sh.bak_fw20 run_args.sh; exit 1; } | |
| import os, re, pathlib | |
| p = pathlib.Path("run_args.sh") | |
| s = p.read_text() | |
| bins = re.search(r'^BIN="([^"]*)"', s, re.M).group(1).split() | |
| w = re.search(r'^WEIGHTS="([^"]*)"', s, re.M).group(1).split() | |
| assert len(bins) == len(w) == 16, f"expected 16/16, got {len(bins)}/{len(w)}" | |
| eng = [k for k, b in enumerate(bins) if b.endswith("/fineweb.bin")] | |
| assert len(eng) == 5, f"expected 5 English files, got {len(eng)}" | |
| share = sum(float(w[k]) for k in eng) | |
| size = {k: os.path.getsize(bins[k]) for k in eng} | |
| for k in eng: | |
| w[k] = f"{share * size[k] / sum(size.values()):.6f}" | |
| s = re.sub(r'^WEIGHTS="[^"]*"', lambda m: 'WEIGHTS="' + " ".join(w) + '"', s, count=1, flags=re.M) | |
| p.write_text(s) | |
| for k in eng: | |
| print(f"{float(w[k]):.4f} {bins[k].split('/ar-data/')[-1]}") | |
| print(f"English total: {sum(float(w[k]) for k in eng):.4f}") | |
| PY | |
| # 5) apply after the next checkpoint (same nodes); undo the edit if any check fails | |
| if bash -n run_args.sh && bash -c 'source run_args.sh; for f in $BIN; do [ -f "$f" ] || exit 1; done'; then | |
| touch logs/RELOAD && echo "$(date -u) RELOAD set: training switches after the next checkpoint" | |
| else | |
| cp run_args.sh.bak_fw20 run_args.sh; echo "$(date -u) run_args check failed, restored"; exit 1 | |
| fi | |