Translation
Transformers
Safetensors
English
mistral3
image-text-to-text
code
code-translation
sas
r
python
lora
axolotl
Instructions to use ProCogia/Euclid-2.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ProCogia/Euclid-2.5 with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="ProCogia/Euclid-2.5")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("ProCogia/Euclid-2.5") model = AutoModelForMultimodalLM.from_pretrained("ProCogia/Euclid-2.5", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,79 +1,212 @@
|
|
| 1 |
---
|
| 2 |
-
library_name: transformers
|
| 3 |
license: apache-2.0
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
tags:
|
| 6 |
-
- code
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
# Euclid-2.
|
| 13 |
|
| 14 |
-
Bidirectional
|
| 15 |
-
for statistical / data-processing programs.
|
| 16 |
|
| 17 |
-
##
|
| 18 |
|
| 19 |
-
|
| 20 |
-
(280 block-quantized projection tensors), then LoRA fine-tuned and merged.
|
| 21 |
-
|
| 22 |
-
## Training recipe
|
| 23 |
|
| 24 |
| | |
|
| 25 |
|---|---|
|
| 26 |
-
|
|
| 27 |
-
|
|
| 28 |
-
|
|
| 29 |
-
|
|
| 30 |
-
|
|
| 31 |
-
|
|
| 32 |
-
|
|
| 33 |
-
|
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
##
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
so the late checkpoints were discarded:
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|---|---|
|
| 49 |
-
|
|
| 50 |
-
|
|
| 51 |
-
|
|
| 52 |
-
|
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
-
both are published so they can be compared on execution-based functional equivalence.
|
| 56 |
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
-
|
| 60 |
-
**pending**. Eval loss is a token-level proxy and does not measure behavioural
|
| 61 |
-
equivalence, which is this model's only correctness criterion.
|
| 62 |
|
| 63 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
-
```python
|
| 66 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 67 |
-
m = AutoModelForCausalLM.from_pretrained("momosushi/Euclid-2.6", dtype="bfloat16", device_map="auto")
|
| 68 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
-
|
| 71 |
-
translated program, no prose, no markdown fences).
|
| 72 |
|
| 73 |
-
|
| 74 |
|
| 75 |
-
|
| 76 |
-
`momosushi/Euclid-devstral` branch `checkpoints`.
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: image-text-to-text
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
tags:
|
| 8 |
+
- code
|
| 9 |
+
- code-translation
|
| 10 |
+
- sas
|
| 11 |
+
- r
|
| 12 |
+
- python
|
| 13 |
+
- lora
|
| 14 |
+
- axolotl
|
| 15 |
+
- mistral3
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# Euclid-2.5
|
| 19 |
|
| 20 |
+
Bidirectional SAS ↔ R ↔ Python program translation. A 24B dense code model, LoRA-tuned and merged to standalone BF16 weights.
|
|
|
|
| 21 |
|
| 22 |
+
## Model Summary
|
| 23 |
|
| 24 |
+
Euclid-2.5 translates complete statistical and data-processing programs across all six directed pairs over {SAS, Python, R}. The training objective is **behavioural equivalence**: given identical inputs, the translated program must compute identical values and bind them to identically-named results.
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
| | |
|
| 27 |
|---|---|
|
| 28 |
+
| Developer | ProCogia |
|
| 29 |
+
| Method | LoRA SFT (r=128), adapter merged into the weights |
|
| 30 |
+
| Checkpoint | step 368 (1.0 epoch) |
|
| 31 |
+
| Parameters | 24B dense |
|
| 32 |
+
| Hidden / layers / intermediate | 5120 / 40 / 32768 |
|
| 33 |
+
| Attention heads / KV heads / head dim | 32 / 8 / 128 |
|
| 34 |
+
| Tokenizer | Tekken, 131,072 vocab |
|
| 35 |
+
| Context | 256k architectural; trained at 8,192 |
|
| 36 |
+
| Precision | BF16, ~48 GB |
|
| 37 |
+
| License | Apache 2.0 |
|
| 38 |
+
|
| 39 |
+
**Multimodality.** A vision tower is present in the architecture and untouched by fine-tuning. The model is text-only in practice; the tower carries ~1–2 GB of inert VRAM and dictates the loader class (see [How to Use](#how-to-use)).
|
| 40 |
+
|
| 41 |
+
## Intended Use
|
| 42 |
+
|
| 43 |
+
- Single-turn translation of complete programs across the six directed pairs over {SAS, Python, R}.
|
| 44 |
+
- Target environments matching the training distribution: **R** — base R plus `dplyr`; **Python** — `pandas`, `numpy`, `scipy`, `statsmodels`.
|
| 45 |
+
- Output contract: the translated program only, no prose, no markdown fences.
|
| 46 |
+
|
| 47 |
+
## How to Use
|
| 48 |
+
|
| 49 |
+
### Loader class
|
| 50 |
+
|
| 51 |
+
`AutoModelForCausalLM` raises `Unrecognized configuration class`.
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
import torch
|
| 55 |
+
from transformers import AutoModelForImageTextToText
|
| 56 |
+
|
| 57 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 58 |
+
"ProCogia/Euclid-2.5",
|
| 59 |
+
torch_dtype=torch.bfloat16,
|
| 60 |
+
device_map="auto",
|
| 61 |
+
)
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
Tokenization must route through `mistral-common` using the bundled `tekken.json`.
|
| 65 |
|
| 66 |
+
### vLLM
|
| 67 |
|
| 68 |
+
```bash
|
| 69 |
+
vllm serve ProCogia/Euclid-2.5 \
|
| 70 |
+
--tokenizer-mode mistral \
|
| 71 |
+
--max-model-len 16384
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
`--tokenizer-mode mistral` is required. Routing through a jinja template instead of `mistral-common` produces systematically degraded output that closely resembles a genuine accuracy result.
|
| 75 |
+
|
| 76 |
+
### Prompt format
|
| 77 |
+
|
| 78 |
+
The model was trained against a single system prompt across every row. Deviating from its contract is off-distribution. The exact prompt (MD5 prefix `dc99ebd18483`) ships with the proprietary training data; the block below reproduces its contract:
|
| 79 |
|
| 80 |
+
```text
|
| 81 |
+
You are a code translation engine for statistical and data-processing programs written in SAS, Python, and R.
|
| 82 |
+
|
| 83 |
+
You are given one complete program in a source language and produce the equivalent program in the target language. Behavioural equivalence is the only criterion: given the same inputs, your program must compute the same values and place them in results carrying the same names.
|
| 84 |
+
|
| 85 |
+
- Preserve the source program's structure, step order, and intent. Carry its comments across as comments in the target language, and add a brief comment where the target expresses a source construct non-obviously.
|
| 86 |
+
- Name every result exactly as the source names it, so results can be compared name for name.
|
| 87 |
+
- SAS semantics decide the answer even when SAS is not the target language. A SAS date is whole days since 1960-01-01 and a datetime is seconds since 1960-01-01, both stored as plain numbers. A SAS FORMAT changes only how a value is displayed, never what is stored. Missing (.) sorts below every number, so `x < 5` is true when x is missing. Character values are blank-padded to a declared length and compare ignoring trailing blanks.
|
| 88 |
+
- A step that only prints or plots produces no data and has no translation outside SAS; leave it out rather than inventing an equivalent.
|
| 89 |
+
- Respond with the translated program and nothing else: no prose, no explanation, no markdown code fences, no placeholders.
|
| 90 |
+
```
|
| 91 |
|
| 92 |
+
The user turn is:
|
|
|
|
| 93 |
|
| 94 |
+
1. `Translate the following {SOURCE} program to {TARGET}.`
|
| 95 |
+
2. A target-language instruction block (one of three: R, Python, SAS) specifying the permitted library environment.
|
| 96 |
+
3. The source program, fenced with the **source** language tag.
|
| 97 |
+
|
| 98 |
+
The model emits a bare program. Absence of a ```` ```sas ```` fence is the direct signal that the fine-tuned weights are active — the untuned weights emit markdown fences, these do not.
|
| 99 |
+
|
| 100 |
+
## Training Data
|
| 101 |
+
|
| 102 |
+
**Proprietary. Not released.** Composition is disclosed below for reproducibility of method, not of data.
|
| 103 |
+
|
| 104 |
+
| | |
|
| 105 |
|---|---|
|
| 106 |
+
| Training rows |**12,952**|
|
| 107 |
+
| In-loop validation | 120|
|
| 108 |
+
| Held-out execution set | 424|
|
| 109 |
+
| Format | JSONL, single-turn `system` + `user` + `assistant` |
|
| 110 |
+
| Length (chars) | mean 6,226 / p50 4,682 / p90 11,690 / p99 21,205 / max 68,627 |
|
| 111 |
|
| 112 |
+
Direction balance:
|
|
|
|
| 113 |
|
| 114 |
+
| Direction | Rows | Direction | Rows |
|
| 115 |
+
|---|---|---|---|
|
| 116 |
+
| Python→R | 2,070 | R→SAS | 2,213 |
|
| 117 |
+
| Python→SAS | 2,199 | SAS→Python | 2,199 |
|
| 118 |
+
| R→Python | 2,070 | SAS→R | 2,213 |
|
| 119 |
|
| 120 |
+
## Training Procedure
|
|
|
|
|
|
|
| 121 |
|
| 122 |
+
### Weight preparation
|
| 123 |
+
|
| 124 |
+
The starting checkpoint ships in native FP8 (`float8_e4m3fn`, block-quantized) with no official BF16 weights, and FP8 does not support training. Casting via `model.to(torch.bfloat16)` **silently no-ops** on quantized linear layers, writing FP8 bytes labelled BF16.
|
| 125 |
+
|
| 126 |
+
Weights were dequantized by streaming safetensors shards directly:
|
| 127 |
|
|
|
|
|
|
|
|
|
|
| 128 |
```
|
| 129 |
+
W_bf16 = W_fp8.to(float32) × expand_blocks(weight_scale_inv)
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
280 tensors (40 layers × 7 projections) were converted — exactly the modules LoRA attaches to. `activation_scale`, `input_scale`, and `kv_scale` are FP8-runtime only and were discarded. Verification: 280/280 converted, on-disk dtype scan `Counter({'BF16': 585})` with zero `F8_E4M3`, finiteness assertion passed on every parameter, 48.0 GB output, and a live generation coherence check.
|
| 133 |
+
|
| 134 |
+
### LoRA configuration
|
| 135 |
+
|
| 136 |
+
| Parameter | Value |
|
| 137 |
+
|---|---|
|
| 138 |
+
| Rank `r` | 128 |
|
| 139 |
+
| `alpha` | 256 (α = 2r → rank-independent scaling factor of 2) |
|
| 140 |
+
| Dropout | 0.05 |
|
| 141 |
+
| Target modules | `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj` |
|
| 142 |
+
| Scope | Language model only; vision tower and projector excluded |
|
| 143 |
+
| Embeddings / `lm_head` | Frozen |
|
| 144 |
+
| Trainable | 739M (≈3.0%) |
|
| 145 |
|
| 146 |
+
Vision exclusion is structural rather than enumerated: the targeting regex keys on `self_attn|mlp` parent names, which exist only in the language model, while the vision tower uses `attention`/`feed_forward`.
|
|
|
|
| 147 |
|
| 148 |
+
MLP targeting accounts for 78.7% of available per-layer LoRA capacity at hidden 5120 / intermediate 32768; attention-only targeting would forfeit four-fifths of it.
|
| 149 |
|
| 150 |
+
### Optimization
|
|
|
|
| 151 |
|
| 152 |
+
| Parameter | Value |
|
| 153 |
+
|---|---|
|
| 154 |
+
| Learning rate | 1e-4, cosine to 10% of peak |
|
| 155 |
+
| Warmup | 30 steps (fixed count, ~4% of 736) |
|
| 156 |
+
| Optimizer | `adamw_torch_fused`, β = (0.9, 0.95), wd 0.01 |
|
| 157 |
+
| Gradient clipping | 1.0 |
|
| 158 |
+
| Micro-batch × accumulation | 1 × 8 (≈36 examples/step) |
|
| 159 |
+
| Sequence length | 8,192, sample packing on, cross-sample masked |
|
| 160 |
+
| Loss | Completion-only |
|
| 161 |
+
| Precision | BF16 + gradient checkpointing, FlashAttention-2 |
|
| 162 |
+
| Epochs | 2, checkpointed every 0.5 |
|
| 163 |
+
| Seed | 42 |
|
| 164 |
+
| Total steps | 736 |
|
| 165 |
+
|
| 166 |
+
At α=2r, LR 1e-4 is equivalent in effective update magnitude to LR 2e-4 at α=r. Over-length rows were **dropped, never truncated** — 12 rows exceeded 8,192 tokens (0.09%), measured with exact `mistral-common` counts. Truncating an assistant target teaches premature EOS, which is directly harmful on a task whose contract is "the complete program and nothing else."
|
| 167 |
+
|
| 168 |
+
Six pre-flight gates ran before training: exact token lengths, loss-mask decoding (asserting supervised positions contain only the assistant program), adapter scope and parameter count, packing confirmation, leakage checks, and system-prompt integrity. An adapter weight scan for NaN and residual all-zero `lora_B` tensors was added mid-project and is a required gate for any rerun of this recipe.
|
| 169 |
+
|
| 170 |
+
### Infrastructure
|
| 171 |
+
|
| 172 |
+
| | |
|
| 173 |
+
|---|---|
|
| 174 |
+
| GPU | 1× H100 80GB SXM |
|
| 175 |
+
| Framework | Axolotl 0.17.0.dev0, torch 2.10.0+cu128, transformers v5 |
|
| 176 |
+
| Peak VRAM | 71.1 GB training / 60.3 GB eval |
|
| 177 |
+
| Throughput | ~1,150–1,360 tok/s, ~22 s/step |
|
| 178 |
+
|
| 179 |
+
## Evaluation
|
| 180 |
+
|
| 181 |
+
**Pending.**
|
| 182 |
+
|
| 183 |
+
The planned protocol:
|
| 184 |
+
|
| 185 |
+
| Element | Specification |
|
| 186 |
+
|---|---|
|
| 187 |
+
| Set | 424 examples, repo-disjoint, offline |
|
| 188 |
+
| Method | Execute source and translation on identical inputs; compare at dataframe level |
|
| 189 |
+
| Metric | pass@1, pooled |
|
| 190 |
+
| Prompt | Training system prompt, greedy decoding |
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
## Hardware Requirements
|
| 194 |
+
|
| 195 |
+
| | |
|
| 196 |
+
|---|---|
|
| 197 |
+
| Weights on disk | ~48 GB (BF16) |
|
| 198 |
+
| KV cache @ 16k context | ~2.6 GB per sequence (40 layers × 8 KV heads × 128 dim) |
|
| 199 |
+
| Inert vision tower | ~1–2 GB |
|
| 200 |
+
| Practical single-GPU floor | 80 GB (H100 / H200 / A100 80GB) |
|
| 201 |
+
| Multi-GPU | 2× 48 GB (L40S, A6000) with tensor parallelism |
|
| 202 |
+
|
| 203 |
+
## Citation
|
| 204 |
+
|
| 205 |
+
```bibtex
|
| 206 |
+
@misc{euclid_2_5,
|
| 207 |
+
title = {Euclid-2.5: Bidirectional SAS/R/Python Program Translation},
|
| 208 |
+
author = {ProCogia},
|
| 209 |
+
year = {2026},
|
| 210 |
+
url = {https://huggingface.co/ProCogia/Euclid-2.5}
|
| 211 |
+
}
|
| 212 |
+
```
|