Instructions to use Welmia/welmia-1.0-81m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Welmia/welmia-1.0-81m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Welmia/welmia-1.0-81m")# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Welmia/welmia-1.0-81m", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Welmia/welmia-1.0-81m with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Welmia/welmia-1.0-81m" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Welmia/welmia-1.0-81m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Welmia/welmia-1.0-81m
- SGLang
How to use Welmia/welmia-1.0-81m 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 "Welmia/welmia-1.0-81m" \ --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": "Welmia/welmia-1.0-81m", "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 "Welmia/welmia-1.0-81m" \ --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": "Welmia/welmia-1.0-81m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Welmia/welmia-1.0-81m with Docker Model Runner:
docker model run hf.co/Welmia/welmia-1.0-81m
Welmia-1.0 (81M)
A lightweight 81M-parameter causal language model trained completely from scratch using a TinyLLaMA-inspired architecture with RoPE, RMSNorm, SwiGLU, and KV-cache streaming support. Designed for fast local inference, edge deployment, and research experimentation.
ποΈ Architecture Details
| Parameter | Value |
|---|---|
| Parameters | 81M |
| Layers | 6 |
| Attention Heads | 12 |
| Embedding Dim | 768 |
| Context Length | 1024 |
| Vocab Size | 50,257 |
| Normalization | RMSNorm |
| Activation | SwiGLU |
| Positional Enc. | RoPE |
| Tokenizer | GPT-2 (tiktoken) |
| Weight Tying | β Yes |
π Quick Start
Installation
pip install torch safetensors tiktoken transformers>=4.40.0
### Load with Transformers (Recommended)
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"YOUR_HF_USERNAME/welmia-1.0-81m",
trust_remote_code=True,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("YOUR_HF_USERNAME/welmia-1.0-81m")
prompt = "### Instruction:\nWhat is machine learning?\n\n### Response:\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7, top_k=50)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Streaming Inference with KV Cache
This model supports token-by-token streaming generation with persistent KV cache for efficient long-context inference:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"YOUR_HF_USERNAME/welmia-1.0-81m", trust_remote_code=True
).eval()
tokenizer = AutoTokenizer.from_pretrained("YOUR_HF_USERNAME/welmia-1.0-81m")
@torch.inference_mode()
def stream_generate(prompt, max_new_tokens=300, temperature=0.7, top_k=50):
formatted = f"### Instruction:\n{prompt}\n\n### Response:\n"
ids = tokenizer.encode(formatted)
x = torch.tensor([ids], dtype=torch.long, device=model.device)
logits, caches = model(x, use_cache=True)
generated = []
for _ in range(max_new_tokens):
next_logits = logits[:, -1, :] / temperature
if top_k > 0:
v, _ = torch.topk(next_logits, min(top_k, next_logits.size(-1)))
next_logits[next_logits < v[:, [-1]]] = float("-inf")
probs = torch.softmax(next_logits, dim=-1)
next_token = torch.multinomial(probs, 1)
if next_token.item() == tokenizer.eos_token_id:
break
generated.append(next_token.item())
print(tokenizer.decode(generated[-1]), end="", flush=True)
logits, caches = model(next_token, kv_caches=caches,
start_pos=len(ids)+len(generated)-1, use_cache=True)
print()
stream_generate("Explain why the sky is blue")
β οΈ Important Notes
- Custom Architecture: This model uses a non-standard architecture. You must pass
trust_remote_code=Truewhen loading. - Tokenizer: Uses the standard GPT-2 BPE tokenizer via tiktoken. The included HF tokenizer files are compatible wrappers.
- Training: Trained completely from scratch (not fine-tuned from an existing checkpoint). Training details and dataset information will be added in future updates.
- Context Limit: Maximum context length is 1024 tokens. Inputs exceeding this will be truncated from the left.
π Intended Use & Limitations
β Good for:
- Edge/local deployment on CPU or low-VRAM GPUs
- Research into small-scale LM training dynamics
- Fast prototyping and instruction-following experiments
- Educational purposes and architecture exploration
β Not suitable for:
- Production applications requiring high accuracy
- Tasks requiring deep world knowledge or reasoning
- Multilingual generation (English only)
- Long-context tasks beyond 1024 tokens
π License
Apache License 2.0
π€ Author
Trained and released by [Your Name/Org]
π Acknowledgements
Architecture inspired by TinyLLaMA. Built with PyTorch, safetensors, and Hugging Face Transformers.
If you find this model useful, please consider leaving a β€οΈ like and sharing your experiments!
- Downloads last month
- -