Update README.md
Browse files
README.md
CHANGED
|
@@ -1,47 +1,195 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
| 4 |
|
| 5 |
-
# Cofos
|
| 6 |
|
| 7 |
-
**Cofos v2** is a
|
| 8 |
-
architecture. Same essence as Cofos v1 (296M @ 34% real_syntax_valid),
|
| 9 |
-
scaled larger and trained with multilingual instructions + chain-of-thought.
|
| 10 |
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
-
|
| 18 |
-
|
| 19 |
-
-
|
| 20 |
-
-
|
| 21 |
-
|
| 22 |
-
- **Total parameters:** {model.n_params:,}
|
| 23 |
|
| 24 |
-
|
| 25 |
-
- **30% real HF Python** (`iamtarun/python_code_instructions_18k_alpaca`)
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
##
|
| 29 |
-
- **Best `real_syntax_valid`:** {best_syntax:.1f}% on held-out real Python instructions
|
| 30 |
|
| 31 |
-
##
|
| 32 |
-
- v2 tokenizer at [{HF_TOK_REPO_ID}](https://huggingface.co/{HF_TOK_REPO_ID})
|
| 33 |
-
|
| 34 |
|
| 35 |
-
## How to use
|
| 36 |
```python
|
|
|
|
| 37 |
import torch
|
| 38 |
-
import sentencepiece as spm
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
# model = SparseMind(Config(**cfg_dict))
|
| 46 |
-
# model.load_state_dict(ckpt["model"])
|
| 47 |
-
# model.eval()
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- fr
|
| 6 |
+
tags:
|
| 7 |
+
- code-generation
|
| 8 |
+
- python
|
| 9 |
+
- chain-of-thought
|
| 10 |
+
- sparse-transformer
|
| 11 |
+
- multilingual
|
| 12 |
+
- amforge
|
| 13 |
+
- sparsemind
|
| 14 |
+
library_name: pytorch
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
inference: false
|
| 17 |
+
model-index:
|
| 18 |
+
- name: cofos_v2
|
| 19 |
+
results:
|
| 20 |
+
- task:
|
| 21 |
+
type: text-generation
|
| 22 |
+
name: Python code generation
|
| 23 |
+
metrics:
|
| 24 |
+
- type: real_syntax_valid
|
| 25 |
+
value: 63.0
|
| 26 |
+
name: Real Python syntax validity (held-out)
|
| 27 |
---
|
| 28 |
|
| 29 |
+
# Cofos v2 — Multilingual Python Code Assistant
|
| 30 |
|
| 31 |
+
**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.
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
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.
|
| 34 |
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## Model Summary
|
| 38 |
+
|
| 39 |
+
| Field | Value |
|
| 40 |
+
|---|---|
|
| 41 |
+
| **Developer** | AMEFORGE |
|
| 42 |
+
| **Architecture** | SparseMind v15 (proprietary) |
|
| 43 |
+
| **Parameters** | 522M |
|
| 44 |
+
| **Context length** | 2048 tokens |
|
| 45 |
+
| **Vocabulary** | 16,384 (custom nexusBPE) |
|
| 46 |
+
| **Languages** | French, English |
|
| 47 |
+
| **Primary task** | Python code generation |
|
| 48 |
+
| **License** | Apache 2.0 |
|
| 49 |
+
| **Status** | Active development |
|
| 50 |
+
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
## Intended Use
|
| 54 |
+
|
| 55 |
+
### Primary use cases
|
| 56 |
+
|
| 57 |
+
- **Python code generation** from natural-language prompts (function specs, class designs, algorithm requests)
|
| 58 |
+
- **Bilingual coding assistance** for developers working in French or English
|
| 59 |
+
- **Chain-of-thought reasoning** when reasoning steps are useful before the code (toggle via prompt format)
|
| 60 |
+
- Integration as a lightweight code assistant in development pipelines where larger models are impractical
|
| 61 |
|
| 62 |
+
### Out-of-scope
|
| 63 |
|
| 64 |
+
This model is **not designed for**:
|
| 65 |
+
- General conversation or open-ended dialogue
|
| 66 |
+
- Languages other than French and English
|
| 67 |
+
- 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)
|
| 68 |
+
- Tasks requiring large-context reasoning (>2048 tokens)
|
| 69 |
+
- Factual knowledge retrieval, scientific reasoning, or creative writing
|
|
|
|
| 70 |
|
| 71 |
+
Cofos v2 is a specialized coding tool. Use it for what it was built for and pair it with appropriate tools for everything else.
|
|
|
|
| 72 |
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## Performance
|
| 76 |
+
|
| 77 |
+
Evaluated on a held-out set of real Python instruction prompts (no overlap with training data).
|
| 78 |
+
|
| 79 |
+
| Metric | Value |
|
| 80 |
+
|---|---|
|
| 81 |
+
| Real-syntax-valid (held-out, n=100) | **63.0%** |
|
| 82 |
+
| Validation loss | 3.08 |
|
| 83 |
+
| Model size (on disk) | ~2.1 GB (fp32) |
|
| 84 |
+
|
| 85 |
+
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.
|
| 86 |
+
|
| 87 |
+
---
|
| 88 |
|
| 89 |
+
## Usage
|
|
|
|
| 90 |
|
| 91 |
+
### Loading
|
|
|
|
|
|
|
| 92 |
|
|
|
|
| 93 |
```python
|
| 94 |
+
from huggingface_hub import hf_hub_download
|
| 95 |
import torch
|
|
|
|
| 96 |
|
| 97 |
+
# Download checkpoint
|
| 98 |
+
checkpoint_path = hf_hub_download(repo_id="AMFORGE/cofos_v2", filename="cofos_model.pt")
|
| 99 |
+
tokenizer_path = hf_hub_download(repo_id="AMFORGE/cofos_v2", filename="cofos_tokenizer.model")
|
| 100 |
+
|
| 101 |
+
# Loading requires the AMEFORGE inference runtime. Contact AMEFORGE for access
|
| 102 |
+
# to the runtime, or use the streaming inference script provided with the model.
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
### Prompt format
|
| 106 |
+
|
| 107 |
+
Cofos v2 expects a structured prompt format with explicit XML-style tags. The basic pattern is:
|
| 108 |
+
|
| 109 |
+
```
|
| 110 |
+
<instruction>Write a Python function that ...</instruction>
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
For chain-of-thought generation, prefix with a `<thought>` tag:
|
| 114 |
+
|
| 115 |
+
```
|
| 116 |
+
<instruction>Write a Python function that ...</instruction>
|
| 117 |
+
<thought>
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
The model will then generate its reasoning, followed by the code block.
|
| 121 |
+
|
| 122 |
+
---
|
| 123 |
+
|
| 124 |
+
## Training
|
| 125 |
+
|
| 126 |
+
Cofos v2 was trained from scratch on a curated mix of:
|
| 127 |
+
- Multi-source distilled instruction data with chain-of-thought reasoning (in French and English)
|
| 128 |
+
- Real Python instruction-following data from public datasets
|
| 129 |
+
- A small synthetic component for algorithmic diversity
|
| 130 |
+
|
| 131 |
+
Training was conducted with the proprietary SparseMind training pipeline, with periodic safety checkpointing to ensure reproducibility and recovery from interruptions.
|
| 132 |
+
|
| 133 |
+
**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.
|
| 134 |
+
|
| 135 |
+
---
|
| 136 |
+
|
| 137 |
+
## Lineage
|
| 138 |
+
|
| 139 |
+
```
|
| 140 |
+
cofos_tok_v2 (tokenizer)
|
| 141 |
+
↓
|
| 142 |
+
cofos_v2 (this model) — code-specialized from scratch
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
Cofos v2 is a standalone code-specialized model. It is **not** a derivative of any other published model.
|
| 146 |
+
|
| 147 |
+
---
|
| 148 |
+
|
| 149 |
+
## Limitations & Biases
|
| 150 |
+
|
| 151 |
+
- **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.
|
| 152 |
+
- **Language coverage**: The model is bilingual FR/EN. Prompts in other languages will produce degraded output or fall back to broken English/French.
|
| 153 |
+
- **Hallucination**: As with all autoregressive language models, Cofos v2 can produce code that looks plausible but is incorrect. Always test generated code before use.
|
| 154 |
+
- **Training data**: While care was taken to use clean, publicly-sourced datasets, the model may reflect biases present in those datasets.
|
| 155 |
+
- **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.
|
| 156 |
+
|
| 157 |
+
---
|
| 158 |
+
|
| 159 |
+
## Environmental Considerations
|
| 160 |
+
|
| 161 |
+
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.
|
| 162 |
+
|
| 163 |
+
---
|
| 164 |
+
|
| 165 |
+
## License
|
| 166 |
+
|
| 167 |
+
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.
|
| 168 |
+
|
| 169 |
+
---
|
| 170 |
+
|
| 171 |
+
## Citation
|
| 172 |
+
|
| 173 |
+
If you use Cofos v2 in your work, please cite:
|
| 174 |
+
|
| 175 |
+
```bibtex
|
| 176 |
+
@misc{cofos_v2_2026,
|
| 177 |
+
title = {Cofos v2: A Multilingual Python Code Assistant},
|
| 178 |
+
author = {{AMEFORGE}},
|
| 179 |
+
year = {2026},
|
| 180 |
+
url = {https://huggingface.co/AMFORGE/cofos_v2}
|
| 181 |
+
}
|
| 182 |
+
```
|
| 183 |
+
|
| 184 |
+
---
|
| 185 |
+
|
| 186 |
+
## Contact
|
| 187 |
+
|
| 188 |
+
For questions, collaborations, or access to the AMEFORGE inference runtime:
|
| 189 |
+
|
| 190 |
+
- **Organization**: AMEFORGE
|
| 191 |
+
- **HuggingFace**: [@AMFORGE](https://huggingface.co/AMFORGE)
|
| 192 |
+
|
| 193 |
+
---
|
| 194 |
|
| 195 |
+
*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.*
|
|
|
|
|
|
|
|
|