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
modeling: use_cache=True icin GDN durum-devretme
Browse files- modeling_erk_linear.py +45 -2
modeling_erk_linear.py
CHANGED
|
@@ -21,15 +21,58 @@ 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
y = out[0] if isinstance(out, tuple) else out
|
|
|
|
|
|
|
| 33 |
return (y, None)
|
| 34 |
|
| 35 |
|
|
|
|
| 21 |
GDN_LAYERS = [1, 3, 5, 7, 10, 36, 38, 39] # %20 lineer, yayilmis yerlesim
|
| 22 |
|
| 23 |
|
| 24 |
+
class _GDNStateCache:
|
| 25 |
+
"""GatedDeltaNet'in get/update_layer_cache arayuzunun bekledigi minimal katman-durum tutucu.
|
| 26 |
+
|
| 27 |
+
FLA'nin recurrent_state + conv_state'ini tek katman icin saklar; boylece cache'li uretim
|
| 28 |
+
sirasinda GDN gecmis durumu adimlar arasi devreder.
|
| 29 |
+
"""
|
| 30 |
+
def __init__(self):
|
| 31 |
+
self._layers = []
|
| 32 |
+
|
| 33 |
+
def __len__(self):
|
| 34 |
+
return len(self._layers)
|
| 35 |
+
|
| 36 |
+
def __getitem__(self, idx):
|
| 37 |
+
return self._layers[idx]
|
| 38 |
+
|
| 39 |
+
def update(self, layer_idx=0, recurrent_state=None, conv_state=None, **kwargs):
|
| 40 |
+
while len(self._layers) <= layer_idx:
|
| 41 |
+
self._layers.append({"recurrent_state": None, "conv_state": None})
|
| 42 |
+
if recurrent_state is not None:
|
| 43 |
+
self._layers[layer_idx]["recurrent_state"] = recurrent_state
|
| 44 |
+
if conv_state is not None:
|
| 45 |
+
self._layers[layer_idx]["conv_state"] = conv_state
|
| 46 |
+
return self
|
| 47 |
+
|
| 48 |
+
|
| 49 |
class _GDNAttention(nn.Module):
|
| 50 |
+
"""Qwen3 self_attn cagri imzasiyla uyumlu Gated DeltaNet sarmalayici.
|
| 51 |
+
|
| 52 |
+
Cache'li uretim (use_cache=True) sirasinda GDN'nin recurrent + convolution durumunu
|
| 53 |
+
adimlar arasi devreder; boylece model.generate() ciktisi, tam-yeniden-hesaplama
|
| 54 |
+
(use_cache=False) ile sayisal gurultuye kadar ayni olur. Referans amacli tek-dizi
|
| 55 |
+
kullanim icindir (es zamanli/batch-paylasimli servis icin ayri durum yonetimi gerekir).
|
| 56 |
+
"""
|
| 57 |
def __init__(self, gdn):
|
| 58 |
super().__init__()
|
| 59 |
+
gdn.layer_idx = 0
|
| 60 |
self.gdn = gdn
|
| 61 |
+
self._state = None
|
| 62 |
|
| 63 |
def forward(self, hidden_states, *args, **kwargs):
|
| 64 |
+
cache_position = kwargs.get("cache_position", None)
|
| 65 |
+
seq_len = hidden_states.shape[1]
|
| 66 |
+
new_sequence = (
|
| 67 |
+
(cache_position is None and seq_len > 1)
|
| 68 |
+
or (cache_position is not None and int(cache_position.reshape(-1)[0]) == 0)
|
| 69 |
+
)
|
| 70 |
+
if new_sequence or self._state is None:
|
| 71 |
+
self._state = _GDNStateCache()
|
| 72 |
+
out = self.gdn(hidden_states, use_cache=True, past_key_values=self._state)
|
| 73 |
y = out[0] if isinstance(out, tuple) else out
|
| 74 |
+
if isinstance(out, tuple) and len(out) >= 3 and out[2] is not None:
|
| 75 |
+
self._state = out[2]
|
| 76 |
return (y, None)
|
| 77 |
|
| 78 |
|