Text Generation
Transformers
Safetensors
GGUF
English
code
llama
python
pytho25m
tiny-llm
text-generation-inference
Instructions to use Sayansantra/pytho25M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sayansantra/pytho25M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Sayansantra/pytho25M")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Sayansantra/pytho25M") model = AutoModelForCausalLM.from_pretrained("Sayansantra/pytho25M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Sayansantra/pytho25M with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Sayansantra/pytho25M:Q4_K_M # Run inference directly in the terminal: llama cli -hf Sayansantra/pytho25M:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Sayansantra/pytho25M:Q4_K_M # Run inference directly in the terminal: llama cli -hf Sayansantra/pytho25M:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Sayansantra/pytho25M:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Sayansantra/pytho25M:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Sayansantra/pytho25M:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Sayansantra/pytho25M:Q4_K_M
Use Docker
docker model run hf.co/Sayansantra/pytho25M:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Sayansantra/pytho25M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sayansantra/pytho25M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sayansantra/pytho25M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Sayansantra/pytho25M:Q4_K_M
- SGLang
How to use Sayansantra/pytho25M 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 "Sayansantra/pytho25M" \ --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": "Sayansantra/pytho25M", "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 "Sayansantra/pytho25M" \ --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": "Sayansantra/pytho25M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use Sayansantra/pytho25M with Ollama:
ollama run hf.co/Sayansantra/pytho25M:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use Sayansantra/pytho25M with Docker Model Runner:
docker model run hf.co/Sayansantra/pytho25M:Q4_K_M
- Lemonade
How to use Sayansantra/pytho25M with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Sayansantra/pytho25M:Q4_K_M
Run and chat with the model
lemonade run user.pytho25M-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Upload Pytho 25M model files (Safetensors + GGUF + Model Card)
Browse files- .gitattributes +1 -0
- README.md +106 -1
- config.json +32 -0
- generation_config.json +10 -0
- model.safetensors +3 -0
- pytho25m_Q4_K_M.gguf +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +10 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
pytho25m_Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,108 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- code
|
| 5 |
+
license: mit
|
| 6 |
+
library_name: transformers
|
| 7 |
+
tags:
|
| 8 |
+
- code
|
| 9 |
+
- python
|
| 10 |
+
- pytho25m
|
| 11 |
+
- tiny-llm
|
| 12 |
+
- gguf
|
| 13 |
+
- text-generation
|
| 14 |
+
pipeline_tag: text-generation
|
| 15 |
+
inference: true
|
| 16 |
+
datasets:
|
| 17 |
+
- iamtarun/python_code_instructions_18k_alpaca
|
| 18 |
+
model_format:
|
| 19 |
+
- safetensors
|
| 20 |
+
- gguf
|
| 21 |
+
params: 25103232
|
| 22 |
---
|
| 23 |
+
|
| 24 |
+
# 🚀 Pytho 25M (Python Code Assistant)
|
| 25 |
+
|
| 26 |
+
**Pytho 25M** (`Sayansantra/pytho25M`) is an ultra-compact ~25 Million parameter language model designed specifically for Python code generation and instruction following. Trained on 18,000 Python Alpaca instructions, Pytho 25M delivers fast Python code generation while using **under 30 MB of RAM**.
|
| 27 |
+
|
| 28 |
+
Available in both **unquantized PyTorch Safetensors** and **4-bit quantized GGUF format**.
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## 📊 Model Architecture Specs
|
| 33 |
+
|
| 34 |
+
| Property | Value |
|
| 35 |
+
|---|---|
|
| 36 |
+
| **Model Name** | **Pytho 25M** (`Sayansantra/pytho25M`) |
|
| 37 |
+
| **Parameters** | **25.10 Million** (25,103,232) |
|
| 38 |
+
| **Architecture** | Custom Causal LM |
|
| 39 |
+
| **Layers** | 14 Hidden Layers |
|
| 40 |
+
| **Hidden Size (`d_model`)** | 384 |
|
| 41 |
+
| **Intermediate Size (`mlp`)** | 1024 |
|
| 42 |
+
| **Attention Heads** | 6 (Grouped-Query Attention w/ 2 KV Heads) |
|
| 43 |
+
| **Vocabulary Size** | 8,000 (Custom Byte-Level BPE) |
|
| 44 |
+
| **Max Context Length** | 512 Tokens |
|
| 45 |
+
| **Special Tokens** | `<s>`, `<pad>`, `</s>`, `<unk>`, `<|system|>`, `<|user|>`, `<|assistant|>` |
|
| 46 |
+
| **PyTorch Size** | 95.77 MB (FP32 Safetensors) |
|
| 47 |
+
| **GGUF Q4_K_M Size** | 17.71 MB |
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## ⚡ Quickstart Code Examples
|
| 52 |
+
|
| 53 |
+
### 1. PyTorch / Transformers Usage
|
| 54 |
+
|
| 55 |
+
```python
|
| 56 |
+
import torch
|
| 57 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 58 |
+
|
| 59 |
+
model_id = "Sayansantra/pytho25M"
|
| 60 |
+
|
| 61 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 62 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 63 |
+
|
| 64 |
+
prompt = "<|system|>\nYou are an expert Python coding assistant.</s>\n<|user|>\nWrite a python function to check if a number is prime.</s>\n<|assistant|>\n"
|
| 65 |
+
|
| 66 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 67 |
+
outputs = model.generate(
|
| 68 |
+
**inputs,
|
| 69 |
+
max_new_tokens=60,
|
| 70 |
+
do_sample=True,
|
| 71 |
+
temperature=0.7,
|
| 72 |
+
pad_token_id=tokenizer.eos_token_id
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
### 2. GGUF Usage with `llama-cpp-python`
|
| 79 |
+
|
| 80 |
+
```python
|
| 81 |
+
from llama_cpp import Llama
|
| 82 |
+
|
| 83 |
+
llm = Llama.from_pretrained(
|
| 84 |
+
repo_id="Sayansantra/pytho25M",
|
| 85 |
+
filename="pytho25m_Q4_K_M.gguf",
|
| 86 |
+
verbose=False
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
prompt = "<|system|>\nYou are an expert Python coding assistant.</s>\n<|user|>\nWrite a python function to reverse a string.</s>\n<|assistant|>\n"
|
| 90 |
+
response = llm(prompt, max_tokens=50)
|
| 91 |
+
print(response["choices"][0]["text"])
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
---
|
| 95 |
+
|
| 96 |
+
## 🏋️ Training Details
|
| 97 |
+
|
| 98 |
+
- **Dataset:** 18,000 Python Alpaca instructions (`iamtarun/python_code_instructions_18k_alpaca`)
|
| 99 |
+
- **Optimizer:** AdamW (`lr=8e-4`, `weight_decay=0.01`)
|
| 100 |
+
- **Epochs:** 10 Epochs
|
| 101 |
+
- **Batch Size:** 32 (Effective batch size)
|
| 102 |
+
- **Precision:** Mixed FP16
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
+
|
| 106 |
+
## 📜 Citation & License
|
| 107 |
+
|
| 108 |
+
Developed by **Sayan Santra**. Released under the **MIT License**.
|
config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"dtype": "float32",
|
| 9 |
+
"eos_token_id": 2,
|
| 10 |
+
"head_dim": 64,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 384,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 1024,
|
| 15 |
+
"max_position_embeddings": 512,
|
| 16 |
+
"mlp_bias": false,
|
| 17 |
+
"model_type": "llama",
|
| 18 |
+
"num_attention_heads": 6,
|
| 19 |
+
"num_hidden_layers": 14,
|
| 20 |
+
"num_key_value_heads": 2,
|
| 21 |
+
"pad_token_id": 1,
|
| 22 |
+
"pretraining_tp": 1,
|
| 23 |
+
"rms_norm_eps": 1e-06,
|
| 24 |
+
"rope_parameters": {
|
| 25 |
+
"rope_theta": 10000.0,
|
| 26 |
+
"rope_type": "default"
|
| 27 |
+
},
|
| 28 |
+
"tie_word_embeddings": true,
|
| 29 |
+
"transformers_version": "5.0.0",
|
| 30 |
+
"use_cache": false,
|
| 31 |
+
"vocab_size": 8000
|
| 32 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 0,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"output_attentions": false,
|
| 6 |
+
"output_hidden_states": false,
|
| 7 |
+
"pad_token_id": 1,
|
| 8 |
+
"transformers_version": "5.0.0",
|
| 9 |
+
"use_cache": true
|
| 10 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8b0dee43cbbb1dceef9b8015ec05efb213f22a8f9c712e5f7a07921f7d522e40
|
| 3 |
+
size 100426920
|
pytho25m_Q4_K_M.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af3ed17e53c5292cce6732b9c7305d6cf6746a2a93552637ee9a815131d09b40
|
| 3 |
+
size 18573600
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<s>",
|
| 4 |
+
"eos_token": "</s>",
|
| 5 |
+
"merges_file": "custom_python_tokenizer/merges.txt",
|
| 6 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 7 |
+
"pad_token": "<pad>",
|
| 8 |
+
"tokenizer_class": "TokenizersBackend",
|
| 9 |
+
"unk_token": "<unk>"
|
| 10 |
+
}
|