Instructions to use Randgris/Agila-v1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Randgris/Agila-v1.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Randgris/Agila-v1.0")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Randgris/Agila-v1.0", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Randgris/Agila-v1.0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Randgris/Agila-v1.0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Randgris/Agila-v1.0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Randgris/Agila-v1.0
- SGLang
How to use Randgris/Agila-v1.0 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 "Randgris/Agila-v1.0" \ --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": "Randgris/Agila-v1.0", "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 "Randgris/Agila-v1.0" \ --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": "Randgris/Agila-v1.0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Randgris/Agila-v1.0 with Docker Model Runner:
docker model run hf.co/Randgris/Agila-v1.0
agila-v1.0
Isang decoder-only transformer na sinanay mula sa simula (walang pretrained weights, walang fine-tune ng ibang model) sa Tagalog at English na Wikipedia at sa isang conversational corpus, tapos naging int8 weights na dina-download ng browser papunta sa Cache Storage at pinapatakbo sa WebGPU.
corpus (6.0M TL + 2.7M EN chars)
β BPE tokenizer (6,000 vocab, trained from scratch)
β 2.9M-param transformer, pretrained 2,800 steps on 2 vCPU
β instruction tuning (500 steps) + conversational tuning (1,600 steps)
β int8 quantization β 2.98 MB weights.bin
β WebGPU inference (sariling WGSL kernels) + CPU fallback
β token duplicator (bawat token β kopya sa VRAM, orihinal buo)
Walang @mlc-ai/web-llm, walang hosted API. Ang src/lib/agila/gpu.ts ang sariling inference
engine at training/ ang sariling training pipeline.
Ang model
| Params | 2,923,200 |
| Architecture | decoder-only, pre-RMSNorm, half-split RoPE, GELU MLP, tied embeddings, no biases |
| d_model / layers / heads | 192 / 4 / 6 (head_dim 32) |
| Context | 128 tokens |
| Vocab | 6,000 (byte-level BPE) |
| Weights on disk | 2.98 MB β int8 per-row symmetric + f32 scales, 34 tensors |
| GPU memory | ~12 MB f32 (dequantized at load) |
| PWA precache | 384 KiB |
Training results (totoo, hindi marketing)
| Stage | Steps | Data | Val loss | Perplexity |
|---|---|---|---|---|
| Base LM | 2,800 | 5,734,400 tokens | 4.369 | 79.0 |
| Instruction tuning | 500 | Wikipedia QA, masked loss | 1.305 | 3.7 |
| Conversational tuning | 1,600 | 4,200 dialogues (Γ3) + 385 facts | 0.036 | 1.0 |
19.8 min base + ~4 min + ~13 min tuning sa 2 vCPU / 3.8 GB RAM / walang GPU.
Ang mababang val loss sa huling stage ay memorization, hindi generalization: maliit ang dialogue corpus at paulit-ulit ang templates. Iyon ang dahilan kung bakit maayos ang sagot sa mga karaniwang tanong at mahina pa sa mga bago.
70% Tagalog / 30% English β nasa data, hindi lang sa prompt
- 6.01M characters Tagalog (1,983 articles)
- 2.70M characters English (461 articles)
- = 68.9% Tagalog sa training corpus (13,293 documents β 2,325,916 tokens)
- Dagdag pa: 4,200 synthetic na dialogue, 30% English ang tanong/sagot
Kalidad ng usapan
Tunay na output mula sa kasalukuyang weights (scripts/eval_chat.py):
Q: Sino ka?
A: Ako si agila-v1.0, isang maliit na AI na tumatakbo sa loob ng browser mo. Sinanay ako
mula sa simula sa Tagalog at English na Wikipedia.
Q: Ano ang WebGPU?
A: Ang WebGPU ay isang browser API na nagbibigay-daan sa GPU na mag-compute. Dahil dito,
kaya kong tumakbo nang lokal at mabilis.
Q: Gumagana ka ba offline?
A: Oo, basta naka-download na ang weights at may naka-cache na search results. I-online mo
lang minsan para maka-update.
Q: What can you do?
A: I can chat in Tagalog and English, look things up on Wikipedia and DuckDuckGo, and keep
working offline from cached data.
Automated check: 12/12 clean β 0 empty, 0 repetition loops, 0 too-short answers.
Limitasyon na dapat malaman: kusang usapan lang ito sa loob ng nasanay na paksa. Kapag tatanungin mo ng bagong bagay na wala sa corpus, malamang mag-hallucinate pa rin ito. Kaya nandiyan ang Wikipedia/DuckDuckGo sources at ang Lite mode para sa mga faktwal na tanong.
Image generator β agila-image (sariling diffusion model)
Hindi lang teksto: may sariling conditional diffusion model na gumagawa ng 32Γ32 na larawan, sinanay din mula sa simula sa parehong makina β walang Stable Diffusion, walang hosted API.
| Params | 1,134,976 (49 tensors) |
| Architecture | DiT-style: 8Γ8 patches β 16 tokens, 4 blocks, d 128, 4 heads |
| Conditioning | time + concept embedding β FiLM (adaLN) scale/shift per block |
| Diffusion | 100 timesteps, linear beta, x0 parameterization, DDIM (eta=0) |
| Training | 11,000 steps Β· batch 32 Β· EMA 0.998 Β· 8 concepts |
| Weights | 1.18 MB int8 per-row, 49 tensors |
| Resolution | 32Γ32 native, pixelated upscale sa UI |
Ano ang nangyari sa unang subok (tapat na bahagi)
Ang unang bersyon β eps-prediction, 1,000 timesteps, 3,000 steps β ay puro ingay ang inilalabas. Sinukat ko ito: patch-mean std / pixel std = 0.21, katumbas ng walang hugis. Tatlong pagbabago ang gumawa ng pagkakaiba:
- x0 parameterization β ang target ay malinis na larawan, kaya direktang ginagantimpalaan ang istruktura (loss 0.39 β 0.009)
- FiLM conditioning β dati'y ipinapasok lang ang concept sa pamamagitan ng pag-add; ngayon may scale/shift per block, kaya malinaw ang pagkakaiba ng konsepto
- 100 timesteps sa halip na 1,000 β mas kaunting noise level na kailangang matutunan
Resulta: structure ratio 0.44β0.94 kada konsepto, at nakikita na ang sunset, bundok, dagat, gubat, lungsod, disyerto, bukang liwayway, at bagyo.
Quality tiers, nakadepende sa hardware: High 24 steps (desktop GPU), Standard 16 steps (mobile GPU), Draft 8 steps (CPU fallback).
Parity: CPU denoiser vs PyTorch max |Ξ| 0.0587 (2.28% relative); sinusuri rin ng browser ang sariling WGSL kernels laban sa CPU bago ito gamitin, at automatic na CPU kapag hindi tugma.
Paano tumatakbo sa browser
- Download β
weights.bin(2.98 MB) ay hinihila nang may progress, tapos iniimbak sa Cache Storage (agila-weights-v1). Naka-cache din ang manifest, tokenizer, at parity data, kaya buong offline ang load pagkatapos. - Inference β int8 β f32 dequantize sa JS, upload sa GPU buffers, tapos token-by-token na
forward pass gamit ang sariling WGSL kernels:
matvec,rmsnorm,rope,softmax,weighted,gelu,add. KV cache sa GPU, logits readback para sa sampling. - Self-test β bago gamitin ang GPU, pinapatakbo ang fixed prompt at ikinukumpara ang logits
sa
parity.json(galing sa PyTorch). Kapag lumagpas sa tolerance, CPU reference ang gagamitin at ipapakita sa panel kung bakit. - Search β Wikipedia (TL + EN,
origin=*) at DuckDuckGo Instant Answer API (access-control-allow-origin: *) direktang tinatawag mula sa browser; resulta ay naka-cache sa IndexedDB para may offline na sagot.
Token duplicator
Bawat token na ginagawa ng model ay kinokopya papunta sa hiwalay na buffer bago gamitin:
sampler β original token (hindi ginagalaw)
β kopya β GPU token buffer (VRAM)
β kopya ang ipinapasa sa susunod na forward pass
- Ang
generatedarray sa JS ay nananatiling buo β hindi ito minu-mutate. - Sa WebGPU, may sariling
copytokencompute kernel: isinusulat muna ang token sa maliit na input buffer, tapos kinokopya ng GPU papunta sa VRAM token buffer (isang slot bawat position). - May readback verification: binabasa pabalik ang VRAM buffer at ikinukumpara sa kopya; ang
resulta ay makikita sa bawat sagot (
N tokens β VRAM β) at sa panel. - Sa CPU fallback, JS array ang buffer at may parehong verification.
Verified (Node, walang GPU)
npm run verify:model # tokenizer + weights vs PyTorch artifacts
npm run eval:chat # 12-prompt coherence check
- TS BPE tokenizer vs Python: 6/6 encode checks + decode round-trips pass
weights.binsize vs manifest: pass- TS reference forward vs PyTorch logits: max |Ξ| = 0.1283 (1.57% relative)
- Top-5 next-token ids: exact match
- Chat eval: 12/12 clean
Hindi pa nabe-verify sa totoong GPU: ang WGSL kernels at ang duplicator readback (may runtime self-test para dito), at ang actual na rendering ng UI.
Estruktura
training/ # Python: architecture, training, export
agila/config.py # presets (nano 2.9M, small 29M)
agila/model.py # transformer + generation
agila/tokenizer_train.py # BPE training + corpus β token ids
agila/train.py # pretraining loop
agila/dialogues.py # synthetic Tagalog/English conversation corpus
agila/sft.py # instruction + conversational tuning (masked loss)
agila/export.py # int8 quantize + manifest + parity.json
agila/sample.py # generation sanity check
scripts/
fetch_corpus_hf.py # Wikipedia mirror β corpus
eval_chat.py # 12-prompt coherence + loop check
verify.ts # parity harness (tokenizer + weights)
make-icons.mjs # procedural PWA icons
src/lib/agila/
tokenizer.ts # byte-level BPE encoder/decoder (TS)
manifest.ts, weights.ts # manifest parse, cache, dequantize
reference.ts # CPU f32 forward (fallback + baseline)
gpu.ts # WGSL kernels, KV cache, duplicator buffer
token-duplicator.ts # copy token β VRAM, readback verification
runtime.ts # load β self-test β generate, streaming
prompt.ts # <|tanong|> β¦ <|sagot|> format
src/components/ # Thread, Sidebar, Composer, Rich
src/lib/search.ts # Wikipedia + DuckDuckGo + offline cache
Commands
npm install
npm run dev # app (port 3000)
npm run build # typecheck + PWA build
npm run verify:model # tokenizer + weights parity checks
npm run eval:chat # conversation coherence check
npm run sample:model # generation mula sa checkpoint
# training (Python 3.12 + .venv)
python3 -m venv .venv
.venv/bin/pip install torch --index-url https://download.pytorch.org/whl/cpu
.venv/bin/pip install tokenizers numpy
npm run corpus
npm run tokenizer
npm run train
npm run dialogues
npm run train:sft
npm run export:model
Detalye ng pipeline: training/README.md.
Limits (tapat na listahan)
- Memorized ang usapan. Val loss 0.036 sa 4,200 dialogues = pag-memorize ng templates, hindi tunay na pag-unawa. Maayos sa pamilyar na tanong, mahina sa bago.
- Maliit ang kaalaman. 8.7M characters mula sa Wikipedia; hindi kasya ang mundo sa 2.9M params. Para sa facts, gamitin ang sources at Lite mode.
- Walang safety tuning. Walang RLHF/guardrails β base LM na may light SFT.
- CPU training.
smallpreset (~29M params) ay hindi sinanay dito; kailangan ng GPU. - Attribution. Wikipedia text (CC BY-SA) ang pinagmulan ng corpus.
Susunod na hakbang (kung may GPU)
smallpreset (d_model 384, 6 layers, ctx 256, ~29M params).- 500M+ tokens mula sa CulturaX TL + EN para mabawasan ang memorization.
- Mas malawak na dialogue corpus (tunay na usapan, hindi templates).
- DPO para sumunod sa instructions at mag-cite ng sources.
- Pareho lang ang export at browser runtime β walang babaguhin sa WebGPU code.
