Text Generation
Transformers
Safetensors
hybrid_tiny_lm
custom-code
hybrid-attention
state-space-model
wikitext
ml-intern
Instructions to use rahulshetty/hybrid-tiny-wikitext-poc with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rahulshetty/hybrid-tiny-wikitext-poc with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rahulshetty/hybrid-tiny-wikitext-poc")# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("rahulshetty/hybrid-tiny-wikitext-poc", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use rahulshetty/hybrid-tiny-wikitext-poc with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rahulshetty/hybrid-tiny-wikitext-poc" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rahulshetty/hybrid-tiny-wikitext-poc", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/rahulshetty/hybrid-tiny-wikitext-poc
- SGLang
How to use rahulshetty/hybrid-tiny-wikitext-poc 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 "rahulshetty/hybrid-tiny-wikitext-poc" \ --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": "rahulshetty/hybrid-tiny-wikitext-poc", "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 "rahulshetty/hybrid-tiny-wikitext-poc" \ --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": "rahulshetty/hybrid-tiny-wikitext-poc", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use rahulshetty/hybrid-tiny-wikitext-poc with Docker Model Runner:
docker model run hf.co/rahulshetty/hybrid-tiny-wikitext-poc
File size: 2,101 Bytes
27fd2eb e4de392 27fd2eb e4de392 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | ---
library_name: transformers
tags:
- text-generation
- custom-code
- hybrid-attention
- state-space-model
- wikitext
- ml-intern
license: mit
datasets:
- Salesforce/wikitext
---
# Hybrid Tiny LM POC on WikiText-2
Proof-of-concept causal language model combining multiple token-mixing approaches:
- local/full causal self-attention for exact token lookup
- gated causal depthwise convolution for local pattern mixing
- input-gated diagonal recurrent mixer as a tiny SSM/RWKV-like compressed memory
- hybrid blocks that run attention + conv + recurrence in parallel and fuse them
Dataset: `Salesforce/wikitext`, config `wikitext-2-raw-v1`.
Tokenizer: `openai-community/gpt2`.
## POC metrics
```json
{
"eval_loss": 7.388123512268066,
"eval_runtime": 9.5676,
"eval_samples_per_second": 26.757,
"eval_steps_per_second": 3.345,
"epoch": 0.78125,
"perplexity": 1616.6696041601817,
"train_loss": 7.8487934923172,
"params": 10403040
}
```
This is intentionally tiny and trained briefly as an architecture POC, not a competitive LM.
## Reproduce
```bash
pip install "transformers>=4.54.0" datasets torch accelerate trackio
python hybrid_lm_poc.py \
--max_steps 200 \
--max_train_samples 2048 \
--max_eval_samples 256 \
--batch_size 8 \
--d_model 96 \
--n_layer 6 \
--block_size 64 \
--learning_rate 8e-4
```
Sample generation after the short run is in `sample_generation.txt`.
<!-- ml-intern-provenance -->
## Generated by ML Intern
This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern
## Usage
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = 'rahulshetty/hybrid-tiny-wikitext-poc'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
```
For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.
|