File size: 7,115 Bytes
8b23def
 
 
 
 
 
 
 
 
 
 
 
 
2a9da9a
8b23def
 
2a9da9a
8b23def
295799d
8b23def
 
 
 
 
 
 
 
 
 
2a9da9a
8b23def
 
 
2a9da9a
8b23def
 
 
2a9da9a
 
 
8b23def
2a9da9a
8b23def
 
 
 
 
 
 
 
8513089
8b23def
 
 
2a9da9a
8b23def
 
 
 
 
2a9da9a
8b23def
2a9da9a
8b23def
2a9da9a
 
 
 
8b23def
2a9da9a
8b23def
2a9da9a
8b23def
 
 
 
 
 
 
 
2a9da9a
 
 
8b23def
 
 
2a9da9a
8b23def
 
 
2a9da9a
 
 
 
 
 
8b23def
2a9da9a
 
 
 
 
8b23def
2a9da9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b23def
 
 
 
 
 
2a9da9a
 
 
 
 
8b23def
 
 
 
 
 
 
2a9da9a
 
 
8b23def
 
 
2a9da9a
 
8b23def
 
 
2a9da9a
8b23def
2a9da9a
8b23def
 
 
 
 
2a9da9a
8b23def
 
2a9da9a
8b23def
2a9da9a
 
 
 
8b23def
 
 
 
 
 
 
 
 
 
2a9da9a
 
8b23def
 
 
 
2a9da9a
 
 
 
8b23def
 
 
 
 
 
 
 
2a9da9a
 
8b23def
 
2a9da9a
8b23def
 
 
 
 
2a9da9a
8b23def
2a9da9a
 
8b23def
 
 
 
 
 
 
 
 
 
2a9da9a
 
 
 
8b23def
 
 
 
 
 
 
 
2a9da9a
8b23def
 
 
 
 
2a9da9a
 
 
 
 
8b23def
 
 
 
 
 
db57b22
8b23def
 
db57b22
 
8b23def
db57b22
8b23def
 
 
 
db57b22
8b23def
db57b22
8b23def
db57b22
8b23def
 
db57b22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b23def
c73b47c
 
 
 
 
 
 
 
 
 
 
 
 
 
8b23def
 
1415982
8b23def
 
aba06e6
 
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
---
license: mit
base_model:
  - FacebookAI/xlm-roberta-large
language:
  - ru
tags:
  - Reasoning
  - Logical-Analysis
  - Text-Classification
  - AI-Safety
  - Evaluation
  - Judge-model
  - Argumentation
---

[![Hugging Face](https://img.shields.io/badge/Hugging%20Face-model-blue)](https://huggingface.co/skatzR/RQA-X1.1)

# 🧠 RQA — Reasoning Quality Analyzer (R1)

**RQA** is a **judge model** designed to evaluate the *quality of reasoning in text*.  
It does **not** generate, rewrite, or explain content — instead, it **assesses whether a text contains logical problems**, and if so, **what kind**.

> **RQA is a judge, not a teacher and not a generator.**

---

## 🔍 What Problem Does RQA Solve?

Texts written by humans or LLMs can:

- sound coherent,
- use correct vocabulary,
- appear persuasive,

…but still contain **logical problems** that are:

- implicit,
- structural,
- hidden in argumentation.

**RQA focuses strictly on reasoning quality**, not on style, sentiment, or factual correctness.

---

## 🧩 Model Overview

| Property | Value |
|--------|------|
| **Model Type** | Judge / Evaluator |
| **Base Encoder** | [XLM-RoBERTa Large](https://huggingface.co/FacebookAI/xlm-roberta-large) |
| **Pooling** | Mean pooling |
| **Heads** | 2 (binary + multi-label) |
| **Language** | Russian 🇷🇺 |
| **License** | MIT |

---

## 🧠 What the Model Predicts

RQA produces **two independent signals** that are combined at inference time:

### 1️⃣ Logical Issue Detection (Binary)

- `has_issue ∈ {false, true}`
- Calibrated probability available
- Designed to answer:  
  **“Does this text contain a reasoning problem?”**

### 2️⃣ Error Type Signals (Multi-label)

The model estimates probabilities for specific error types:

- `false_causality`
- `unsupported_claim`
- `overgeneralization`
- `missing_premise`
- `contradiction`
- `circular_reasoning`

⚠️ **Important**  
Error type probabilities are **diagnostic signals**, not mandatory labels.  
They are surfaced **only if `has_issue == true`** during inference.

---

## 🟡 Hidden Logical Problems (Key Concept)

RQA explicitly distinguishes between:

### 🔴 Explicit Logical Errors
Clearly identifiable fallacies:
- invalid causal inference
- circular reasoning
- contradictions
- unsupported claims

### 🟡 Hidden Logical Problems
Texts that are:
- argumentative or persuasive,
- structurally incomplete,
- reliant on implicit assumptions,

but **do not contain a cleanly classifiable fallacy**.

Examples:
- missing or unstated premises
- rhetorical generalizations
- context-dependent claims

Hidden problems are **not misclassifications** —  
they are an **intended diagnostic category**.

---

## ⚖️ Inference Logic (Important)

The model uses **decision logic on top of raw logits**:

- Binary head decides **whether a problem exists**
- Error heads provide **type-level evidence**
- If:
  - `has_issue == false`
  - but error probabilities are non-zero  
  → the text may be flagged as **borderline** or **hidden problem**

This prevents:
- false positive error labels,
- incoherent outputs,
- over-triggering on clean factual texts.

---

## 🏗️ Architecture Details

- **Encoder**: XLM-RoBERTa Large (pretrained weights preserved)
- **Pooling**: Mean pooling (robust for long texts)
- **Two independent projections**:
  - binary reasoning head
  - multi-label error head
- Separate dropout and projections to reduce negative transfer

---

## 🎓 Training Philosophy

### 🔒 Strict Data Contract

- Logical texts **contain no errors**
- Hidden-problem texts **contain no explicit fallacies**
- Invalid samples are **removed**, not auto-corrected

### ⚖️ Balanced Difficulty

- Hidden problems ≤ **30%** of problematic texts
- Prevents collapse into vague uncertainty detection

### 🎯 Loss Design

- Binary BCE for issue detection
- Masked multi-label loss for error types
- Stability-oriented multi-task optimization

---

## 🌡️ Confidence Calibration

RQA applies **post-hoc temperature scaling**:

- Separate calibration for:
  - `has_issue`
  - each error type
- Enables:
  - meaningful probabilities
  - safe threshold tuning
  - production use without retraining

---

## 🚀 Intended Use

### ✅ Recommended for:

- Reasoning quality evaluation
- LLM output auditing
- AI safety pipelines
- Argumentation analysis
- Pre-filtering / routing systems

### ❌ Not intended for:

- Text generation
- Error correction
- Explanation or tutoring
- Grammar or style analysis
- Fact checking

---

## 🧪 Model Behavior

- Conservative by design
- Optimized for **low false positives**
- Explicitly robust to:
  - topic changes
  - writing style
  - emotional tone

RQA judges **logical structure**, not persuasion quality.

---

## 📚 Training Data (High-level)

- **Custom-built dataset**
- **Thousands of long-form argumentative texts**
- **Multiple domains and reasoning styles**
- Carefully controlled balance of:
  - logical texts
  - explicit errors
  - hidden problems

> The dataset was designed specifically for **judge behavior**, not for text generation.

---

## ⚠️ Limitations

- Logical validity ≠ factual correctness
- Purely descriptive texts may still trigger *diagnostic signals*
- Highly rhetorical or persuasive texts can be flagged as **hidden problems**
- Philosophical disagreement is **not always** a logical error

---

## 🧩 Philosophy

> **Good reasoning is not about sounding convincing —  
> it is about what actually follows from what.**

RQA is built around this principle.

---

## 🔧 Implementation Details

- Custom Hugging Face architecture (`modeling_rqa.py`)
- Requires:
  - `trust_remote_code=True`
- Uses `safetensors`
- No `.bin` weights (this is expected behavior)

---

## 🚀 Quick Start

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

device = "cuda" if torch.cuda.is_available() else "cpu"

tokenizer = AutoTokenizer.from_pretrained(
    "skatzR/RQA-R1",
    trust_remote_code=True
)

model = AutoModel.from_pretrained(
    "skatzR/RQA-R1",
    trust_remote_code=True
).to(device)

model.eval()

```
---

## 🧠 Reference Inference Logic

RQA is designed to be used with **explicit post-processing logic**, including:

- temperature scaling
- thresholding
- disagreement diagnostics
- hidden-problem detection

A **fully working reference implementation** is provided here:


👉 **[📄 inference.py](https://huggingface.co/skatzR/RQA-X1.1/blob/main/inference.py) — Reference Inference Implementation**

---
## ✅ Example
```
📄 Текст:
После того как в городе открыли новый торговый центр, увеличилось количество разводов. 
Следовательно, открытие торгового центра разрушает семьи.

🔎 Обнаружена проблема: ДА (100.00%)

❌ Явные логические ошибки:
  • Ложная причинно-следственная связь — 95.95%

📊 Disagreement: 0.034
```
---

## 📜 License

MIT

---