Text Generation
PyTorch
Transformers
English
language-model
graph-neural-network
sparse-attention
adaptive-depth
temporal-decay
mesh-attention
efficient-transformer
novel-architecture
causal-lm
research
preprint
mesh-transformer
dynamic-graph
early-exit
per-token-routing
Eval Results (legacy)
Instructions to use vigneshwar234/TemporalMesh-Transformer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vigneshwar234/TemporalMesh-Transformer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="vigneshwar234/TemporalMesh-Transformer")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("vigneshwar234/TemporalMesh-Transformer", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use vigneshwar234/TemporalMesh-Transformer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vigneshwar234/TemporalMesh-Transformer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vigneshwar234/TemporalMesh-Transformer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/vigneshwar234/TemporalMesh-Transformer
- SGLang
How to use vigneshwar234/TemporalMesh-Transformer 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 "vigneshwar234/TemporalMesh-Transformer" \ --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": "vigneshwar234/TemporalMesh-Transformer", "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 "vigneshwar234/TemporalMesh-Transformer" \ --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": "vigneshwar234/TemporalMesh-Transformer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use vigneshwar234/TemporalMesh-Transformer with Docker Model Runner:
docker model run hf.co/vigneshwar234/TemporalMesh-Transformer
| """ | |
| layers.py β TMTLayer: one full layer of the TemporalMesh Transformer. | |
| Combines MeshAttention β DualStreamFFN β ExitGate β MemoryAnchorCross. | |
| Tokens that have already exited (exit_mask=True) are frozen β their | |
| representation from the exiting layer is carried forward unchanged. | |
| """ | |
| from __future__ import annotations | |
| from typing import Optional, Tuple | |
| import torch | |
| import torch.nn as nn | |
| from torch import Tensor | |
| from .attention import MeshAttention | |
| from .config import TMTConfig | |
| from .exit_gate import ExitGate | |
| from .ffn import DualStreamFFN | |
| from .memory import MemoryAnchorCross | |
| class TMTLayer(nn.Module): | |
| def __init__(self, cfg: TMTConfig, layer_idx: int) -> None: | |
| super().__init__() | |
| self.layer_idx = layer_idx | |
| self.norm1 = nn.LayerNorm(cfg.d_model, eps=cfg.layer_norm_eps) | |
| self.attn = MeshAttention(cfg) | |
| self.norm2 = nn.LayerNorm(cfg.d_model, eps=cfg.layer_norm_eps) | |
| self.ffn = DualStreamFFN(cfg) | |
| self.exit_gate = ExitGate(cfg) | |
| self.norm3 = nn.LayerNorm(cfg.d_model, eps=cfg.layer_norm_eps) | |
| self.memory_cross = MemoryAnchorCross(cfg) | |
| def forward( | |
| self, | |
| x: Tensor, | |
| edge_index: Tensor, | |
| edge_weight: Tensor, | |
| exit_mask: Tensor, | |
| decay_scalars: Optional[Tensor] = None, | |
| ) -> Tuple[Tensor, Tensor, Tensor, Tensor]: | |
| """ | |
| Args: | |
| x: (B, S, D) | |
| edge_index: (2, E) | |
| edge_weight: (E,) | |
| exit_mask: (B, S) bool β True where token has exited | |
| decay_scalars: (B, S, D) optional temporal decay | |
| Returns: | |
| x: (B, S, D) updated representations | |
| exit_mask: (B, S) updated exit mask | |
| confidence: (B, S) gate confidence scores | |
| memory_state: (M, D) updated memory anchors | |
| """ | |
| # Save exited-token representations so we can restore after layer ops | |
| x_frozen = x.clone() | |
| # MeshAttention + residual | |
| attn_out = self.attn(self.norm1(x), edge_index, edge_weight, decay_scalars) | |
| x = x + attn_out | |
| # DualStreamFFN + residual | |
| ffn_out = self.ffn(self.norm2(x)) | |
| x = x + ffn_out | |
| # ExitGate | |
| x, exit_mask, confidence = self.exit_gate(x, exit_mask) | |
| # Memory cross-attention + residual | |
| mem_out, memory_state = self.memory_cross(self.norm3(x)) | |
| x = x + mem_out | |
| # Freeze exited tokens: replace with their pre-layer values | |
| if exit_mask.any(): | |
| frozen = exit_mask.unsqueeze(-1).expand_as(x) | |
| x = torch.where(frozen, x_frozen, x) | |
| return x, exit_mask, confidence, memory_state | |
| def __repr__(self) -> str: | |
| p = sum(p.numel() for p in self.parameters()) | |
| return f"TMTLayer(idx={self.layer_idx}, params={p:,})" | |