Text Generation
Transformers
Safetensors
English
asterisk
aspp
pi-flow
hybrid-architecture
graph-reasoning
probability-flow
sft
trl
conversational
custom_code
Instructions to use NoesisLab/Asterisk-Pi-135M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NoesisLab/Asterisk-Pi-135M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NoesisLab/Asterisk-Pi-135M", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("NoesisLab/Asterisk-Pi-135M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NoesisLab/Asterisk-Pi-135M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NoesisLab/Asterisk-Pi-135M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NoesisLab/Asterisk-Pi-135M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NoesisLab/Asterisk-Pi-135M
- SGLang
How to use NoesisLab/Asterisk-Pi-135M 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 "NoesisLab/Asterisk-Pi-135M" \ --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": "NoesisLab/Asterisk-Pi-135M", "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 "NoesisLab/Asterisk-Pi-135M" \ --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": "NoesisLab/Asterisk-Pi-135M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NoesisLab/Asterisk-Pi-135M with Docker Model Runner:
docker model run hf.co/NoesisLab/Asterisk-Pi-135M
Upload 15 files
Browse filesFiles changed (8)
- .gitattributes+1
- ARCHASTERISK.pngAdded
- AsteriskForCausalLM.py+27-113
- README.md+8-101
- chat_template.jinja+1-1
- config.json+1-2
- model.safetensors+2-2
- training_args.bin+1-1
34 unmodified lines35363734 unmodified lines*tfevents* filter=lfs diff=lfs merge=lfs -textGemini_Generated_Image_jvekprjvekprjvek.png filter=lfs diff=lfs merge=lfs -textArch.png filter=lfs diff=lfs merge=lfs -text34 unmodified lines3536373834 unmodified lines*tfevents* filter=lfs diff=lfs merge=lfs -textGemini_Generated_Image_jvekprjvekprjvek.png filter=lfs diff=lfs merge=lfs -textArch.png filter=lfs diff=lfs merge=lfs -textARCHASTERISK.png filter=lfs diff=lfs merge=lfs -text
35 unmodified lines363738394041426 unmodified lines495051525354553 unmodified lines596061626364656667686970717273747576777879808182838485868788892 unmodified lines92939495969798991001011021031041051061071081091101111121131 unmodified line1151161171181191209 unmodified lines1301311321331341351361374 unmodified lines14214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021119 unmodified lines2312322332342352362372 unmodified lines24024124224324424524624713 unmodified lines26126226326426526626726887 unmodified lines35635735835936036136212 unmodified lines3753763773783793803813829 unmodified lines3923933943953963973983 unmodified lines4024034044054064074084094104114124134149 unmodified lines42442542642742842943010 unmodified lines44144244344444544644710 unmodified lines4584594604614624634641 unmodified line46646746846947047147247347447547647747847948035 unmodified linesaspp_hidden_dim: Optional[int] = None,aspp_num_steps: int = 2,aspp_dropout: float = 0.1,aspp_num_neighbors: int = 8, # NEW: number of semantic neighbors# Ο-flow parameterspi_flow: bool = False,pi_flow_steps: int = 1,6 unmodified linesself.aspp_hidden_dim = aspp_hidden_dimself.aspp_num_steps = aspp_num_stepsself.aspp_dropout = aspp_dropoutself.aspp_num_neighbors = aspp_num_neighbors# Ο-flow configself.pi_flow = pi_flowself.pi_flow_steps = pi_flow_steps3 unmodified linesclass ASPPOperator(nn.Module):"""Asterisk Operator (ASPP) - Graph Propagation with Adjacency List (2D Grid)Converts 1D sequence to 2D grid and performs 8-neighbor graph propagation:- Adjacency list: 8 neighbors per position (ζ£η8ι»ε± )β β ββ β ββ β β- Learnable adjacency weights (randomly initialized)- Padding for dynamic sequence lengths- Message passing: h_i^(t+1) = Ο(h_i^(t), Ξ£_jβN(i) A_j * h_j^(t))Args:hidden_size: Dimension of hidden states (input/output)aspp_hidden_dim: Internal dimension for ASPP (default: None, use hidden_size)num_steps: Number of evolution steps K (default: 2)dropout: Dropout rate for regularization (default: 0.1)num_neighbors: Number of neighbors (default: 8, for 8-directional grid)"""def __init__(self, hidden_size: int, aspp_hidden_dim: Optional[int] = None, num_steps: int = 2, dropout: float = 0.1, num_neighbors: int = 8):super().__init__()self.hidden_size = hidden_sizeself.aspp_hidden_dim = aspp_hidden_dim or hidden_sizeself.num_steps = num_stepsself.num_neighbors = num_neighbors# Projection to lower dimension (if specified)self.use_projection = (self.aspp_hidden_dim != hidden_size)2 unmodified linesself.up_proj = nn.Linear(self.aspp_hidden_dim, hidden_size)self.proj_dropout = nn.Dropout(dropout)# 8-directional offsets for 2D grid neighbors (row, col)# β(-1,-1) β(-1,0) β(-1,1)# β(0,-1) β(0,0) β(0,1)# β(1,-1) β(1,0) β(1,1)self.register_buffer('neighbor_offsets', torch.tensor([[-1, -1], [-1, 0], [-1, 1], # top-left, top, top-right[0, -1], [0, 1], # left, right[1, -1], [1, 0], [1, 1] # bottom-left, bottom, bottom-right], dtype=torch.long)) # [8, 2]# Learnable adjacency weights for 8 directions (randomly initialized)self.adjacency_weights = nn.Parameter(torch.randn(num_neighbors) * 0.1)# Message aggregation function: combines self + neighborsself.message_net = nn.Sequential(nn.Linear(self.aspp_hidden_dim * 2, self.aspp_hidden_dim * 2),nn.SiLU(),nn.Dropout(dropout),nn.Linear(self.aspp_hidden_dim * 2, self.aspp_hidden_dim),1 unmodified line)# Learnable K-step parameterself.k_logit = nn.Parameter(torch.tensor(1.0))# Learnable residual scale9 unmodified linesReturns:evolved_states: [batch_size, seq_len, hidden_size]"""batch_size, seq_len, _ = hidden_states.shape# Project to lower dimension if neededif self.use_projection:h_t = self.down_proj(hidden_states)4 unmodified lines# Learnable number of stepsk_steps = max(1, int(torch.sigmoid(self.k_logit) * self.num_steps))# K-step graph propagation with 2D grid adjacency listfor t in range(k_steps):# 1. Reshape 1D sequence to 2D grid# Dynamic grid size: H β W β sqrt(seq_len)H = int(torch.ceil(torch.sqrt(torch.tensor(seq_len, dtype=torch.float32))).item())W = int(torch.ceil(torch.tensor(seq_len, dtype=torch.float32) / H).item())grid_size = H * W# Pad sequence to grid_sizeif seq_len < grid_size:padding = grid_size - seq_lenh_t_padded = F.pad(h_t, (0, 0, 0, padding), mode='constant', value=0) # [B, H*W, D]else:h_t_padded = h_t# Reshape to 2D grid: [B, H*W, D] -> [B, H, W, D]h_grid = h_t_padded.view(batch_size, H, W, self.aspp_hidden_dim)# 2. Add boundary padding for neighbor gathering (pad with zeros)# Pad 1 row/col on each side: [B, H, W, D] -> [B, H+2, W+2, D]h_grid_padded = F.pad(h_grid, (0, 0, 1, 1, 1, 1), mode='constant', value=0)# 3. Gather neighbors using adjacency list (offsets)# neighbor_offsets: [8, 2] with (row_offset, col_offset)# Only use first num_neighbors offsetsneighbors_list = []for offset in self.neighbor_offsets[:self.num_neighbors]:# Offset is relative to center, but we need absolute indices in padded grid# Center at (i+1, j+1) in padded grid, neighbor at (i+1+di, j+1+dj)# Use roll to shift the griddi, dj = offset[0].item(), offset[1].item()# Create index tensors for gathering# For each position (i,j) in original grid, get neighbor at (i+di, j+dj) in padded gridrow_indices = torch.arange(H, device=h_t.device).view(-1, 1).expand(H, W) + 1 + dicol_indices = torch.arange(W, device=h_t.device).view(1, -1).expand(H, W) + 1 + dj# Gather neighbor features: [B, H, W, D]neighbor = h_grid_padded[:, row_indices, col_indices, :] # [B, H, W, D]neighbors_list.append(neighbor)# Stack neighbors: [B, H, W, num_neighbors, D]neighbors = torch.stack(neighbors_list, dim=3) # [B, H, W, num_neighbors, D]# 4. Apply learnable adjacency weights# adjacency_weights: [num_neighbors] -> normalize with softmaxadj_weights = F.softmax(self.adjacency_weights, dim=0) # [num_neighbors]# Weighted aggregation: [B, H, W, D]aggregated_neighbors = torch.sum(neighbors * adj_weights.view(1, 1, 1, self.num_neighbors, 1), dim=3)# 5. Message passing: combine self + neighbors# Flatten back to sequence: [B, H, W, D] -> [B, H*W, D]h_grid_flat = h_grid.view(batch_size, grid_size, self.aspp_hidden_dim)aggregated_flat = aggregated_neighbors.view(batch_size, grid_size, self.aspp_hidden_dim)# Concat and pass through message netmessage_input = torch.cat([h_grid_flat, aggregated_flat], dim=-1) # [B, H*W, 2D]h_t_next = self.message_net(message_input) # [B, H*W, D]# Remove padding to restore original seq_lenh_t_next = h_t_next[:, :seq_len, :] # [B, L, D]# 6. Scaled residual connection for stabilityh_t = h_t + self.residual_scale * h_t_nexth_t = self.norm(h_t)19 unmodified lines4. Feed-forward network"""def __init__(self, config: LlamaConfig, layer_idx: int, aspp_hidden_dim: Optional[int] = None, aspp_num_steps: int = 2, aspp_dropout: float = 0.1, aspp_num_neighbors: int = 8):# Initialize parent LlamaDecoderLayersuper().__init__(config, layer_idx)2 unmodified lineshidden_size=config.hidden_size,aspp_hidden_dim=aspp_hidden_dim,num_steps=aspp_num_steps,dropout=aspp_dropout,num_neighbors=aspp_num_neighbors)# Gated fusion mechanism with dropout13 unmodified lineshidden_size=config.hidden_size,aspp_hidden_dim=aspp_hidden_dim,num_steps=aspp_num_steps,dropout=aspp_dropout,num_neighbors=aspp_num_neighbors)# Learnable flow scale (per-layer)87 unmodified linesAll layers use hybrid ASPP+Attention by default for maximum expressiveness."""def __init__(self, config: LlamaConfig, hybrid_layer_indices: Optional[List[int]] = None, aspp_hidden_dim: Optional[int] = None, aspp_num_steps: int = 2, aspp_dropout: float = 0.1, aspp_num_neighbors: int = 8):super().__init__(config)# Determine which layers to make hybrid (default: ALL layers)12 unmodified lineslayer_idx=idx,aspp_hidden_dim=aspp_hidden_dim,aspp_num_steps=aspp_num_steps,aspp_dropout=aspp_dropout,aspp_num_neighbors=aspp_num_neighbors)# Initialize weights9 unmodified linesconfig_class = AsteriskConfigdef __init__(self, config: AsteriskConfig, hybrid_layer_indices: Optional[List[int]] = None, aspp_hidden_dim: Optional[int] = None, aspp_num_steps: int = 2, aspp_dropout: float = 0.1, aspp_num_neighbors: int = 8):# Read all ASPP parameters from config if not explicitly providedif hybrid_layer_indices is None and hasattr(config, 'hybrid_layer_indices'):hybrid_layer_indices = config.hybrid_layer_indices3 unmodified linesaspp_num_steps = config.aspp_num_stepsif hasattr(config, 'aspp_dropout'):aspp_dropout = config.aspp_dropoutif hasattr(config, 'aspp_num_neighbors'):aspp_num_neighbors = config.aspp_num_neighborssuper().__init__(config)# Replace model with Asterisk versionself.model = AsteriskLlamaModel(config, hybrid_layer_indices, aspp_hidden_dim, aspp_num_steps, aspp_dropout, aspp_num_neighbors)# Store hybrid layer info in config for serializationself.config.hybrid_layer_indices = hybrid_layer_indices9 unmodified linesaspp_hidden_dim: Optional[int] = None,aspp_num_steps: int = 2,aspp_dropout: float = 0.1,aspp_num_neighbors: int = 8, # NEW: number of semantic neighbors# Ο-flow parameterspi_flow: bool = False,pi_flow_steps: int = 1,10 unmodified linesaspp_hidden_dim: Internal dimension for ASPP (None = use model hidden_size)aspp_num_steps: Number of evolution steps K for ASPP (default: 2)aspp_dropout: Dropout rate for ASPP regularization (default: 0.1)aspp_num_neighbors: Number of semantic neighbors for graph propagation (default: 8)pi_flow: Enable Ο-flow refinement step (default: False)pi_flow_steps: Number of flow refinement steps (default: 1)pi_flow_scale: Initial flow scale parameter (default: 0.2)10 unmodified linesaspp_hidden_dim=aspp_hidden_dim,aspp_num_steps=aspp_num_steps,aspp_dropout=aspp_dropout,aspp_num_neighbors=aspp_num_neighbors,pi_flow=pi_flow,pi_flow_steps=pi_flow_steps,pi_flow_scale=pi_flow_scale,1 unmodified line)# Create Asterisk modelasterisk_model = cls(asterisk_config, hybrid_layer_indices, aspp_hidden_dim, aspp_num_steps, aspp_dropout, aspp_num_neighbors)# Transfer weights from base model (non-hybrid layers and embeddings)asterisk_model.load_state_dict(base_model.state_dict(), strict=False)print(f"β Converted base model to Asterisk architecture with Graph Propagation")print(f" Hybrid layers: {asterisk_model.model.hybrid_layer_indices}")aspp_dim_str = f"{aspp_hidden_dim}" if aspp_hidden_dim else f"{base_config.hidden_size} (full)"print(f" ASPP config: dim={aspp_dim_str}, steps={aspp_num_steps}, dropout={aspp_dropout}, neighbors={aspp_num_neighbors}")if pi_flow:print(f" Ο-flow enabled: steps={pi_flow_steps}, scale={pi_flow_scale}, gate={pi_flow_use_gate}")35 unmodified lines3637383940416 unmodified lines4849505152533 unmodified lines57585960616263646566676869707172737475767778798081822 unmodified lines858687888990919293941 unmodified line969798991001011029 unmodified lines1121131141151161174 unmodified lines12212312412512612712812913013113213319 unmodified lines1531541551561571581592 unmodified lines16216316416516616716813 unmodified lines18218318418518618718887 unmodified lines27627727827928028128212 unmodified lines2952962972982993003019 unmodified lines3113123133143153163173 unmodified lines3213223233243253263273283293303319 unmodified lines34134234334434534610 unmodified lines35735835936036136210 unmodified lines3733743753763773781 unmodified line38038138238338438538638738838939039139239339435 unmodified linesaspp_hidden_dim: Optional[int] = None,aspp_num_steps: int = 2,aspp_dropout: float = 0.1,# Ο-flow parameterspi_flow: bool = False,pi_flow_steps: int = 1,6 unmodified linesself.aspp_hidden_dim = aspp_hidden_dimself.aspp_num_steps = aspp_num_stepsself.aspp_dropout = aspp_dropout# Ο-flow configself.pi_flow = pi_flowself.pi_flow_steps = pi_flow_steps3 unmodified linesclass ASPPOperator(nn.Module):"""Asterisk Operator (ASPP) - Point-wise Parallel PropagationSimplified version WITHOUT neighbor gathering to reduce overfitting:- Optional dimensionality reduction for efficiency- Point-wise evolution: h_i^(t+1) = Ο(h_i^(t)) [NO neighbors]- Multi-step evolution for depth without added complexity- Dropout for regularizationArgs:hidden_size: Dimension of hidden states (input/output)aspp_hidden_dim: Internal dimension for ASPP (default: None, use hidden_size)num_steps: Number of evolution steps K (default: 2)dropout: Dropout rate for regularization (default: 0.1)"""def __init__(self, hidden_size: int, aspp_hidden_dim: Optional[int] = None, num_steps: int = 2, dropout: float = 0.1):super().__init__()self.hidden_size = hidden_sizeself.aspp_hidden_dim = aspp_hidden_dim or hidden_sizeself.num_steps = num_steps# Projection to lower dimension (if specified)self.use_projection = (self.aspp_hidden_dim != hidden_size)2 unmodified linesself.up_proj = nn.Linear(self.aspp_hidden_dim, hidden_size)self.proj_dropout = nn.Dropout(dropout)# Point-wise update function Ο - NO neighbor gathering# Much smaller: only processes current positionself.update_net = nn.Sequential(nn.Linear(self.aspp_hidden_dim, self.aspp_hidden_dim * 2),nn.SiLU(),nn.Dropout(dropout),nn.Linear(self.aspp_hidden_dim * 2, self.aspp_hidden_dim),1 unmodified line)# Learnable K-step parameter# sigmoid(1.0) β 0.73, giving k_steps β 1.5 β 2 steps initiallyself.k_logit = nn.Parameter(torch.tensor(1.0))# Learnable residual scale9 unmodified linesReturns:evolved_states: [batch_size, seq_len, hidden_size]"""# Project to lower dimension if neededif self.use_projection:h_t = self.down_proj(hidden_states)4 unmodified lines# Learnable number of stepsk_steps = max(1, int(torch.sigmoid(self.k_logit) * self.num_steps))# K-step point-wise evolution (NO neighbor gathering)for t in range(k_steps):# Apply point-wise update rule Οh_t_next = self.update_net(h_t)# Scaled residual connection for stabilityh_t = h_t + self.residual_scale * h_t_nexth_t = self.norm(h_t)19 unmodified lines4. Feed-forward network"""def __init__(self, config: LlamaConfig, layer_idx: int, aspp_hidden_dim: Optional[int] = None, aspp_num_steps: int = 2, aspp_dropout: float = 0.1):# Initialize parent LlamaDecoderLayersuper().__init__(config, layer_idx)2 unmodified lineshidden_size=config.hidden_size,aspp_hidden_dim=aspp_hidden_dim,num_steps=aspp_num_steps,dropout=aspp_dropout)# Gated fusion mechanism with dropout13 unmodified lineshidden_size=config.hidden_size,aspp_hidden_dim=aspp_hidden_dim,num_steps=aspp_num_steps,dropout=aspp_dropout)# Learnable flow scale (per-layer)87 unmodified linesAll layers use hybrid ASPP+Attention by default for maximum expressiveness."""def __init__(self, config: LlamaConfig, hybrid_layer_indices: Optional[List[int]] = None, aspp_hidden_dim: Optional[int] = None, aspp_num_steps: int = 2, aspp_dropout: float = 0.1):super().__init__(config)# Determine which layers to make hybrid (default: ALL layers)12 unmodified lineslayer_idx=idx,aspp_hidden_dim=aspp_hidden_dim,aspp_num_steps=aspp_num_steps,aspp_dropout=aspp_dropout)# Initialize weights9 unmodified linesconfig_class = AsteriskConfigdef __init__(self, config: AsteriskConfig, hybrid_layer_indices: Optional[List[int]] = None, aspp_hidden_dim: Optional[int] = None, aspp_num_steps: int = 2, aspp_dropout: float = 0.1):# Read all ASPP parameters from config if not explicitly providedif hybrid_layer_indices is None and hasattr(config, 'hybrid_layer_indices'):hybrid_layer_indices = config.hybrid_layer_indices3 unmodified linesaspp_num_steps = config.aspp_num_stepsif hasattr(config, 'aspp_dropout'):aspp_dropout = config.aspp_dropoutsuper().__init__(config)# Replace model with Asterisk versionself.model = AsteriskLlamaModel(config, hybrid_layer_indices, aspp_hidden_dim, aspp_num_steps, aspp_dropout)# Store hybrid layer info in config for serializationself.config.hybrid_layer_indices = hybrid_layer_indices9 unmodified linesaspp_hidden_dim: Optional[int] = None,aspp_num_steps: int = 2,aspp_dropout: float = 0.1,# Ο-flow parameterspi_flow: bool = False,pi_flow_steps: int = 1,10 unmodified linesaspp_hidden_dim: Internal dimension for ASPP (None = use model hidden_size)aspp_num_steps: Number of evolution steps K for ASPP (default: 2)aspp_dropout: Dropout rate for ASPP regularization (default: 0.1)pi_flow: Enable Ο-flow refinement step (default: False)pi_flow_steps: Number of flow refinement steps (default: 1)pi_flow_scale: Initial flow scale parameter (default: 0.2)10 unmodified linesaspp_hidden_dim=aspp_hidden_dim,aspp_num_steps=aspp_num_steps,aspp_dropout=aspp_dropout,pi_flow=pi_flow,pi_flow_steps=pi_flow_steps,pi_flow_scale=pi_flow_scale,1 unmodified line)# Create Asterisk modelasterisk_model = cls(asterisk_config, hybrid_layer_indices, aspp_hidden_dim, aspp_num_steps, aspp_dropout)# Transfer weights from base model (non-hybrid layers and embeddings)asterisk_model.load_state_dict(base_model.state_dict(), strict=False)print(f"β Converted base model to Asterisk architecture")print(f" Hybrid layers: {asterisk_model.model.hybrid_layer_indices}")aspp_dim_str = f"{aspp_hidden_dim}" if aspp_hidden_dim else f"{base_config.hidden_size} (full)"print(f" ASPP config: dim={aspp_dim_str}, steps={aspp_num_steps}, dropout={aspp_dropout}")if pi_flow:print(f" Ο-flow enabled: steps={pi_flow_steps}, scale={pi_flow_scale}, gate={pi_flow_use_gate}")
99 unmodified lines100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140128 unmodified lines26927027127227327427527627714 unmodified lines29229329429529629729829930030130230330430530630711 unmodified lines31932032132232332432532632732845 unmodified lines37437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241346 unmodified lines46046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950099 unmodified linesCombines ASPP operator with standard attentionComponents:- ASPP operator: Local structured reasoning with graph propagation- Standard attention: Global context- Gated fusion: Dynamic balancing"""```**ASPP Operator - Graph Propagation:**The ASPP operator converts the 1D sequence into a 2D grid and performs graph-based message passing:```Sequence [1, 2, 3, 4, ...] β 2D Grid:βββββ¬ββββ¬βββββ 1 β 2 β 3 ββββββΌββββΌββββ€β 4 β 5 β 6 ββββββ΄ββββ΄ββββ8-directional neighbors (default):β β ββ β ββ β β4-directional neighbors (optional):ββ β ββ```**Key features:**- **Configurable neighbors**: `aspp_num_neighbors` (default: 8)- **Learnable adjacency weights**: Each direction has a learnable weight- **K-step evolution**: Iterative message passing for `aspp_num_steps` (default: 4)- **Dynamic grid**: Grid dimensions adapt to sequence length (H β W β βseq_len)**Fusion mechanism:**```aspp_out = ASPP(hidden_states)128 unmodified lines### Training Configuration- **Starting Point**: Asterisk checkpoint (base ASPP-Attention model)- **Optimizer**: AdamW (lr=1e-4, weight_decay=0.1)- **Batch Size**: 4 per device, gradient accumulation=4 (effective batch=16)- **Epochs**: 2.5- **Scheduler**: Linear warmup (10% of steps)- **Mixed Precision**: bfloat16- **Gradient Checkpointing**: Enabled14 unmodified linesaspp_hidden_dim = 256 # Internal dimension (vs 576 model hidden_size)aspp_num_steps = 4 # Evolution steps for ASPPaspp_dropout = 0.2 # Regularizationaspp_num_neighbors = 8 # Number of semantic neighbors for graph propagation (default: 8)hybrid_layer_indices = None # All 30 layers```**Graph Propagation Neighbors:**- Default: 8-directional grid (ββββββββ)- Configurable: Can use fewer neighbors (e.g., 4-directional: ββββ)- The neighbor offsets are defined in a buffer, and only the first `num_neighbors` are used- Learnable adjacency weights adapt importance of each direction during training## Model Creation from Base Asterisk```python11 unmodified linesconfig.pi_flow_scale = 1.0config.pi_flow_use_gate = True# Optional: Configure ASPP graph propagation neighbors# config.aspp_num_neighbors = 8 # Default: 8 (full 8-directional grid)# config.aspp_num_neighbors = 4 # Alternative: 4 (cardinal directions only)# Create model with Ο-flowmodel = AsteriskForCausalLM(config)45 unmodified lines## Implementation Details### ASPP Graph Propagation ConfigurationThe ASPP operator supports configurable neighbor connectivity:```pythonclass ASPPOperator(nn.Module):def __init__(self,hidden_size: int,aspp_hidden_dim: Optional[int] = None,num_steps: int = 2,dropout: float = 0.1,num_neighbors: int = 8 # Configurable: 4, 8, etc.):# Neighbor offsets buffer (8 directions hardcoded)self.register_buffer('neighbor_offsets', torch.tensor([[-1, -1], [-1, 0], [-1, 1], # β β β[0, -1], [0, 1], # β β[1, -1], [1, 0], [1, 1] # β β β]))# Only first num_neighbors are usedself.num_neighbors = num_neighbors# Learnable adjacency weightsself.adjacency_weights = nn.Parameter(torch.randn(num_neighbors) * 0.1)```**Usage:**- `num_neighbors=8`: Full 8-directional connectivity (default)- `num_neighbors=4`: Cardinal directions only (ββββ)- The buffer always contains 8 offsets, but only the first `num_neighbors` are used- Adjacency weights are softmax-normalized for stability### Return Type HandlingCritical for Transformers compatibility:46 unmodified lines## Known Issues & Solutions### 1. Neighbor Count Configuration (Fixed in Latest Version)**Previous issue**: ASPP operator hardcoded 8 neighbors in reshape operations, causing errors when using different neighbor counts.**Solution**: Updated implementation to use `self.num_neighbors` dynamically:```python# Fixed: Dynamic neighbor countfor offset in self.neighbor_offsets[:self.num_neighbors]: # Only use first N# ...gather neighbors...# Fixed: Dynamic reshapeaggregated_neighbors = torch.sum(neighbors * adj_weights.view(1, 1, 1, self.num_neighbors, 1),dim=3)```Now supports any neighbor count (4, 8, etc.) without modification.### 2. Return Type Errors**Issue**: `AttributeError: 'tuple' object has no attribute 'dtype'`**Solution**: `HybridASPPAttentionLayer.forward()` must return `torch.Tensor` only, not tuple. This matches the `LlamaDecoderLayer` API in transformers 4.57.6.### 3. Ο-Flow in All Layers vs Final Layer**Initial approach**: Ο-flow only in final layer (limited expressiveness)**Current approach**: Ο-flow in all 30 hybrid layers for maximum refinement capability.### 4. Training StabilityΟ-Flow can cause instability with high learning rates. Use:- Lower learning rate (1e-4 recommended for stability)- Gradient clipping (max_norm=1.0)- Conservative initial flow scale (0.2-1.0)99 unmodified lines100101102103104105106107108109110111128 unmodified lines24024124224324424524624724814 unmodified lines26326426526626726826927027111 unmodified lines28328428528628728845 unmodified lines33433533633733833946 unmodified lines38638738838939039139239339439539639739839940040140240340440540640799 unmodified linesCombines ASPP operator with standard attentionComponents:- ASPP operator: Local structured reasoning- Standard attention: Global context- Gated fusion: Dynamic balancing"""```**Fusion mechanism:**```aspp_out = ASPP(hidden_states)128 unmodified lines### Training Configuration- **Starting Point**: Asterisk checkpoint (base ASPP-Attention model)- **Optimizer**: AdamW (lr=5e-4, weight_decay=0.1)- **Batch Size**: 2 per device, gradient accumulation=4 (effective batch=8)- **Epochs**: 2- **Scheduler**: Linear warmup (10% of steps)- **Mixed Precision**: bfloat16- **Gradient Checkpointing**: Enabled14 unmodified linesaspp_hidden_dim = 256 # Internal dimension (vs 576 model hidden_size)aspp_num_steps = 4 # Evolution steps for ASPPaspp_dropout = 0.2 # Regularizationhybrid_layer_indices = None # All 30 layers```## Model Creation from Base Asterisk```python11 unmodified linesconfig.pi_flow_scale = 1.0config.pi_flow_use_gate = True# Create model with Ο-flowmodel = AsteriskForCausalLM(config)45 unmodified lines## Implementation Details### Return Type HandlingCritical for Transformers compatibility:46 unmodified lines## Known Issues & Solutions### 1. Return Type Errors**Issue**: `AttributeError: 'tuple' object has no attribute 'dtype'`**Solution**: `HybridASPPAttentionLayer.forward()` must return `torch.Tensor` only, not tuple. This matches the `LlamaDecoderLayer` API in transformers 4.57.6.### 2. Ο-Flow in All Layers vs Final Layer**Initial approach**: Ο-flow only in final layer (limited expressiveness)**Current approach**: Ο-flow in all 30 hybrid layers for maximum refinement capability.### 3. Training StabilityΟ-Flow can cause instability with high learning rates. Use:- Lower learning rate (5e-4 vs 2e-5 for base)- Gradient clipping (max_norm=1.0)- Conservative initial flow scale (0.2-1.0)
12345{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>systemYou are a helpful AI assistant named Asterisk, trained by NoesisLab<|im_end|>' }}{% endif %}{{'<|im_start|>' + message['role'] + '' + message['content'] + '<|im_end|>' + ''}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant12345{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>systemYou are a helpful AI assistant named SmolLM, trained by Hugging Face<|im_end|>' }}{% endif %}{{'<|im_start|>' + message['role'] + '' + message['content'] + '<|im_end|>' + ''}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant
1 unmodified line23456789101 unmodified line"architectures": ["AsteriskForCausalLM"],"aspp_dropout": 0.1,"aspp_hidden_dim": 256,"aspp_num_neighbors": 8,"aspp_num_steps": 4,"attention_bias": false,"attention_dropout": 0.0,1 unmodified line234567891 unmodified line"architectures": ["AsteriskForCausalLM"],"aspp_dropout": 0.2,"aspp_hidden_dim": 256,"aspp_num_steps": 4,"attention_bias": false,"attention_dropout": 0.0,
123version https://git-lfs.github.com/spec/v1oid sha256:41550e1413295a2b5e02127758543c905650e9c834c6b53e382238f4021f3668size 396858360123version https://git-lfs.github.com/spec/v1oid sha256:cd3411332c19c27ac340b99a92d91e0b93f224b62fa3e0cccf7777b4e126b802size 381107624
123version https://git-lfs.github.com/spec/v1oid sha256:79668c78f13b1c865f88ffab2a80bc10c893e3262c29261ee8d447ec47b717d3size 6353123version https://git-lfs.github.com/spec/v1oid sha256:357a1e8bcbd247f80b9437f6d4dd9e81a29edbafaa6fea075a7380b6927773f4size 6353
.gitattributes+1
ARCHASTERISK.pngAdded

Large File Pointer Details
- SHA256: 4b5e7b1e822d358c4fc6de0882b23db7cec6d501af638d4550aae34f961168ef
- Pointer size: 132 Bytes
- Size of remote file: 5.71 MB
AsteriskForCausalLM.py+27-113
README.md+8-101
chat_template.jinja+1-1
config.json+1-2
model.safetensors+2-2
training_args.bin+1-1