Instructions to use Vi-LAB/KenT-20M-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Vi-LAB/KenT-20M-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Vi-LAB/KenT-20M-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Vi-LAB/KenT-20M-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Vi-LAB/KenT-20M-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-20M-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-20M-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Vi-LAB/KenT-20M-Base
- SGLang
How to use Vi-LAB/KenT-20M-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-20M-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-20M-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-20M-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-20M-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Vi-LAB/KenT-20M-Base with Docker Model Runner:
docker model run hf.co/Vi-LAB/KenT-20M-Base
KenT-20M-Base
~19.6M tham số, mô hình ngôn ngữ hồi quy một token mỗi bước. Không attention: lịch sử nằm trong bộ nhớ EMA học được ở mọi độ sâu.
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 Matrix, A = sigmoid(logits), shape (n+1, D)
S = Σ_i H_i[t+1] # Add
y = S · D # "DCT-II Proj (D)" (DCT ngược)
out = y + SwiGLU(RMSNorm(y))
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.
| vocab | 50257 (GPT-2), tied embedding / LM head |
D (hidden_size) |
240 |
n khối xanh (num_hidden_layers) |
12 (→ 13 tap EMA) |
SwiGLU hidden (intermediate_size) |
720 (3D) |
| tham số | ≈ 19.56M (embedding 12.06M) |
| trạng thái giải mã | H shape (13, 240), 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ự.
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("Vi-LAB/KenT-20M-Base", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("Vi-LAB/KenT-20M-Base", trust_remote_code=True)
Hoặc python infer.py --model Vi-LAB/KenT-20M-Base --prompt "Today the weather is".
- Downloads last month
- 30
