This is the model card of a transformers model that has been pushed on the Hub. Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Use the code below to get started with the model. Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
Sanskrit-322M-Base is an open-weight model for text generation from Sr Aivante, released under Apache License 2.0. It has 322M parameters and a 2,048-token context. At 16-bit it needs about 0.8 GB of GPU memory, which fits on 1x MI300X from $1.85 an hour, at the lowest prices in the SAVRN Index.
Sanskrit-322M-Base is a 322-million-parameter Sanskrit language model trained from scratch with its own 32,000-token SentencePiece Unigram tokenizer. It is intended for Sanskrit text completion, generation experiments, and further task-specific fine-tuning.
Runs On
What it takes to serve Sanskrit-322M-Base (322M parameters): the memory its weights need at each precision, and the cheapest way to rent enough data-center GPUs to hold them.
| Precision | Weights | Memory needed | Cheapest setup | Per hour | Also fits |
|---|---|---|---|---|---|
| 16-bit | 0.6 GB | 0.8 GB | 1x MI300X (192 GB) Vultr |
$1.85 | 1x H100 $1.99 · 1x MI325X $2.00 |
| 8-bit | 0.3 GB | 0.4 GB | 1x MI300X (192 GB) Vultr |
$1.85 | 1x H100 $1.99 · 1x MI325X $2.00 |
| 4-bit | 0.2 GB | 0.2 GB | 1x MI300X (192 GB) Vultr |
$1.85 | 1x H100 $1.99 · 1x MI325X $2.00 |
Memory is the weights at that precision plus 20% for the runtime and a short context; a long context needs more. Prices are the lowest on-demand hourly rates in the SAVRN Index, read Oct 7, 2026.
Sanskrit-322M-Base on every accelerator the SAVRN Index prices, at every precision
Model Card
By Sr Aivante, published under apache-2.0, revision b4f732ebf4b1.
Sanskrit-322M-Base is a 322-million-parameter Sanskrit language model trained from scratch with its own 32,000-token SentencePiece Unigram tokenizer. It is intended for Sanskrit text completion, generation experiments, and further task-specific fine-tuning. This is a base pretrained model: it predicts the continuation of text. It has not been instruction-tuned or trained as a conversational assistant. It uses a Llama-compatible decoder architecture; its weights were initialized and trained independently, rather than adapted from a pretrained Llama checkpoint. Published by sraivante under the Apache License 2.0. The tokenizer uses identity normalization, byte fallback, and SentencePiece…
Read Sr Aivante's full model card
Sanskrit-322M-Base is a 322-million-parameter Sanskrit language model trained from scratch with its own 32,000-token SentencePiece Unigram tokenizer. It is intended for Sanskrit text completion, generation experiments, and further task-specific fine-tuning.
This is a base pretrained model: it predicts the continuation of text. It has not been instruction-tuned or trained as a conversational assistant. It uses a Llama-compatible decoder architecture; its weights were initialized and trained independently, rather than adapted from a pretrained Llama checkpoint.
Published by sraivante under the Apache License 2.0.
Model details
| Property | Value |
|---|---|
| Unique parameters | 322,225,152 |
| Architecture | Decoder-only Transformer, standard LlamaForCausalLM |
| Transformer layers | 24 |
| Hidden size | 1,024 |
| Feed-forward size | 2,560, SwiGLU |
| Attention heads / KV heads | 16 / 16 |
| Context length | 2,048 tokens |
| Position encoding | RoPE, theta 10,000 |
| Normalization | RMSNorm, epsilon 1e-5 |
| Embeddings | Input and output embeddings tied |
| Vocabulary | 32,000 |
| Weight format | FP32 Safetensors |
| Language focus | Sanskrit in Devanagari |
The tokenizer uses identity normalization, byte fallback, and SentencePiece whitespace handling. It does not automatically insert BOS or EOS tokens. Special-token IDs are <unk>=0, <s>=1, </s>=2, and <pad>=3. The original tokenizer.model is included alongside a standard fast tokenizer.json.
Quick start
pip install "transformers>=4.56.2" torch safetensors sentencepiece
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "sraivante/Sanskrit-322M-Base"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype=torch.float32,
).to(device).eval()
prompt = "धर्मक्षेत्रे कुरुक्षेत्रे"
# Training documents were separated by EOS; use it as a document boundary.
inputs = tokenizer(
tokenizer.eos_token + prompt,
return_tensors="pt",
).to(device)
torch.manual_seed(42)
with torch.inference_mode():
output = model.generate(
**inputs,
max_new_tokens=80,
do_sample=True,
temperature=0.8,
top_k=50,
repetition_penalty=1.1,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(output[0], skip_special_tokens=True))
Custom Python model code and trust_remote_code=True are not needed. Keep the prompt plus generated continuation within the 2,048-token context. There is no chat template.
Training data
The packed training mixture contains 1,104,941,200 tokens, including source upsampling. The held-out file contains 5,539,199 tokens. Approximately 0.5% of documents from each source were assigned to validation using a deterministic hash of the document ID.
| Source | Training tokens before upsampling | Repetition factor |
|---|---|---|
| Sangraha, verified Sanskrit | 880,541,818 | 1 |
| IndicCorpV2, Sanskrit | 124,397,130 | 1 |
| HPLT 2.0, Sanskrit | 28,656,730 | 1 |
| FineWeb-2, Sanskrit | 19,234,846 | 1 |
| GRETIL Sanskrit verses | 11,127,774 | 3 |
| Sanskrit Wikipedia | 5,828,264 | 2 |
| Itihasa | 2,356,942 | 3 |
Preparation included script and language filtering, normalization, deduplication, rule-based cleanup, and targeted OCR correction of the Itihasa portion. The filters aimed to emphasize Sanskrit and reduce other-language material; they do not establish perfect language purity or scholarly accuracy.
The tokenizer was trained independently on a Sanskrit sample using Unigram segmentation and byte fallback. Documents were tokenized and followed by EOS before packing. Batches were sampled as 2,048-token windows.
Dataset names above link to their source repositories. This release includes model artifacts and aggregate data metadata, not copies of the training corpus. Source datasets and underlying works retain their own licenses and terms.
Training procedure
- Hardware: one NVIDIA A100-SXM4-40GB in Google Colab, with checkpoint resumes.
- Precision: BF16 autocast during training; stored parameters in FP32.
- Optimizer: fused AdamW, betas (0.9, 0.95), epsilon 1e-8, weight decay 0.1.
- Learning rate: 3e-4 peak, 700 warmup steps, cosine decay to 3e-5.
- Microbatch: 8 sequences; gradient accumulation: 32 passes.
- Effective update: 256 sequences / 524,288 tokens.
- Gradient clipping: maximum norm 1.0.
- Acceleration: PyTorch scaled dot-product attention and
torch.compile. - Planned training: four token-budget passes, 8,430 optimizer steps.
- Final run: reached step 8,430 and reported completion.
- Published weights: best validation checkpoint from step 8,200.
The best checkpoint had processed approximately 4.299 billion scheduled training tokens. The completed run's nominal budget was approximately 4.420 billion tokens, excluding repeated work after interruptions. Because training samples random windows, these are token-budget passes rather than exhaustive dataset epochs.
Evaluation
| Checkpoint | Validation cross-entropy | Perplexity |
|---|---|---|
| 8,200 — published best checkpoint | 3.782284 | 43.916 |
| 8,400 | 3.7843 | 44.0 |
| 8,430 — final checkpoint | 3.7866 | 44.1 |
The exact best loss is stored inside the supplied best.pt. The other rows come from the completed notebook log.
Validation uses 40 deterministic batches of 8 sequences of 2,048 tokens sampled from the held-out token file, or 655,360 evaluated tokens. It is not a full pass over the validation file. Perplexity is the exponential of the mean cross-entropy and depends on this tokenizer and evaluation procedure; it is not directly comparable to models using other tokenizers or test sets.
No external Sanskrit understanding, translation, instruction-following, or grammaticality benchmarks are reported.
Intended use and limitations
Suitable uses include Sanskrit continuation experiments, studying small language models, and initializing further Sanskrit fine-tuning.
Generated text can repeat phrases, mix genres or languages, contain malformed words, or invent quotations and facts. It should be checked by a knowledgeable reader before use as an educational or scholarly source. The model has not been validated as a translator, grammar checker, factual question-answering system, or general assistant.
The corpus combines classical, encyclopedic, and web sources, so source artifacts, biases, and memorized passages may remain. The model has no instruction-tuning or safety-alignment stage. The 2,048-token context limit is part of the training configuration; longer contexts have not been evaluated.
Export and reproducibility
The original custom PyTorch model was exported into the standard Transformers Llama implementation by splitting packed Q/K/V projections, converting Q/K row order for the RoPE convention, and preserving tied embeddings. The FP32 tensors are retained without quantization.
conversion_report.json records source-file hashes, software versions, tokenizer comparisons, model-logit comparisons, and cached greedy-generation checks. The tokenizer export is checked against the original SentencePiece model rather than relying on a generic Llama tokenizer conversion.
training_data_metadata.json records aggregate source token counts and upsampling factors. training.py contains the original training implementation. convert_to_hf.py contains the conversion and verification procedure.
License
The model weights, tokenizer, and project code in this repository are released under Apache-2.0. See LICENSE. This model's license does not relicense the upstream datasets or underlying texts.
Configuration
- Architecture
- LlamaForCausalLM
- Context length (tokens)
- 2,048
- Layers
- 24
- Hidden size
- 1,024
- Feed-forward size
- 2,560
- Attention heads
- 16
- Key/value heads
- 16
- Head dimension
- 64
- Vocabulary size
- 32,000
- RoPE base
- 10000
- Model type
- llama
Identity and Version
- Repository
- sraivante/Sanskrit-322M-Base
- Publisher
- Sr Aivante
- Task
- Text generation
- Modality
- Text
- Library
- transformers
- Parameters
- 322M parameters
- Languages
- sa
- Revision
- b4f732ebf4b1d000b1db231b5c8746121a670d06
- First published
- 2026-09-25
- Last updated
- 2026-09-25
Files and Weights
15 files, 1.3 GB in total. The weights are 1 file totalling 1.3 GB in safetensors.
Every file
| File | Type | Size | SHA-256 |
|---|---|---|---|
| model.safetensors | Weights | 1.3 GB | e269d082ce8c |
| config.json | Configuration | 719 B | — |
| conversion_report.json | Configuration | 2.0 KB | — |
| convert_to_hf.py | Configuration | 12.6 KB | — |
| generation_config.json | Configuration | 179 B | — |
| special_tokens_map.json | Configuration | 102 B | — |
| training.py | Configuration | 12.5 KB | — |
| training_data_metadata.json | Configuration | 915 B | — |
| LICENSE | Documentation | 11.4 KB | — |
| README.md | Documentation | 8.6 KB | — |
| requirements.txt | Other | 84 B | — |
| .gitattributes | Repository | 1.5 KB | — |
| tokenizer.json | Tokenizer | 2.4 MB | — |
| tokenizer.model | Tokenizer | 862.1 KB | c5661b9def66 |
| tokenizer_config.json | Tokenizer | 1.1 KB | — |
License and Download
- License
- apache-2.0
- Access
- Open weights, no gate
- Download size
- 1.3 GB
Released by Sr Aivante through its official repository on Hugging Face. Read the license.
Built From
- Trained on (disclosed) HPLT/HPLT2.0_cleaned
- Trained on (disclosed) HuggingFaceFW/fineweb-2
- Trained on (disclosed) ai4bharat/IndicCorpV2
- Trained on (disclosed) ai4bharat/sangraha
- Trained on (disclosed) paws/sanskrit-verses-gretil
- Trained on (disclosed) rahular/itihasa
- Trained on (disclosed) wikimedia/wikipedia
Memory Requirements
| Precision | Weights in memory |
|---|---|
| As published | 1.3 GB |
| 16-bit | 0.6 GB |
| 8-bit | 0.3 GB |
| 4-bit | 0.2 GB |
Weights only, from the published parameter count; the key-value cache and runtime add to this.
Questions About Sanskrit-322M-Base
How much GPU memory does Sanskrit-322M-Base need?
About 0.8 GB at 16-bit and 0.2 GB at 4-bit: the weights (322M parameters) plus a working margin. A long context needs more.
What is the cheapest GPU to run Sanskrit-322M-Base on?
At 16-bit, 1x MI300X from $1.85 an hour; at 4-bit, 1x MI300X from $1.85 an hour, at the lowest on-demand prices the SAVRN Index lists.
Can I use Sanskrit-322M-Base commercially?
Yes. Sanskrit-322M-Base is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.
What is Sanskrit-322M-Base's context length?
2,048 tokens, from the maximum position embeddings in its published configuration.
Similar Models
Suggest a title and description for any text. On-device titles and descriptions: a short factual title and a one- to two-sentence description for any passage of text. Swift (requirements) Then add the Title product to your target. The MLX trait is required: without it the module compiles as a stub. Get a title and a one or two sentence description for any passage of text, on device. Fine-tuned on transcript clips, but it works on any prose. The register is deliberately plain, with no emoji, no hashtags and no clickbait, and a description is meant to identify this passage rather than its topic. An MLX model directory. Load the folder, not a single file. The chat template is not incidental. A…
This is the model card of a transformers model that has been pushed on the Hub. Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Use the code below to get started with the model. Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
SmolLM2Prover is a specialized, fine-tuned version of prithivMLmods/SmolLM2-CoT-360M. While retaining the strong conversational abilities of its base model, this version has been specifically enhanced to excel at deep thinking, logical reasoning, and higher-level mathematics, with a focus on generating step-by-step proofs and explanations (Chain-of-Thought). The model was fine-tuned using multiple rounds of Supervised Fine-Tuning (SFT) with the TRL library on a curated dataset, enhancing its ability to follow complex instructions and reason through problems. This model is intended to be used for text generation tasks that require logical reasoning or advanced conversation. The easiest way…
The Drafter agent of a LangGraph multi-agent support system for the fictional shop ReVonance. Base model HuggingFaceTB/SmolLM2-360M-Instruct, fine-tuned with LoRA (merged). Stage: sft (sft = supervised on the response simulator; dpo = then aligned with human and critic preferences via Direct Preference Optimisation). Knowledge-base fingerprint: f9cdb07b5df6. Demo model trained on synthetic data; it only knows the toy policies of ReVonance.
Results on demo model (different generation method, one model per language): Keywords generated with vlT5-base-keywords: encoder-decoder architecture, vlT5, keyword generation, scientific articles corpus The biggest advantage is the transferability of the vlT5 model, as it works well on all domains and types of text. The downside is that the text length and the number of keywords are similar to the training data: the text piece of an abstract length generates approximately 3 to 5 keywords. It works both extractive and abstractively. Longer pieces of text must be split into smaller chunks, and then propagated to the model. The model was trained on a POSMAC corpus. Polish Open Science…