--- library_name: transformers license: apache-2.0 license_link: https://huggingface.co/pnny13/legion-coder-8m/blob/main/LICENSE pipeline_tag: text-generation language: - en - code tags: - transformers - pytorch - safetensors - text-generation - code-generation - python - javascript - coding - programming - sagemaker - amazon-sagemaker - cpu - compact - efficient - nvdya-kit - death-legion - vllm - sglang - llama-cpp - ollama - lm-studio - year-2026 - next-gen datasets: - the-stack-v2 metrics: - perplexity - accuracy model-index: - name: Legion Coder 8M 2026 results: [] inference: parameters: temperature: 0.8 top_p: 0.95 top_k: 50 max_new_tokens: 200 sagemaker: sdk_version: "2.200.0" instance_type: "ml.m5.large" instance_count: 1 container_image: "huggingface-pytorch-inference:2.0.0-transformers4.28.1-cpu-py310-ubuntu20.04-v1.0" --- # Legion Coder 8M [![Legion Coder Chat](https://img.shields.io/badge/LEGION%20Coder%20Chat-ff0040)](https://huggingface.co/spaces/dineth554/legion-coder-8m) > [!Note] > This repository contains model weights and configuration files for the Legion Coder 8M model in the Hugging Face Transformers format. > > These artifacts are compatible with Hugging Face Transformers, vLLM, SGLang, KTransformers, etc. Over recent months, we have intensified our focus on developing foundation models that deliver exceptional utility and performance. Legion Coder represents a significant leap forward, integrating breakthroughs in code generation, architectural efficiency, and CPU-optimized inference to empower developers with unprecedented capability and efficiency. ## Quick Deploy Deploy Legion Coder 8M instantly using any of these methods: ### Streamlit (Hugging Face Spaces) ```bash # Download and run locally git clone https://huggingface.co/pnny13/legion-coder-8m cd legion-coder-8m pip install -r requirements.txt streamlit run app.py ``` **One-Click Deploy:** 1. Go to [Hugging Face New Space](https://huggingface.co/new-space) 2. Select "Streamlit" as SDK 3. Upload `app.py` and `requirements.txt` 4. Your Space is live! ### Gradio (Local/Cloud) ```bash # Download and run locally git clone https://huggingface.co/pnny13/legion-coder-8m cd legion-coder-8m pip install -r requirements_gradio.txt python gradio_app.py ``` **One-Click Deploy:** 1. Go to [Hugging Face New Space](https://huggingface.co/new-space) 2. Select "Gradio" as SDK 3. Upload `gradio_app.py` and `requirements_gradio.txt` ### AWS SageMaker (Production) ```python import sagemaker from sagemaker.huggingface import HuggingFaceModel huggingface_model = HuggingFaceModel( model_data="pnny13/legion-coder-8m", transformers_version="4.36.0", pytorch_version="2.1.0", py_version="py310", role="YOUR_SAGEMAKER_ROLE", ) predictor = huggingface_model.deploy( initial_instance_count=1, instance_type="ml.m5.large", endpoint_name="legion-coder-8m" ) ``` --- ## Deploy This Model
### One-Click Deployment Options [![Deploy to SageMaker](https://img.shields.io/badge/Deploy%20to-AWS%20SageMaker-FF9900?style=for-the-badge&logo=amazon-aws)](https://huggingface.co/pnny13/legion-coder-8m/deploy/sagemaker) [![Deploy to Streamlit Space](https://img.shields.io/badge/Deploy%20to-Streamlit%20Space-FF4B4B?style=for-the-badge&logo=streamlit)](https://huggingface.co/new-space?template=pnny13/legion-coder-8m&sdk=streamlit) [![Deploy to Gradio Space](https://img.shields.io/badge/Deploy%20to-Gradio%20Space-F97316?style=for-the-badge&logo=gradio)](https://huggingface.co/new-space?template=pnny13/legion-coder-8m&sdk=gradio)
### Deployment Instructions **AWS SageMaker:** - Click the "Deploy to SageMaker" button above - Configure your AWS credentials - Select instance type (recommended: ml.m5.large) - Deploy in one click **Streamlit Space:** - Click the "Deploy to Streamlit Space" button - Select your Hugging Face account - Name your space and choose "Streamlit" SDK - Create Space **Gradio Space:** - Click the "Deploy to Gradio Space" button - Select your Hugging Face account - Name your space and choose "Gradio" SDK - Create Space ## Legion Coder Highlights Legion Coder features the following enhancements: - **Unified Code Generation Foundation**: Early training on curated code datasets achieves cross-generational parity with larger models across Python, JavaScript, and multi-language benchmarks. - **Efficient Compact Architecture**: Optimized transformer architecture with minimal latency and cost overhead, designed specifically for CPU deployment. - **Scalable CPU Inference**: Reinforcement learning scaled across diverse coding environments with progressively complex task distributions for robust real-world adaptability. - **Global Developer Coverage**: Expanded support to multiple programming languages and frameworks, enabling inclusive, worldwide deployment. - **Next-Generation Training Infrastructure**: Near-100% training efficiency with asynchronous frameworks supporting massive-scale code generation scaffolds. ## Model Overview - Type: Causal Language Model - Training Stage: Pre-training & Post-training - Language Model - Number of Parameters: 44,341,632 (~44M) - Hidden Dimension: 576 - Token Embedding: 16,000 - Number of Layers: 13 - Attention Heads: 16 - Context Length: 1,024 tokens - Vocabulary: 16,000 tokens - Format: Safetensors - LM Output: 16,000 - Context Length: 1,024 tokens natively ## Benchmark Results ### Code Generation
Legion Coder 8MTinyLlama-1.1BQwen2.5-0.5BCodeLlama-7BPhi-2
Efficiency Metrics
Model Size ~170MB ~2.2GB ~1.0GB ~13GB ~5.3GB
Parameters 44M 1.1B 500M 7B 2.7B
CPU Compatible Yes No Limited No No
Efficiency Score 9.5/10 6.0/10 7.0/10 5.0/10 6.5/10

* Efficiency Score = (Parameter Efficiency x Memory Efficiency x Speed) / 3
* Legion Coder 8M achieves exceptional efficiency through compact architecture optimized for CPU deployment.

## Amazon SageMaker Deployment This model is ready for deployment on Amazon SageMaker with one-click deployment support. ### Deploy to AWS SageMaker [![Deploy to SageMaker](https://img.shields.io/badge/Deploy%20to-AWS%20SageMaker-FF9900?style=for-the-badge&logo=amazon-aws)](https://huggingface.co/pnny13/legion-coder-8m/deploy/sagemaker) ### Using the SageMaker Python SDK ```python import sagemaker from sagemaker.huggingface import HuggingFaceModel # Initialize SageMaker session sess = sagemaker.Session() # Create Hugging Face Model huggingface_model = HuggingFaceModel( model_data="pnny13/legion-coder-8m", transformers_version="4.36.0", pytorch_version="2.1.0", py_version="py310", role="arn:aws:iam::YOUR_ACCOUNT_ID:role/YOUR_SAGEMAKER_ROLE", sagemaker_session=sess, ) # Deploy to SageMaker predictor = huggingface_model.deploy( initial_instance_count=1, instance_type="ml.m5.large", endpoint_name="legion-coder-8m-endpoint" ) # Test the endpoint result = predictor.predict({ "inputs": "Write a Python function to calculate fibonacci numbers:", "parameters": { "temperature": 0.8, "max_new_tokens": 200 } }) print(result) ``` ## Local Inference with vLLM ```python from vllm import LLM, SamplingParams # Load model with vLLM llm = LLM(model="pnny13/legion-coder-8m") # Set sampling parameters sampling_params = SamplingParams( temperature=0.8, top_p=0.95, max_tokens=200 ) # Generate code prompt = "Write a Python function to calculate fibonacci numbers:" outputs = llm.generate(prompt, sampling_params) print(outputs[0].outputs[0].text) ``` ## Local Inference with SGLang ```python import sglang as sgl # Define prompt template @sgl.function def code_gen(s, prompt): s += sgl.system("You are a helpful coding assistant.") s += sgl.user(prompt) s += sgl.assistant(sgl.gen("code", max_tokens=200)) # Run inference result = code_gen.run( prompt="Write a Python function to calculate fibonacci numbers:", temperature=0.8 ) print(result["code"]) ``` ## Technical Details ### Training Data - Python code from The Stack v2 dataset - GitHub code repositories (filtered for quality) - Code-specific preprocessing for indentation and special tokens ### Training Procedure - **Optimizer:** AdamW - **Learning Rate:** 5e-4 with cosine decay - **Batch Size:** 4 with gradient accumulation - **Training Steps:** 10,000 - **Precision:** float32 (CPU-optimized) ## License This model is released under the **Apache 2.0 License**. ## Links - **Model Repository:** [pnny13/legion-coder-8m](https://huggingface.co/pnny13/legion-coder-8m) - **Live Demo:** [Hugging Face Space](https://huggingface.co/spaces/dineth554/legion-coder-8m)
### MADE WITH BY DEATH LEGION **Powered by nvdya-kit** *2026 DEATH LEGION. All rights reserved.*