Text Generation
Transformers
Safetensors
English
kent
ssm
state-space-model
recurrent
linear-time
frequency-domain
dct
mlp
swiglu
custom_code
fp16
base
Instructions to use Vi-LAB/KenT-1B-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Vi-LAB/KenT-1B-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Vi-LAB/KenT-1B-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Vi-LAB/KenT-1B-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Vi-LAB/KenT-1B-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-1B-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-1B-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Vi-LAB/KenT-1B-Base
- SGLang
How to use Vi-LAB/KenT-1B-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-1B-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-1B-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-1B-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-1B-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Vi-LAB/KenT-1B-Base with Docker Model Runner:
docker model run hf.co/Vi-LAB/KenT-1B-Base
KenteaKe11 commited on
Commit ·
fe9c6f7
1
Parent(s): 99eb3d1
KenT-300M: EMA memory with learned per-layer alpha, 1 WNN per layer, 24 layers, fp32 EMA
Browse files
model.py
CHANGED
|
@@ -150,6 +150,12 @@ def _affine_scan(a: torch.Tensor, b: torch.Tensor):
|
|
| 150 |
|
| 151 |
|
| 152 |
def ema_scan(u: torch.Tensor, mask: torch.Tensor, h0: torch.Tensor, a: torch.Tensor, block: int = 128):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
"""H_t = (1 - a m_t) H_{t-1} + a m_t u_t, tính song song cho mọi t.
|
| 154 |
|
| 155 |
u: (B,T,N,D) fp32 | mask: (B,T) {0,1} (0 = padding: H giữ nguyên) | h0: (B,N,D) fp32
|
|
|
|
| 150 |
|
| 151 |
|
| 152 |
def ema_scan(u: torch.Tensor, mask: torch.Tensor, h0: torch.Tensor, a: torch.Tensor, block: int = 128):
|
| 153 |
+
"""EMA song song, luôn chạy fp32 (tắt autocast để matmul không bị ép về fp16)."""
|
| 154 |
+
with torch.autocast(device_type=u.device.type, enabled=False):
|
| 155 |
+
return _ema_scan_fp32(u.float(), mask, h0.float(), a.float(), block)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def _ema_scan_fp32(u: torch.Tensor, mask: torch.Tensor, h0: torch.Tensor, a: torch.Tensor, block: int = 128):
|
| 159 |
"""H_t = (1 - a m_t) H_{t-1} + a m_t u_t, tính song song cho mọi t.
|
| 160 |
|
| 161 |
u: (B,T,N,D) fp32 | mask: (B,T) {0,1} (0 = padding: H giữ nguyên) | h0: (B,N,D) fp32
|