File size: 4,413 Bytes
c4202d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
language:
- en
license: apache-2.0
base_model: petruhonk/Qwen3.8-9B-Distill-uncensored-heretic
base_model_relation: finetune
library_name: transformers
pipeline_tag: text-generation
tags:
- yuri-os
- yuricore
- qwen3.5
- roleplay
- companion
- reasoning
- function-calling
- tool-use
- sft
---

# YuriCore-9B

**YuriCore-9B** is a 9B-parameter companion roleplay and tool-use model fine-tuned for the **YuriOS** companion runtime. It is built on [petruhonk/Qwen3.8-9B-Distill-uncensored-heretic](https://huggingface.co/petruhonk/Qwen3.8-9B-Distill-uncensored-heretic) (the hybrid Gated-DeltaNet Qwen3.5-9B architecture) and requires `transformers >= 5`.

- **GGUF quantizations (`Q8_0`, `Q4_K_M`):** [Yuri-OS/YuriCore-9B-GGUF](https://huggingface.co/Yuri-OS/YuriCore-9B-GGUF)

## Highlights

- **In-character roleplay with `<think>` reasoning:** Preserves natural character voice and narrative continuity while using structured `<think>...</think>` reasoning before replying. Formats physical actions with `*asterisks*` (TTS-friendly) rather than bracketed narration.
- **Grounded tool use & abstention:** Trained for inline `[[tool ...]]` calls, multi-step tool chains, and clean abstention when a tool is unnecessary, ambiguous, or unavailable.
- **Outcome honesty:** Filtered and trained to avoid fabricating completed actions, invented search results, or delivered images when a tool failed, was denied, or is still pending.
- **Long-context & background loops:** Trained up to 16,384 tokens for full companion system prompts as well as structured background tasks (reflection/dreaming, goal work, memory updates, and JSON utility outputs).

## Training Summary

| Setting | Value |
|---|---|
| Base model | `petruhonk/Qwen3.8-9B-Distill-uncensored-heretic` |
| Architecture | Qwen3.5-9B hybrid Gated-DeltaNet + full attention |
| Method | BF16 rsLoRA (`r=32`, `alpha=32`) merged into BF16 weights |
| Target modules | All 248 attention, Gated-DeltaNet (`in_proj_qkv/z/a/b`, `out_proj`), and MLP projections |
| Loss masking | Final assistant turn only (`<think>` + reply) |
| Context length | 16,384 tokens |
| Schedule | 1 epoch, `lr=1e-4`, effective batch size 16 |
| Dataset size | 20,206 train / 407 validation examples (English) |

The training mixture combines curated roleplay datasets (CoSER, filtered PIPPA, character archetypes), function-calling and abstention data (ToolACE, When2Call, Hermes-style tasks), and multi-turn YuriOS tool and background-loop episodes with automated filters for clock/date accuracy, leaked instructions, and hallucinated tool outcomes.

## Internal Evaluation Summary

Evaluated via `llama.cpp` / LM Studio GGUF builds on YuriOS's internal benchmark suites:

| Suite | YuriCore-9B (`Q8_0`) | YuriCore-9B (`Q4_K_M`) |
|---|---|---|
| Tool & abstention (`cases_v5c`, 252 scored) | **87%** (218/252) | — |
| Held-out blind tool suite (21 cases) | **95%** (20/21) | **90%** (19/21) |
| Result-bearing outcome suite (68 cases) | **84%** (57/68) | **74%** (50/68) |
| Background loops (45 cases) | **93%** (42/45) | **87%** (39/45) |
| Roleplay judge (12 sessions, 0–100) | **91.8** | — |

## Usage

### Transformers (`transformers >= 5`)

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "Yuri-OS/YuriCore-9B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    dtype=torch.bfloat16,
    device_map="auto",
)

messages = [
    {"role": "system", "content": "You are a warm, witty companion."},
    {"role": "user", "content": "Hey, what should we cook tonight?"},
]
prompt = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=512, temperature=0.7, top_p=0.9)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
```

### Local Inference (GGUF)

For LM Studio, `llama.cpp`, or Ollama, see [Yuri-OS/YuriCore-9B-GGUF](https://huggingface.co/Yuri-OS/YuriCore-9B-GGUF).

## License & Acknowledgments

Released under **Apache 2.0** (inherited from the Qwen3.5 / base model lineage).

Thanks to the Qwen team, `petruhonk` for the base distill checkpoint, the creators of CoSER, PIPPA, ToolACE, and When2Call, and the Unsloth / TRL / `llama.cpp` ecosystems.