ONNX Model Zoo

Maincode/Maincoder-1B-ONNX

By Maincode · ↓ 13 · ♥ 3 · Updated 2025-12-30

What's in this repo

This page lists the files in Maincode/Maincoder-1B-ONNX, including decoder_model.onnx, decoder_with_past_model.onnx.

  • 2 ONNX models (.onnx files)
  • 14 files, including 6 .json, 2 .onnx, 2 .onnx_data, 1 .md, 1 .jinja, 1 .txt
  • Last updated 2025-12-30

ONNX files

File Size Download
decoder_model.onnx — Download
decoder_with_past_model.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

Maincoder-1B-ONNX is the ONNX-optimized version of Maincoder-1B, a code-focused language model optimized for code generation and completion tasks. This version enables fast inference using ONNX Runtime in Python and runs directly in the browser with Transformers.js.

Key Features

  • ONNX Optimized: Efficient inference with ONNX Runtime and KV-cache support
  • Cross-Platform: Run in Python, Node.js, or directly in the browser
  • Code Generation: Optimized for Python code completion and generation tasks.
  • Compact Size: 1 billion parameters, lightweight enough to run on consumer hardware.
  • SOTA Performance: State-of-the-art performance on Python coding benchmarks HumanEval, HumanEval+ and MBPP+.

Benchmark Results

Benchmark Performance Across Baseline LLMs

Model HumanEval HumanEval+ MBPP+ MMLU GSM8K
Maincode/Maincoder-1B 0.7622 0.7256 0.7090 0.3054 0.2976
deepseek-ai/deepseek-coder-1.3b-instruct 0.5610 0.5305 0.6217 0.2705 0.0413
HuggingFaceTB/SmolLM3-3B 0.5366 0.5000 0.6799 0.5928 0.5505
Qwen/Qwen2.5-Coder-1.5B-Instruct 0.4634 0.4451 0.6561 0.4984 0.4944
Qwen/Qwen3-1.7B 0.4024 0.3780 0.5582 0.5571 0.6865

Model Overview

Maincoder uses a modern transformer decoder architecture with:

  • Rotary Position Embeddings: With theta of 1,000,000.
  • RMSNorm: Pre-normalization for stable training.
  • Grouped Query Attention: 4:1 ratio of query to key-value heads.
  • QK Normalization: RMSNorm applied to attention queries and keys.
  • SwiGLU MLP: Gated linear units with SiLU activation.
Attribute Value
Parameters 1B
Hidden Size 1536
Layers 32
Attention Heads 16 (4 KV heads)
Head Dimension 96
Vocabulary Size 151,936
Context Length 2,048
Format ONNX

Usage

Python (ONNX Runtime)

Installation

pip install optimum[onnxruntime] transformers

For GPU acceleration:

pip install optimum[onnxruntime-gpu]

Quick Start

from optimum.onnxruntime import ORTModelForCausalLM
from transformers import AutoTokenizer

# Load the ONNX model with KV-cache support
model = ORTModelForCausalLM.from_pretrained(
    "Maincode/Maincoder-1B-ONNX",
    file_name="decoder_with_past_model.onnx",
    use_cache=True
)

# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained("Maincode/Maincoder-1B-ONNX")

# Code completion example
prompt = '''def fibonacci(n: int) -> int:
    """Return the n-th Fibonacci number."""
'''

inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
    **inputs,
    max_new_tokens=128,
    temperature=0.2,
    do_sample=True,
    pad_token_id=tokenizer.eos_token_id
)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

GPU Acceleration

from optimum.onnxruntime import ORTModelForCausalLM

model = ORTModelForCausalLM.from_pretrained(
    "Maincode/Maincoder-1B-ONNX",
    use_cache=True,
    file_name="decoder_with_past_model.onnx",
    provider="CUDAExecutionProvider"
)

JavaScript (Transformers.js)

Installation

npm install @huggingface/transformers

Node.js

import { AutoModelForCausalLM, AutoTokenizer } from '@huggingface/transformers';

// Load the tokenizer and model
const tokenizer = await AutoTokenizer.from_pretrained('Maincode/Maincoder-1B-ONNX');
const model = await AutoModelForCausalLM.from_pretrained('Maincode/Maincoder-1B-ONNX', {
    subfolder: '.',
    model_file_name: 'decoder_with_past_model',
    use_external_data_format: true,

});

// Code completion example
const prompt = `def fibonacci(n: int) -> int:
    """Return the n-th Fibonacci number."""
`;

const inputs = await tokenizer(prompt, { return_tensors: 'pt' });

const outputs = await model.generate({
    input_ids: inputs.input_ids,
    attention_mask: inputs.attention_mask,
    max_new_tokens: 128,
    temperature: 0.2,
    do_sample: true,
});

const decoded = tokenizer.decode(outputs[0], { skip_special_tokens: true });
console.log(decoded);

Code Completion Examples

# Function completion
prompt = '''def quicksort(arr: list) -> list:
    """Sort a list using the quicksort algorithm."""
'''

# Class completion
prompt = '''class BinarySearchTree:
    """A binary search tree implementation."""
    
    def __init__(self):
'''

# Algorithm implementation
prompt = '''def dijkstra(graph: dict, start: str, end: str) -> tuple:
    """Find the shortest path using Dijkstra's algorithm.
    
    Args:
        graph: Adjacency list representation of the graph
        start: Starting node
        end: Target node
    
    Returns:
        Tuple of (distance, path)
    """
'''

Additional Notes

Limitations

  • Context length limited to 2,048 tokens

  • Primarily optimized for Python, performance may vary on other languages

  • May generate code with bugs or security issues - always review generated code

  • Browser performance depends on device capabilities

    Disclaimer: This model has not undergone any alignment or safety tuning (e.g., RLHF/RLAIF, DPO, or safety fine-tuning). Outputs may be unsafe or biased. Please use appropriate safeguards and evaluate carefully for your use case.

License

This model is released under the Apache 2.0 License.

Citation

@misc{maincoder2025,
  title        = {Maincoder-1B: A High-Performance 1B Parameter Coding Model},
  author       = {Maincode Team},
  year         = {2025},
  organization = {Maincode},
  howpublished = {\url{https://huggingface.co/Maincode/Maincoder-1B}}
}

Related Models

Contact

For questions, issues, or collaboration inquiries, please visit Maincode.

Model info

text-generation transformers.js
transformers.js onnx llama text-generation code python maincoder code-generation reinforcement-learning mcpo conversational en
↓ 13 ♥ 3

Created: 2025-12-30

Updated: 2025-12-30

View on Hugging Face

Files (14)

.gitattributes
README.md
added_tokens.json
chat_template.jinja
config.json
decoder_model.onnx ONNX
decoder_model.onnx_data
decoder_with_past_model.onnx ONNX
decoder_with_past_model.onnx_data
merges.txt
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.json

Related models