Text Generation
Transformers
Safetensors
English
Arabic
quasar_long
silx-ai
quasar-preview
quasar
foundation-model
Mixture of Experts
18b
2b-active
long-context
bittensor
sn24
decentralized-training
distillation
hybrid-transformer
loop-transformer
safe-nope
drope
conversational
custom_code
Instructions to use mainline777/base_IIXIV with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mainline777/base_IIXIV with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mainline777/base_IIXIV", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("mainline777/base_IIXIV", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mainline777/base_IIXIV with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mainline777/base_IIXIV" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mainline777/base_IIXIV", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mainline777/base_IIXIV
- SGLang
How to use mainline777/base_IIXIV 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 "mainline777/base_IIXIV" \ --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": "mainline777/base_IIXIV", "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 "mainline777/base_IIXIV" \ --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": "mainline777/base_IIXIV", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use mainline777/base_IIXIV with Docker Model Runner:
docker model run hf.co/mainline777/base_IIXIV
| import math | |
| import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| from einops import rearrange | |
| def fft_conv(u, k, dropout_mask, gelu=True, k_rev=None): | |
| seqlen = u.shape[-1] | |
| fft_size = 2 * seqlen | |
| k_f = torch.fft.rfft(k, n=fft_size) / fft_size | |
| if k_rev is not None: | |
| k_rev_f = torch.fft.rfft(k_rev, n=fft_size) / fft_size | |
| k_f = k_f + k_rev_f.conj() | |
| u_f = torch.fft.rfft(u.to(dtype=k.dtype), n=fft_size) | |
| if len(u.shape) > 3: | |
| k_f = k_f.unsqueeze(1) | |
| y = torch.fft.irfft(u_f * k_f, n=fft_size, norm="forward")[..., :seqlen] | |
| out = y + u | |
| if gelu: | |
| out = F.gelu(out) | |
| if dropout_mask is not None: | |
| return (out * rearrange(dropout_mask, "b H -> b H 1")).to(dtype=u.dtype) | |
| else: | |
| return out.to(dtype=u.dtype) | |
| class LongConvolution(nn.Module): | |
| """ | |
| LongConvolution applies a convolution operation on the input tensor using a fixed | |
| filter of length max_len. | |
| The filter is learned during training and is applied using FFT convolution. | |
| Args: | |
| hidden_size (int): The number of expected features in the input and output. | |
| max_len (int): The maximum sequence length. | |
| Returns: | |
| y: [batch_size, seq_len, hidden_size] tensor | |
| """ | |
| def __init__( | |
| self, | |
| hidden_size: int, | |
| max_len: int, | |
| **kwargs, | |
| ): | |
| """ | |
| Initializes the LongConvolution module. | |
| Args: | |
| hidden_size (int): The number of expected features in the input and output. | |
| max_len (int): The maximum sequence length. | |
| """ | |
| super().__init__() | |
| self.hidden_size = hidden_size | |
| self.filter = nn.Parameter(torch.randn(self.hidden_size, max_len), requires_grad=True) | |
| def forward(self, x: torch.Tensor, *args, **kwargs): | |
| """ | |
| Applies the LongConvolution operation on the input tensor. | |
| Args: | |
| x: [batch_size, seq_len, hidden_size] tensor | |
| Returns: | |
| y: [batch_size, seq_len, hidden_size] tensor | |
| """ | |
| x = x.transpose(1, 2) | |
| y = fft_conv(x, self.filter, dropout_mask=None, gelu=False) | |
| y = y.transpose(1, 2) | |
| return y.to(dtype=x.dtype) | |
| class PositionalEmbedding(nn.Module): | |
| def __init__(self, emb_dim: int, seq_len: int, **kwargs): | |
| """Complex exponential positional embeddings for implicit long convolution filters.""" | |
| super().__init__() | |
| self.seq_len = seq_len | |
| # The time embedding fed to the filteres is normalized so that t_f = 1 | |
| t = torch.linspace(0, 1, self.seq_len)[None, :, None] # 1, L, 1 | |
| if emb_dim > 1: | |
| bands = (emb_dim - 1) // 2 | |
| # To compute the right embeddings we use the "proper" linspace | |
| t_rescaled = torch.linspace(0, seq_len - 1, seq_len)[None, :, None] | |
| w = 2 * math.pi * t_rescaled / seq_len # 1, L, 1 | |
| f = torch.linspace(1e-4, bands - 1, bands)[None, None] | |
| z = torch.exp(-1j * f * w) | |
| z = torch.cat([t, z.real, z.imag], dim=-1) | |
| self.z = nn.Parameter(z, requires_grad=False) | |
| def forward(self, L): | |
| return self.z[:, :L] | |
| class ImplicitLongConvolution(nn.Module): | |
| """ | |
| Long convolution with implicit filter parameterized by an MLP. | |
| Args: | |
| hidden_size (int): | |
| The number of expected features in the input and output. | |
| max_len (int): | |
| The maximum sequence length. | |
| d_emb (Optional[int]): | |
| The dimension of the positional embeddings. Must be odd and greater or equal to 3 (time, sine and cosine). | |
| Defaults to 3. | |
| d_hidden (Optional[int]): | |
| The number of features in the hidden layer of the MLP. Defaults to 16. | |
| Attributes: | |
| pos_emb (`PositionalEmbedding`): The positional embedding layer. | |
| mlp (`nn.Sequential`): The MLP that parameterizes the implicit filter. | |
| """ | |
| def __init__( | |
| self, | |
| hidden_size: int, | |
| max_len: int, | |
| d_emb: int = 3, | |
| d_hidden: int = 16, | |
| **kwargs, | |
| ): | |
| """ | |
| Long convolution with implicit filter parameterized by an MLP. | |
| """ | |
| super().__init__() | |
| self.hidden_size = hidden_size | |
| self.d_emb = d_emb | |
| assert ( | |
| d_emb % 2 != 0 and d_emb >= 3 | |
| ), "d_emb must be odd and greater or equal to 3 (time, sine and cosine)" | |
| self.pos_emb = PositionalEmbedding(d_emb, max_len) | |
| # final linear layer | |
| self.mlp = nn.Sequential( | |
| nn.Linear(d_emb, d_hidden), | |
| torch.nn.ReLU(), | |
| nn.Linear(d_hidden, hidden_size), | |
| ) | |
| def filter(self, seq_len: int, *args, **kwargs): | |
| return self.mlp(self.pos_emb(seq_len)).transpose(1, 2) | |
| def forward(self, x: torch.Tensor, *args, **kwargs): | |
| """ | |
| Args: | |
| x: [batch_size, seq_len, hidden_size] tensor | |
| Returns: | |
| y: [batch_size, seq_len, hidden_size] tensor | |
| """ | |
| x = x.transpose(1, 2) | |
| k = self.filter(x.shape[-1]) | |
| y = fft_conv(x, k, dropout_mask=None, gelu=False) | |
| y = y.transpose(1, 2) | |
| return y.to(dtype=x.dtype) | |