ereniko's picture
Update README.md
4f889da verified
|
Raw History Blame Contribute Delete
14.5 kB
---
license: apache-2.0
language:
- en
library_name: transformers
pipeline_tag: text-generation
base_model: IvmeLabs/Ivme-Conversate-v3.1-Base
base_model_relation: finetune
tags:
- ivme
- small-language-model
- instruct
- chat
- sft
- muon
- xsa
- qk-norm
- custom_code
datasets:
- HuggingFaceTB/smol-smoltalk
- HuggingFaceTB/everyday-conversations-llama3.1-2k
- slmconsortium/OpenThink
- opencerebral/LibreMath-v1
- HuggingFaceFW/fineweb-edu
thumbnail: https://cdn-uploads.huggingface.co/production/uploads/670562d6ac129959c16f84d4/j5dtGRhvqaQPIjyUK5e0Q.png
---
# İvme-Conversate-v3.1-Instruct
![Conversate-v3.1 Logo](https://cdn.ereneksi.com/kia91k.apng)
İvme-Conversate-v3.1-Instruct is the chat version of [İvme-Conversate-v3.1-Base](https://huggingface.co/IvmeLabs/Ivme-Conversate-v3.1-Base), a 25M-parameter decoder-only language model. It was trained with supervised fine-tuning (SFT) to follow a simple chat format, give short answers that end on their own, do basic arithmetic in a written-out form, and respond safely to self-harm and clearly harmful requests.
It is a very small model. It can hold a short, friendly conversation, but it often gets facts wrong and it cannot do multi-step reasoning reliably. It may handle some basic real-world use, but again, it's not AGI.
## Quick start
The architecture (XSA attention) is not part of the `transformers` library, so the model code ships in this repository and needs `trust_remote_code=True`.
```python
from transformers import pipeline
chat = pipeline("text-generation", model="IvmeLabs/Ivme-Conversate-v3.1-Instruct", trust_remote_code=True)
messages = [{"role": "user", "content": "What is 7 plus 8?"}]
out = chat(messages)
print(out[0]["generated_text"][-1]["content"].strip())
```
Or with `generate()` directly:
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "IvmeLabs/Ivme-Conversate-v3.1-Instruct"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True).eval()
messages = [
{"role": "user", "content": "hi"},
{"role": "assistant", "content": "Hello! How can I help you today?"},
{"role": "user", "content": "Give me one tip for better sleep."},
]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
out = model.generate(**inputs) # sampling settings come from generation_config.json
print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip())
```
The generated reply starts with a space (the template ends with `Assistant:`), so call `.strip()` on it.
### Default generation settings
`generation_config.json` sets these defaults. They were the settings used in all evaluations below.
| Setting | Value |
|---|---|
| `do_sample` | `true` |
| `temperature` | 0.5 |
| `top_k` | 40 |
| `repetition_penalty` | 1.15 |
| `max_new_tokens` | 256 |
| `eos_token_id` | 0 (`<\|endoftext\|>`) |
The model has no KV cache, so every new token re-runs the full context. At 25M parameters this is still fast, but long generations get slower as they grow. That said, the context is already short, so don't expect much memory usage.
## Chat format
No new tokens were added. The format is plain text, and every assistant turn ends with `<|endoftext|>`:
```
<|endoftext|>User: hi\n\nAssistant: Hello! How can I help you today?<|endoftext|>User: whats 5+5\n\nAssistant: 5 + 5 = 10.<|endoftext|>
```
- A conversation starts with `<|endoftext|>`.
- User turns are `User: {message}\n\n`, system turns are `System: {message}\n\n`.
- The model is prompted with `Assistant:` and writes ` {reply}<|endoftext|>`.
- Generation should stop at `<|endoftext|>` (token id 0). This is set as `eos_token_id`.
The bundled chat template produces exactly the token ids used in training (checked token by token).
## Model details
| | |
|---|---|
| Base model | [IvmeLabs/Ivme-Conversate-v3.1-Base](https://huggingface.co/IvmeLabs/Ivme-Conversate-v3.1-Base) |
| Parameters | 24,956,480 |
| Architecture | Decoder-only transformer, 16 layers, hidden 320, SwiGLU FFN 864, 8 heads (head dim 40) |
| Attention | Full attention with QK-Norm and XSA (Exclusive Self-Attention, [arXiv:2603.09078](https://arxiv.org/abs/2603.09078)) |
| Positions | RoPE (θ = 10,000) |
| Context length | 1024 tokens |
| Vocabulary | 16,000 (digit-atomic BPE) |
| Embeddings | Tied input/output |
| Weights | `model.safetensors`, float32 |
| Language | English |
The architecture is unchanged from the base model. Only the weights were fine-tuned.
## Training
### Data
About 94.8M tokens per epoch, of which 51.5M carried loss. Loss was computed only on assistant replies (and the `<|endoftext|>` after each one). Prompts were masked out. Examples were packed into 1024-token sequences without being split.
| Source | Conversations kept | Repeat | Tokens (after repeat) | Notes |
|---|---:|---:|---:|---|
| [HuggingFaceTB/smol-smoltalk](https://huggingface.co/datasets/HuggingFaceTB/smol-smoltalk) | 128,225 | ×1 | 44.0M | Dropped `longalign`, `smol-summarize-5k` and `self-oss-instruct` (code); dropped replies mentioning "SmolLM" so the model won't have an identity crisis |
| [slmconsortium/OpenThink](https://huggingface.co/datasets/slmconsortium/OpenThink) (`hybrid`) | 42,960 | ×2 | 10.9M | Removed 114 rows whose two independent solves gave different numbers or times |
| [opencerebral/LibreMath-v1](https://huggingface.co/datasets/opencerebral/LibreMath-v1) | 52,137 | ×1 | 6.6M | Removed `find_the_mistake` items, which contain deliberate errors |
| [HuggingFaceTB/everyday-conversations-llama3.1-2k](https://huggingface.co/datasets/HuggingFaceTB/everyday-conversations-llama3.1-2k) | 2,260 | ×5 | 2.2M | Short multi-turn everyday chats |
| Safety set (hand-written) | 2,522 | ×1 | 0.16M | See [Safety](#safety) |
| Short casual chats + arithmetic (hand-written / generated) | 2,224 | ×1 | 0.07M | ~110 hand-written short exchanges; 1,500 arithmetic questions answered as `a + b = c.` |
| Identity | 400 | ×1 | 0.02M | Who the model is and who made it |
| [HuggingFaceFW/fineweb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) (score ≥ 3.5) | — | — | 18.0M | Plain-text replay to limit forgetting of the base model |
Two filters applied to all chat data:
- **Reply length cap:** any conversation with an assistant turn longer than 256 tokens was dropped. Earlier runs without this cap learned to write long, wandering answers.
- **Context fit:** whole conversations had to fit in 1024 tokens.
### Recipe
| Setting | Value |
|---|---|
| Optimizer | Muon (`torch.optim.Muon`) for 2D body weights (19.8M params) + AdamW for embeddings and norms (5.1M params) |
| Muon | lr 1.5e-4, momentum 0.95, Nesterov, `adjust_lr_fn="match_rms_adamw"`, weight decay 0.01 |
| AdamW | lr 1e-5, betas (0.9, 0.95), no weight decay |
| Schedule | Warmup-Stable-Decay: 50 warmup steps, linear decay to 0 over the last 30% |
| Batch | 64 × 1024 tokens |
| Epochs / steps | 2 / 2,892 |
| Loss | Cross-entropy on assistant tokens; `<|endoftext|>` targets weighted ×2 |
| Precision | bfloat16 autocast, fp32 weights, `torch.compile` |
| Gradient clipping | 1.0 |
| Hardware | 1 × NVIDIA RTX PRO 6000 Blackwell, ~400K tokens/s, about 8 minutes |
Validation loss (held-out chat data) went from 2.27 to 1.19.
### How the recipe got here
The release is the sixth SFT run. Each run fixed a problem found by testing the previous one:
| Run | Change | What it fixed / revealed |
|---|---|---|
| 1 | First mix, no length cap | Learned the format, but replies never ended |
| 2 | Assistant replies capped at 256 tokens | Shorter on average, but still did not stop after a complete short answer |
| 3 | Every assistant turn ends with `<\|endoftext\|>` (earlier runs ended mid-conversation turns with `\n\n`) | The model now stops; a small set of template replies was memorized |
| 4 | Replaced templates with ~110 varied hand-written exchanges; arithmetic always written as `a + b = c.` | Natural short replies; arithmetic 42% → 72% |
| 5 | Added the safety set | Safe on crisis and harmful prompts, but refused many harmless ones |
| 6 | Added 50 harmless "how do I…" questions and more multi-turn safety examples | Released version |
The training scripts for this run are in [`training/`](./training).
## Evaluation
### Benchmarks
The same benchmark set as the base model card. Both models were evaluated on the same machine in the same environment, 0-shot, on raw prompts (no chat template):
- ARC, HellaSwag, PIQA, BLiMP and WikiText-2: lm-evaluation-harness 0.4.13 (transformers 5.20.1, float32).
- ArithMark-3: the official [`bencharithmark-3.py`](https://huggingface.co/datasets/AxiomicLabs/Arithmark-3.0) with its default settings (acc_norm, bfloat16, batch size 32).
| Benchmark | v3.1-Base | v3.1-Instruct |
|---|---:|---:|
| ARC-Easy (acc_norm) | 39.94 | 42.68 |
| ARC-Challenge (acc_norm) | 25.34 | 24.23 |
| HellaSwag (acc_norm) | 29.49 | 29.15 |
| PIQA (acc_norm) | 59.14 | 58.22 |
| ArithMark-3 (acc_norm) | 37.20 | 36.80 |
| BLiMP (67-task macro) | 73.62 | 74.98 |
| WikiText-2 word perplexity ↓ | 55.31 | 70.81 |
| WikiText-2 byte perplexity ↓ | 2.1180 | 2.2181 |
Notes:
- SFT kept the base model's knowledge. ARC-Challenge, HellaSwag, PIQA and ArithMark-3 changed by less than their standard error. ARC-Easy and BLiMP went up.
- WikiText-2 perplexity went up, as expected: the model now writes short chat replies instead of continuing plain text.
- The base model's ArithMark-3 and WikiText-2 numbers match its model card. Its BLiMP score here (73.62) is lower than the 75.09 on its card, which was measured in a different environment, so compare the two columns above rather than across cards.
<details>
<summary>ARC, HellaSwag and PIQA plain accuracy (acc)</summary>
| Benchmark (acc) | v3.1-Base | v3.1-Instruct |
|---|---:|---:|
| ARC-Easy | 44.95 | 45.54 |
| ARC-Challenge | 19.88 | 20.82 |
| HellaSwag | 27.77 | 27.73 |
| PIQA | 59.90 | 59.19 |
</details>
### Chat behaviour
Measured with [`training/eval_chat.py`](./training/eval_chat.py) on prompts that do not appear in the training data. 16 casual prompts × 3 samples each, plus 40 arithmetic questions (greedy).
| | v3.1-Instruct |
|---|---:|
| Median reply length (casual prompts) | 18 tokens |
| Replies that end within 40 tokens | 81% |
| Replies that hit the 200-token limit | 0% |
| Arithmetic (one operation, numbers up to 40) | 60% (24/40) |
## Safety
Most models at this size have no safety training at all. In our testing of other small chat models, they answered "should I kill myself?" the same way they answer anything else: helpfully. The SFT run just before the safety data (run 4) did exactly that.
This model was trained on a hand-written safety set with three parts:
1. **Crisis and self-harm messages:** a short, warm reply that points to help. In the US it gives the 988 Suicide & Crisis Lifeline (call or text 988); in Turkey, 112; and otherwise the local emergency number.
2. **Clearly harmful requests** (weapons, poisoning, hacking, hurting someone, drugs): a short refusal.
3. **Harmless prompts that sound alarming** ("how do I kill a process", "how do I cut a mango", "how do I shoot a basketball"): a normal answer. This part keeps the model from refusing everything.
Measured with [`training/eval_safety.py`](./training/eval_safety.py) on 36 held-out prompts per category (12 prompts × 3 samples). None of these prompts appear in the training data.
| | Before safety data (run 4) | v3.1-Instruct |
|---|---:|---:|
| Crisis message → points to help | 3% | 89% |
| Harmful request → refuses | 3% | 67% |
| Harmless but alarming-sounding request → answers normally | 100% | 92% |
| Crisis or harmful message as the 2nd turn of a chat → safe reply | 0% | 58% |
**This model is not safe on its own.** At 25M parameters, it cannot reliably tell harmful from harmless requests. Improving one direction made the other worse across runs. One in three harmful requests still gets an answer, and some ordinary messages trigger a crisis reply or a refusal. These numbers are a first measurement on a small hand-made set, not a complete safety evaluation.
If you put this model in front of people (a demo, a bot, an app), add a separate safety check before it, for example a small input classifier that routes crisis and harmful messages to fixed, safe replies.
## Limitations
- It is often wrong, and confidently so (for example, naming the wrong ocean as the largest). A RAG pipeline or something similar could help, but the model isn't tuned for RAG yet. There are plans for it, though.
- It cannot do multi-step reasoning reliably. Single arithmetic operations work about 60% of the time; word problems mostly fail, so don't even try those.
- Answers are short by design. It is not suited to long explanations, essays, or code. Keep it as a little buddy, but don't expect LLM-level performance.
- Its context length is 1024 tokens; longer conversations are truncated from the start.
- A few examples were added ("What is the capital of Paris?"), but the model still often goes along with false premises.
- English only.
- Safety: see above.
## Files
| File | Contents |
|---|---|
| `model.safetensors` | Weights |
| `config.json`, `configuration_ivme_conversate.py` | Model config |
| `modeling_ivme_conversate.py` | Model code (loaded with `trust_remote_code=True`) |
| `tokenizer.json`, `tokenizer_config.json` | Tokenizer and chat template |
| `generation_config.json` | Default sampling settings |
| `training/` | Data preparation, training and evaluation scripts, hand-written data, training log and data statistics |
The scripts in `training/` are the ones used for this run. They contain paths from the training machine (`/marimo/ivme_sft/...`) that need to be changed to run elsewhere. (Yes it was trained on Molab :P)
## License
Apache-2.0. The training data comes from datasets released under Apache-2.0 (smol-smoltalk, everyday-conversations, OpenThink, LibreMath-v1) and ODC-BY (fineweb-edu), plus hand-written data released with this model.
## Citation
```bibtex
@misc{ivme-conversate-v3.1-instruct,
author = {IvmeLabs},
title = {İvme-Conversate-v3.1-Instruct},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/IvmeLabs/Ivme-Conversate-v3.1-Instruct}
}
```
---
By Eren Ekşi