--- license: apache-2.0 language: - en - fr tags: - code-generation - python - chain-of-thought - sparse-transformer - multilingual - amforge - sparsemind library_name: pytorch pipeline_tag: text-generation inference: false model-index: - name: cofos_v2 results: - task: type: text-generation name: Python code generation metrics: - type: real_syntax_valid value: 63.0 name: Real Python syntax validity (held-out) --- # Cofos v2 Multilingual Python Code Assistant **Cofos v2** is a 522M-parameter code assistant specialized in Python, with native French/English bilingual support and optional chain-of-thought reasoning. It is the second iteration in the Cofos series by **AMEFORGE**, built on the proprietary **SparseMind** architecture. This model is designed to produce syntactically correct, executable Python code from natural-language instructions in either French or English, with the ability to emit its reasoning before the code when requested. --- ## Model Summary | Field | Value | |---|---| | **Developer** | AMEFORGE | | **Architecture** | SparseMind v15 (proprietary) | | **Parameters** | 522M | | **Context length** | 2048 tokens | | **Vocabulary** | 16,384 (custom nexusBPE) | | **Languages** | French, English | | **Primary task** | Python code generation | | **License** | Apache 2.0 | | **Status** | Active development | --- ## Intended Use ### Primary use cases - **Python code generation** from natural-language prompts (function specs, class designs, algorithm requests) - **Bilingual coding assistance** for developers working in French or English - **Chain-of-thought reasoning** when reasoning steps are useful before the code (toggle via prompt format) - Integration as a lightweight code assistant in development pipelines where larger models are impractical ### Out-of-scope This model is **not designed for**: - General conversation or open-ended dialogue - Languages other than French and English - Code in languages other than Python (some JavaScript and Rust tokens are present in the vocabulary but the model has not been trained for general production in those languages) - Tasks requiring large-context reasoning (>2048 tokens) - Factual knowledge retrieval, scientific reasoning, or creative writing Cofos v2 is a specialized coding tool. Use it for what it was built for and pair it with appropriate tools for everything else. --- ## Performance Evaluated on a held-out set of real Python instruction prompts (no overlap with training data). | Metric | Value | |---|---| | Real-syntax-valid (held-out, n=100) | **63.0%** | | Validation loss | 3.08 | | Model size (on disk) | ~2.1 GB (fp32) | The model has been observed to generate syntactically valid Python with reasonable semantic alignment to short-to-medium instructions. Performance degrades with very long contexts (>1500 tokens) and on instructions that combine multiple distinct subtasks. ## External benchmark Evaluated on 50 diverse Python prompts (40 EN + 10 FR), comparing against similarly-sized open models: | Model | Size | Valid Python | Sem. correct | |---|---:|---:|---:| | Cofos v2 (ours) | 522M | 42% | 76%* | | Qwen2.5-Coder-0.5B | 500M | 84% | 91% | | SmolLM2-360M | 360M | 92% | 94% | | Qwen2.5-0.5B | 500M | 74% | 100% | *Semantic correct = % of test cases passed on the subset of prompts with verifiable test cases (10 prompts, 30 test cases). Computed only on valid- syntax generations. Cofos v2 emits substantially fewer syntactically-valid generations than comparable open models, but its valid generations show high semantic accuracy (76%). The gap reflects Cofos v2's much smaller training corpus (~5000 distilled samples + 16000 real Python instructions vs trillion-token corpora for the comparison models). Improvement is expected via downstream fine-tuning (cofos_logo). --- ## Usage ### Loading ```python from huggingface_hub import hf_hub_download import torch # Download checkpoint checkpoint_path = hf_hub_download(repo_id="AMFORGE/cofos_v2", filename="cofos_model.pt") tokenizer_path = hf_hub_download(repo_id="AMFORGE/cofos_v2", filename="cofos_tokenizer.model") # Loading requires the AMEFORGE inference runtime. Contact AMEFORGE for access # to the runtime, or use the streaming inference script provided with the model. ``` ### Prompt format Cofos v2 expects a structured prompt format with explicit XML-style tags. The basic pattern is: ``` Write a Python function that ... ``` For chain-of-thought generation, prefix with a `` tag: ``` Write a Python function that ... ``` The model will then generate its reasoning, followed by the code block. --- ## Training Cofos v2 was trained from scratch on a curated mix of: - Multi-source distilled instruction data with chain-of-thought reasoning (in French and English) - Real Python instruction-following data from public datasets - A small synthetic component for algorithmic diversity Training was conducted with the proprietary SparseMind training pipeline, with periodic safety checkpointing to ensure reproducibility and recovery from interruptions. **Tokenizer:** [AMFORGE/cofos_tok_v2](https://huggingface.co/AMFORGE/cofos_tok_v2) — a custom SentencePiece model with French-aware coverage, structural XML tags as atomic tokens, and Python keyword/builtin atoms for compact representation of code. --- ## Lineage ``` cofos_tok_v2 (tokenizer) ↓ cofos_v2 (this model) — code-specialized from scratch ``` Cofos v2 is a standalone code-specialized model. It is **not** a derivative of any other published model. --- ## Limitations & Biases - **Capacity**: At 522M parameters, Cofos v2 has limited capacity for complex multi-step reasoning compared to billion-parameter models. Use it for focused coding tasks, not as a general-purpose assistant. - **Language coverage**: The model is bilingual FR/EN. Prompts in other languages will produce degraded output or fall back to broken English/French. - **Hallucination**: As with all autoregressive language models, Cofos v2 can produce code that looks plausible but is incorrect. Always test generated code before use. - **Training data**: While care was taken to use clean, publicly-sourced datasets, the model may reflect biases present in those datasets. - **No safety alignment**: Cofos v2 has not undergone RLHF or any explicit safety alignment beyond pre-training data curation. It should not be deployed in user-facing products without additional safety layers. --- ## Environmental Considerations Cofos v2 is intentionally small (522M parameters) to minimize the compute footprint of both training and inference. It can run on a single consumer GPU and is suitable for on-device deployment after appropriate optimization. --- ## License This model is released under the **Apache 2.0** license. You are free to use, modify, and redistribute it, including for commercial purposes, subject to the terms of the license. --- ## Citation If you use Cofos v2 in your work, please cite: ```bibtex @misc{cofos_v2_2026, title = {Cofos v2: A Multilingual Python Code Assistant}, author = {{AMEFORGE}}, year = {2026}, url = {https://huggingface.co/AMFORGE/cofos_v2} } ``` --- ## Contact For questions, collaborations, or access to the AMEFORGE inference runtime: - **Organization**: AMEFORGE - **HuggingFace**: [@AMFORGE](https://huggingface.co/AMFORGE) --- *Cofos is part of a broader family of specialized models being developed by AMEFORGE under the SparseMind architecture program. See the [AMFORGE organization page](https://huggingface.co/AMFORGE) for related work.*