Instructions to use Vi-LAB/KenT-300M-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Vi-LAB/KenT-300M-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Vi-LAB/KenT-300M-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Vi-LAB/KenT-300M-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Vi-LAB/KenT-300M-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Vi-LAB/KenT-300M-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Vi-LAB/KenT-300M-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Vi-LAB/KenT-300M-Base
- SGLang
How to use Vi-LAB/KenT-300M-Base 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 "Vi-LAB/KenT-300M-Base" \ --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": "Vi-LAB/KenT-300M-Base", "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 "Vi-LAB/KenT-300M-Base" \ --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": "Vi-LAB/KenT-300M-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Vi-LAB/KenT-300M-Base with Docker Model Runner:
docker model run hf.co/Vi-LAB/KenT-300M-Base
File size: 2,901 Bytes
bc61c1b 4ea3a84 bc61c1b e2a3b30 bc61c1b e2a3b30 bc61c1b e2a3b30 bc61c1b e2a3b30 bc61c1b e2a3b30 bc61c1b 4ea3a84 bc61c1b 4ea3a84 | 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 | ---
library_name: transformers
license: apache-2.0
language:
- en
pipeline_tag: text-generation
tags:
- recurrent
- ema
- dct
- swiglu
- custom_code
- base
datasets:
- wikimedia/wikipedia
- HuggingFaceFW/fineweb-edu
---
# KenT-300M-Base
~299.7M tham số, mô hình ngôn ngữ hồi quy **một token mỗi bước**. Không attention theo thời gian: lịch sử nằm trong bộ nhớ EMA học được ở mọi độ sâu; attention chỉ chạy theo trục độ sâu (N tap) của chính token hiện tại.
```
h_0 = x[t] # embedding, (1, D)
h_i = h_{i-1} + SwiGLU(RMSNorm(h_{i-1})) # i = 1..n khối xanh
u_i = RMSNorm(h_i) · D^T · W_i # i = 0..n khối cam "~DCT-II Proj (D^T)W"
H_i[t+1] = (1 - A_i) ⊙ H_i[t] + A_i ⊙ u_i # Learnable EMA Vector, A = sigmoid(logits), shape (N, D), N = n+1
Hcat = Concat_i H_i[t+1] # (N, D)
p = Q + Wo · Attn(Q, K, V) # Attn Pooling -> Query Residual
K, V = RMSNorm(Hcat) ; Q = learner query (1, D) học được, pooling hết N vector
g = p + SwiGLU(RMSNorm(p)) # khối xanh cuối
y = g · D # "DCT-II Proj" (DCT ngược)
out = x[t] + y # Add với đầu vào gốc x[t]
logits = LM_head(RMSNorm_f(out)) # tied với embedding
```
D là ma trận DCT-II trực chuẩn cố định (hàng = tần số, vector hàng nên DCT là `x·D^T`); W học được, khởi tạo ≈ I.
`RMSNorm_f` không có trong sơ đồ, thêm để logits ổn định.
Tiêu chí siêu tham số: **D là độ phân giải** (D cao => chênh lệch góc giữa các tần số DCT nhỏ), **N = n+1 là khả năng tư duy** (N sâu => học quan hệ tốt hơn). SwiGLU hidden giữ ở ~2D để dồn ngân sách tham số cho D và N.
| | |
|---|---|
| vocab | 50257 (GPT-2), tied embedding / LM head |
| D (`hidden_size`) | 1152 |
| n khối xanh (`num_hidden_layers`) | 24 (→ N = 25 tap EMA) |
| SwiGLU hidden (`intermediate_size`) | 2352 (~2D) |
| Attn Pooling heads (`pool_num_heads`) | 9 (head_dim 128) |
| tham số | ≈ 299.68M (embedding 57.89M) |
| trạng thái giải mã | H shape (25, 1152), O(1) theo độ dài |

EMA khởi tạo theo cấp số nhân từ 0.5 (tap đầu, feature đầu) đến 0.01 (tap cuối, feature cuối); vẫn học được.
EMA chạy FP32 bằng affine-scan log-depth, kết quả bằng đúng hồi quy tuần tự.
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("Vi-LAB/KenT-300M-Base", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("Vi-LAB/KenT-300M-Base", trust_remote_code=True)
```
Hoặc `python infer.py --model Vi-LAB/KenT-300M-Base --prompt "Today the weather is"`. |