Text Generation
Transformers
Safetensors
English
maincoder
feature-extraction
code
python
code-generation
reinforcement-learning
mcpo
conversational
custom_code
Instructions to use Maincode/Maincoder-1B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Maincode/Maincoder-1B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Maincode/Maincoder-1B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Maincode/Maincoder-1B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Maincode/Maincoder-1B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Maincode/Maincoder-1B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Maincode/Maincoder-1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Maincode/Maincoder-1B
- SGLang
How to use Maincode/Maincoder-1B 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 "Maincode/Maincoder-1B" \ --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": "Maincode/Maincoder-1B", "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 "Maincode/Maincoder-1B" \ --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": "Maincode/Maincoder-1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Maincode/Maincoder-1B with Docker Model Runner:
docker model run hf.co/Maincode/Maincoder-1B
| # coding=utf-8 | |
| # Copyright 2025 Maincode. All rights reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| """Maincoder model configuration.""" | |
| from typing import Optional | |
| from transformers.configuration_utils import PretrainedConfig | |
| from transformers.utils import logging | |
| logger = logging.get_logger(__name__) | |
| class MaincoderConfig(PretrainedConfig): | |
| r""" | |
| Configuration class for Maincoder model. | |
| Args: | |
| vocab_size (`int`, *optional*, defaults to 151936): | |
| Vocabulary size of the Maincoder model. | |
| hidden_size (`int`, *optional*, defaults to 1536): | |
| Dimension of the hidden representations. | |
| intermediate_size (`int`, *optional*, defaults to 4096): | |
| Dimension of the MLP intermediate representations. | |
| intermediate_size_mlp (`int`, *optional*, defaults to 4096): | |
| Dimension of the MLP representations (same as intermediate_size for dense models). | |
| num_hidden_layers (`int`, *optional*, defaults to 32): | |
| Number of hidden layers in the Transformer decoder. | |
| num_attention_heads (`int`, *optional*, defaults to 16): | |
| Number of attention heads for each attention layer. | |
| num_key_value_heads (`int`, *optional*, defaults to 4): | |
| Number of key-value heads for Grouped Query Attention (GQA). | |
| head_dim (`int`, *optional*, defaults to 96): | |
| Dimension of each attention head. | |
| hidden_act (`str`, *optional*, defaults to `"silu"`): | |
| The activation function in the MLP. | |
| max_position_embeddings (`int`, *optional*, defaults to 2048): | |
| Maximum sequence length the model can handle. | |
| initializer_range (`float`, *optional*, defaults to 0.02): | |
| Standard deviation for weight initialization. | |
| rms_norm_eps (`float`, *optional*, defaults to 1e-05): | |
| Epsilon for RMS normalization layers. | |
| use_cache (`bool`, *optional*, defaults to `True`): | |
| Whether to use key-value cache for generation. | |
| pad_token_id (`int`, *optional*, defaults to 151643): | |
| Padding token id. | |
| bos_token_id (`int`, *optional*): | |
| Beginning of sequence token id. | |
| eos_token_id (`int`, *optional*, defaults to 151643): | |
| End of sequence token id. | |
| tie_word_embeddings (`bool`, *optional*, defaults to `True`): | |
| Whether to tie input and output embeddings. | |
| rope_theta (`float`, *optional*, defaults to 1000000.0): | |
| Base period for RoPE embeddings. | |
| rope_scaling (`Dict`, *optional*): | |
| RoPE scaling configuration for extended context. | |
| attention_dropout (`float`, *optional*, defaults to 0.0): | |
| Dropout probability for attention weights. | |
| use_qk_norm (`bool`, *optional*, defaults to `True`): | |
| Whether to apply RMS normalization to query and key. | |
| Example: | |
| ```python | |
| >>> from configuration_maincoder import MaincoderConfig | |
| >>> from modelling_maincoder import MaincoderForCausalLM | |
| >>> config = MaincoderConfig() | |
| >>> model = MaincoderForCausalLM(config) | |
| ``` | |
| """ | |
| model_type = "maincoder" | |
| keys_to_ignore_at_inference = ["past_key_values"] | |
| def __init__( | |
| self, | |
| vocab_size: int = 151936, | |
| hidden_size: int = 1536, | |
| intermediate_size: int = 4096, | |
| intermediate_size_mlp: int = 4096, | |
| num_hidden_layers: int = 32, | |
| num_attention_heads: int = 16, | |
| num_key_value_heads: Optional[int] = 4, | |
| head_dim: Optional[int] = 96, | |
| hidden_act: str = "silu", | |
| max_position_embeddings: int = 2048, | |
| initializer_range: float = 0.02, | |
| rms_norm_eps: float = 1e-5, | |
| use_cache: bool = True, | |
| pad_token_id: Optional[int] = 151643, | |
| bos_token_id: Optional[int] = None, | |
| eos_token_id: int = 151643, | |
| tie_word_embeddings: bool = True, | |
| rope_theta: float = 1000000.0, | |
| rope_scaling: Optional[dict] = None, | |
| attention_dropout: float = 0.0, | |
| use_qk_norm: bool = True, | |
| **kwargs, | |
| ): | |
| self.vocab_size = vocab_size | |
| self.hidden_size = hidden_size | |
| self.intermediate_size = intermediate_size | |
| self.intermediate_size_mlp = intermediate_size_mlp | |
| self.num_hidden_layers = num_hidden_layers | |
| self.num_attention_heads = num_attention_heads | |
| self.max_position_embeddings = max_position_embeddings | |
| self.initializer_range = initializer_range | |
| self.rms_norm_eps = rms_norm_eps | |
| self.use_cache = use_cache | |
| self.rope_theta = rope_theta | |
| self.rope_scaling = rope_scaling | |
| self.attention_dropout = attention_dropout | |
| self.use_qk_norm = use_qk_norm | |
| self.hidden_act = hidden_act | |
| # GQA configuration | |
| self.num_key_value_heads = num_key_value_heads if num_key_value_heads is not None else num_attention_heads | |
| self.head_dim = head_dim if head_dim is not None else self.hidden_size // self.num_attention_heads | |
| super().__init__( | |
| pad_token_id=pad_token_id, | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| tie_word_embeddings=tie_word_embeddings, | |
| **kwargs, | |
| ) | |
| __all__ = ["MaincoderConfig"] | |