--- license: apache-2.0 language: - en - code library_name: transformers pipeline_tag: text-generation tags: - code - python - javascript - html - c - cpp - fim - slm --- # SweepCoder-300M SweepCoder-300M is a ~304M parameter code model trained from scratch on 45B tokens, focused specifically on **Python, JavaScript, HTML, C, and C++**. Most small models try to do a bit of everything—general chat, trivia, and dozens of programming languages—which leaves very little capacity for writing clean, reliable code. For this release, I kept the parameter count compact and dedicated the entire training run to five core languages so it can run fast locally while still handling real syntax, types, and boilerplate well. --- ## Specs - **Developer:** [JP-AI-2026](https://huggingface.co) - **Parameters:** ~304M (`bf16`, tied embeddings) - **Architecture:** Llama-style decoder (24 layers, `d_model=896`, `intermediate_size=2432`, SwiGLU, RMSNorm) - **Attention:** Grouped-Query Attention (14 Q heads, 2 KV heads, `head_dim=64`) - **Context Length:** 4,096 tokens (RoPE `theta=100000`) - **Vocab:** 49,152 tokens (includes ``, ``, ``) - **License:** Apache 2.0 --- ## How It Was Trained The model was pre-trained from scratch on **45 billion tokens** across four main buckets: - **Filtered Code:** Clean, educational open-source code across Python, C++, JavaScript, C, and HTML. - **Syntax-Verified Synthetic Example:** Self-contained coding problems, tutorials, and bug-fix pairs. Every synthetic sample was passed through language parsers/compilers (`ast`, `node`, `gcc`/`g++`) before training to filter out broken syntax. - **Math & Logic:** Step-by-step math and algorithmic reasoning data to help with indexing, loops, and control flow. - **Technical Docs:** Computer science reference text and documentation so the model handles comments and docstrings naturally. Training followed a Warmup-Stable-Decay (WSD) schedule using Muon for 2D weight matrices and AdamW for embeddings/norms, with a final annealing phase weighted toward the cleanest code examples. Around 30% of code files were formatted with Fill-in-the-Middle (FIM) during pre-training so it works out of the box for inline autocomplete. --- ## Usage ### Code Continuation ```python import torch from transformers import AutoModelForCausalLM, AutoTokenizer model_id = "JP-AI-2026/SweepCoder-300M" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype=torch.bfloat16, device_map="auto", ) prompt = "def merge_sorted_lists(a: list[int], b: list[int]) -> list[int]:\n" inputs = tokenizer(prompt, return_tensors="pt").to(model.device) out = model.generate( **inputs, max_new_tokens=128, do_sample=False, pad_token_id=tokenizer.eos_token_id, ) print(tokenizer.decode(out[0], skip_special_tokens=True)) ``` ### Fill-in-the-Middle (FIM) ```python prefix = "int factorial(int n) {\n if (n <= 1) return 1;\n " suffix = "\n}" prompt = f"{prefix}{suffix}" inputs = tokenizer(prompt, return_tensors="pt").to(model.device) out = model.generate( **inputs, max_new_tokens=64, do_sample=False, pad_token_id=tokenizer.eos_token_id, ) print(tokenizer.decode(out[0], skip_special_tokens=False)) ``` --- ## What to Expect **Good for:** - Fast local IDE autocomplete (FIM) on CPU or low-VRAM GPUs - Writing standalone functions, standard algorithms, and data structures - C/C++ boilerplate, Python scripting, and basic HTML/JS DOM logic **Limitations:** - At 304M parameters, it works best on short-to-medium snippets (~20–120 lines). On long multi-file tasks, it will lose track of context. - Trained strictly on Python, JS, HTML, C, and C++—don't expect strong results on other languages or general chat. - Always test generated code before using it in real projects. --- ## Citation ```bibtex @misc{sweepcoder300m_2026, title = {SweepCoder-300M}, author = {JP-AI-2026}, year = {2026}, url = {https://huggingface.co/SweepCoder-300M} } ```