Text Generation
Transformers
Turkish
erk_linear
linear-attention
gated-deltanet
hybrid-attention
efficient-attention
turkish
erk
research
custom_code
conversational
Eval Results (legacy)
Instructions to use ecloudtech/Erk-Linear with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ecloudtech/Erk-Linear with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ecloudtech/Erk-Linear", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ecloudtech/Erk-Linear", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ecloudtech/Erk-Linear with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ecloudtech/Erk-Linear" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ecloudtech/Erk-Linear", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ecloudtech/Erk-Linear
- SGLang
How to use ecloudtech/Erk-Linear 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 "ecloudtech/Erk-Linear" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ecloudtech/Erk-Linear", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "ecloudtech/Erk-Linear" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ecloudtech/Erk-Linear", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ecloudtech/Erk-Linear with Docker Model Runner:
docker model run hf.co/ecloudtech/Erk-Linear
Upload modeling_erk_linear.py with huggingface_hub
Browse files- modeling_erk_linear.py +63 -0
modeling_erk_linear.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Erk-Linear — Erk-14B'nin 8 dikkat katmanini Gated DeltaNet'e damitan %20-lineer hibrit.
|
| 3 |
+
|
| 4 |
+
Yukleme:
|
| 5 |
+
# gerekli: pip install torch transformers flash-linear-attention safetensors huggingface_hub
|
| 6 |
+
from modeling_erk_linear import load_erk_linear
|
| 7 |
+
model, tokenizer = load_erk_linear() # Erk-14B tabanini + GDN agirliklarini indirir
|
| 8 |
+
out = model.generate(**tokenizer("Merhaba", return_tensors="pt").to(model.device))
|
| 9 |
+
|
| 10 |
+
Model, Qwen3-14B mimarisine dayanir; 8 katmanin softmax dikkati subquadratic Gated DeltaNet ile
|
| 11 |
+
degistirilmis, kalan 32 katman softmax "cipa" olarak korunmustur. Ayrinti: teknik rapor / GitHub.
|
| 12 |
+
"""
|
| 13 |
+
import torch
|
| 14 |
+
import torch.nn as nn
|
| 15 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 16 |
+
from safetensors.torch import load_file
|
| 17 |
+
from huggingface_hub import hf_hub_download
|
| 18 |
+
|
| 19 |
+
BASE_MODEL = "ecloudtech/Erk-14B" # Qwen3-14B temelli Turkce model
|
| 20 |
+
REPO_ID = "ecloudtech/Erk-Linear"
|
| 21 |
+
GDN_LAYERS = [1, 3, 5, 7, 10, 36, 38, 39] # %20 lineer, yayilmis yerlesim
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class _GDNAttention(nn.Module):
|
| 25 |
+
"""Qwen3 self_attn cagri imzasiyla uyumlu Gated DeltaNet sarmalayici."""
|
| 26 |
+
def __init__(self, gdn):
|
| 27 |
+
super().__init__()
|
| 28 |
+
self.gdn = gdn
|
| 29 |
+
|
| 30 |
+
def forward(self, hidden_states, *args, **kwargs):
|
| 31 |
+
out = self.gdn(hidden_states)
|
| 32 |
+
y = out[0] if isinstance(out, tuple) else out
|
| 33 |
+
return (y, None)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def load_erk_linear(device="cuda", dtype=torch.bfloat16,
|
| 37 |
+
base_model=BASE_MODEL, repo_id=REPO_ID):
|
| 38 |
+
"""Erk-Linear hibridini kurar ve (model, tokenizer) doner."""
|
| 39 |
+
from fla.layers import GatedDeltaNet # flash-linear-attention
|
| 40 |
+
|
| 41 |
+
model = AutoModelForCausalLM.from_pretrained(base_model, torch_dtype=dtype).to(device).eval()
|
| 42 |
+
H = model.config.hidden_size
|
| 43 |
+
|
| 44 |
+
gdn_path = hf_hub_download(repo_id=repo_id, filename="gdn_weights.safetensors")
|
| 45 |
+
state = load_file(gdn_path)
|
| 46 |
+
|
| 47 |
+
for li in GDN_LAYERS:
|
| 48 |
+
gdn = GatedDeltaNet(hidden_size=H, head_dim=128, num_heads=40,
|
| 49 |
+
use_gate=True, use_short_conv=True, mode="chunk")
|
| 50 |
+
prefix = f"L{li}."
|
| 51 |
+
layer_sd = {k[len(prefix):]: v for k, v in state.items() if k.startswith(prefix)}
|
| 52 |
+
gdn.load_state_dict(layer_sd)
|
| 53 |
+
gdn = gdn.to(device).to(dtype).eval()
|
| 54 |
+
model.model.layers[li].self_attn = _GDNAttention(gdn).to(device).to(dtype)
|
| 55 |
+
|
| 56 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model)
|
| 57 |
+
return model, tokenizer
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
if __name__ == "__main__":
|
| 61 |
+
m, t = load_erk_linear()
|
| 62 |
+
ids = t("Türkiye'nin başkenti", return_tensors="pt").to(m.device)
|
| 63 |
+
print(t.decode(m.generate(**ids, max_new_tokens=12)[0], skip_special_tokens=True))
|