Text Generation
Transformers
Safetensors
English
llama
causal-lm
from-scratch
dpo
chat
conversational
text-generation-inference
Instructions to use dkumar15/aria-1b-chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dkumar15/aria-1b-chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="dkumar15/aria-1b-chat") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("dkumar15/aria-1b-chat") model = AutoModelForCausalLM.from_pretrained("dkumar15/aria-1b-chat") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use dkumar15/aria-1b-chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "dkumar15/aria-1b-chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dkumar15/aria-1b-chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/dkumar15/aria-1b-chat
- SGLang
How to use dkumar15/aria-1b-chat 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 "dkumar15/aria-1b-chat" \ --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": "dkumar15/aria-1b-chat", "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 "dkumar15/aria-1b-chat" \ --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": "dkumar15/aria-1b-chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use dkumar15/aria-1b-chat with Docker Model Runner:
docker model run hf.co/dkumar15/aria-1b-chat
Upload training_code/model/config.py with huggingface_hub
Browse files
training_code/model/config.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Configuration for 1B parameter LLaMA-style Transformer model.
|
| 3 |
+
Architecture: Decoder-only Transformer with RoPE, GQA, SwiGLU, RMSNorm.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from dataclasses import dataclass
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
@dataclass
|
| 10 |
+
class ModelConfig:
|
| 11 |
+
vocab_size: int = 32000
|
| 12 |
+
hidden_dim: int = 2048
|
| 13 |
+
intermediate_dim: int = 5504 # ~2.7x hidden for SwiGLU (adjusted for param count)
|
| 14 |
+
num_layers: int = 22
|
| 15 |
+
num_attention_heads: int = 32
|
| 16 |
+
num_kv_heads: int = 8 # GQA: 4 query heads per KV head
|
| 17 |
+
max_seq_len: int = 2048
|
| 18 |
+
rope_theta: float = 10000.0
|
| 19 |
+
rms_norm_eps: float = 1e-5
|
| 20 |
+
dropout: float = 0.0 # No dropout (modern practice for pretraining)
|
| 21 |
+
tie_word_embeddings: bool = False
|
| 22 |
+
|
| 23 |
+
@property
|
| 24 |
+
def head_dim(self) -> int:
|
| 25 |
+
return self.hidden_dim // self.num_attention_heads
|
| 26 |
+
|
| 27 |
+
@property
|
| 28 |
+
def num_params_approx(self) -> int:
|
| 29 |
+
"""Rough parameter count estimate."""
|
| 30 |
+
embed = self.vocab_size * self.hidden_dim
|
| 31 |
+
attn_per_layer = (
|
| 32 |
+
self.hidden_dim * self.head_dim * self.num_attention_heads + # Q
|
| 33 |
+
self.hidden_dim * self.head_dim * self.num_kv_heads + # K
|
| 34 |
+
self.hidden_dim * self.head_dim * self.num_kv_heads + # V
|
| 35 |
+
self.head_dim * self.num_attention_heads * self.hidden_dim # O
|
| 36 |
+
)
|
| 37 |
+
ffn_per_layer = 3 * self.hidden_dim * self.intermediate_dim # gate + up + down
|
| 38 |
+
norm_per_layer = 2 * self.hidden_dim
|
| 39 |
+
total = (
|
| 40 |
+
embed +
|
| 41 |
+
self.num_layers * (attn_per_layer + ffn_per_layer + norm_per_layer) +
|
| 42 |
+
self.hidden_dim + # final norm
|
| 43 |
+
(0 if self.tie_word_embeddings else self.vocab_size * self.hidden_dim)
|
| 44 |
+
)
|
| 45 |
+
return total
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
@dataclass
|
| 49 |
+
class TrainConfig:
|
| 50 |
+
# Paths
|
| 51 |
+
checkpoint_dir: str = "/jfs/deepak-kumar/checkpoints"
|
| 52 |
+
data_cache_dir: str = "/jfs/deepak-kumar/data"
|
| 53 |
+
log_dir: str = "/home/jovyan/training/logs"
|
| 54 |
+
|
| 55 |
+
# Training
|
| 56 |
+
total_tokens: int = 20_000_000_000 # 20B tokens
|
| 57 |
+
batch_size_per_gpu: int = 8
|
| 58 |
+
gradient_accumulation_steps: int = 8 # effective batch = 8 * 8 * 8 = 512 seqs
|
| 59 |
+
max_seq_len: int = 2048
|
| 60 |
+
|
| 61 |
+
# WSD Schedule
|
| 62 |
+
learning_rate: float = 3e-4
|
| 63 |
+
min_lr: float = 3e-5
|
| 64 |
+
warmup_steps: int = 1000
|
| 65 |
+
weight_decay: float = 0.1
|
| 66 |
+
beta1: float = 0.9
|
| 67 |
+
beta2: float = 0.95
|
| 68 |
+
grad_clip: float = 1.0
|
| 69 |
+
|
| 70 |
+
# Logging
|
| 71 |
+
log_interval: int = 10
|
| 72 |
+
save_interval: int = 1000
|
| 73 |
+
eval_interval: int = 500
|
| 74 |
+
|
| 75 |
+
# System
|
| 76 |
+
num_workers: int = 4
|
| 77 |
+
seed: int = 42
|
| 78 |
+
bf16: bool = True
|