tusarway commited on
Commit
cdf97c0
Β·
verified Β·
1 Parent(s): 020890a

πŸ“„ Update README β€” ReFusion 3.0 full documentation

Browse files
Files changed (1) hide show
  1. README.md +273 -147
README.md CHANGED
@@ -1,199 +1,325 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
 
 
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a πŸ€— transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
 
40
- ### Direct Use
 
 
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
 
 
 
 
 
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
 
 
55
 
56
- [More Information Needed]
 
 
57
 
58
- ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
 
 
 
 
 
61
 
62
- [More Information Needed]
63
 
64
- ### Recommendations
 
 
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
 
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
69
 
70
- ## How to Get Started with the Model
 
71
 
72
- Use the code below to get started with the model.
 
73
 
74
- [More Information Needed]
75
 
76
  ## Training Details
77
 
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
 
 
 
 
 
 
 
 
 
 
 
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
 
163
- #### Hardware
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
- [More Information Needed]
166
 
167
- #### Software
168
 
169
- [More Information Needed]
 
 
 
 
170
 
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
176
 
177
- [More Information Needed]
 
 
 
 
 
 
 
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
 
 
 
 
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
 
 
 
 
 
 
 
 
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
 
 
198
 
199
- [More Information Needed]
 
1
  ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ tags:
6
+ - ai-detection
7
+ - text-classification
8
+ - qwen3
9
+ - peft
10
+ - lora
11
+ - refusion
12
+ - ai-generated-text
13
+ - human-written-text
14
+ pipeline_tag: text-classification
15
+ model-index:
16
+ - name: ReFusion 3.0
17
+ results:
18
+ - task:
19
+ type: text-classification
20
+ name: AI Text Detection
21
+ metrics:
22
+ - type: accuracy
23
+ value: 1.0000
24
+ - type: f1
25
+ value: 1.0000
26
+ - type: precision
27
+ value: 1.0000
28
+ - type: recall
29
+ value: 1.0000
30
  ---
31
 
32
+ <div align="center">
33
 
34
+ # ReFusion 3.0
35
 
36
+ ### AI Text Detection Model
37
 
38
+ **100% Accuracy Β· 0% False Positives Β· 0% False Negatives**
39
 
40
+ *Fine-tuned by [Tusar Akon](https://ai-detector.tusarakon.com) Β· Built on Qwen3-0.6B*
41
 
42
+ [![Live Demo](https://img.shields.io/badge/πŸš€_Live_Demo-ai--detector.tusarakon.com-black?style=for-the-badge)](https://ai-detector.tusarakon.com)
43
+ [![HuggingFace](https://img.shields.io/badge/πŸ€—_Model-tusarway%2Frefusion--3-orange?style=for-the-badge)](https://huggingface.co/tusarway/refusion-3)
44
+ [![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](LICENSE)
45
 
46
+ </div>
47
 
48
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ ## Overview
51
 
52
+ **ReFusion 3.0** is a production-grade AI text detector fine-tuned from `Qwen/Qwen3-0.6B` using
53
+ Parameter-Efficient Fine-Tuning (LoRA). It classifies text as either **Human Written** or **AI Generated**
54
+ with sentence-level granularity, achieving perfect scores on a 3,000-sample held-out test set.
55
 
56
+ It powers the live API at [ai-detector.tusarakon.com](https://ai-detector.tusarakon.com),
57
+ serving real-time detection with per-sentence highlighting and tiered API access.
58
 
59
+ ---
60
 
61
+ ## Performance
62
 
63
+ ### Held-Out Test Set (3,000 samples, never seen during training)
64
 
65
+ | Metric | HUMAN | AI | Overall |
66
+ |---|---|---|---|
67
+ | **Precision** | 1.0000 | 1.0000 | **1.0000** |
68
+ | **Recall** | 1.0000 | 1.0000 | **1.0000** |
69
+ | **F1 Score** | 1.0000 | 1.0000 | **1.0000** |
70
+ | **Accuracy** | β€” | β€” | **100%** |
71
 
72
+ ### Confusion Matrix
73
 
74
+ ```
75
+ Predicted AI Predicted Human
76
+ True AI 1,515 0
77
+ True Human 0 1,485
78
 
79
+ False Positive Rate: 0.00% (human text flagged as AI)
80
+ False Negative Rate: 0.00% (AI text missed as human)
81
+ ```
82
 
83
+ ### Training Curve
84
 
85
+ | Epoch | Train Loss | Val Loss | Accuracy | F1 |
86
+ |---|---|---|---|---|
87
+ | 1 | 0.2408 | 0.1182 | 99.97% | 0.9997 |
88
+ | 2 | 0.2382 | 0.1191 | 99.87% | 0.9987 |
89
+ | 3 | 0.2340 | 0.1181 | 99.93% | 0.9993 |
90
+ | 4 | 0.2339 | 0.1170 | 100% | 1.0000 |
91
+ | 5–10 | 0.2339β†’0.2338 | 0.1169β†’0.1169 | 100% | 1.0000 |
92
 
93
+ ### Live Inference Results
94
 
95
+ ```
96
+ βœ… [Casual Reddit] Expected: HUMAN β†’ Got: HUMAN
97
+ AI 2.6% [β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] Human 97.4%
98
 
99
+ βœ… [GPT-style formal] Expected: AI β†’ Got: AI
100
+ AI 96.0% [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘] Human 4.0%
101
 
102
+ βœ… [Personal story] Expected: HUMAN β†’ Got: HUMAN
103
+ AI 2.6% [β–‘β–‘οΏ½οΏ½οΏ½β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] Human 97.4%
104
 
105
+ βœ… [Academic AI] Expected: AI β†’ Got: AI
106
+ AI 95.4% [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘] Human 4.6%
107
 
108
+ Score: 6/6 (100%)
109
+ ```
110
 
111
+ ---
112
 
113
  ## Training Details
114
 
115
+ ### Architecture
116
+
117
+ | Component | Value |
118
+ |---|---|
119
+ | **Base Model** | `Qwen/Qwen3-0.6B` |
120
+ | **Method** | LoRA (PEFT) |
121
+ | **LoRA Rank** | 64 |
122
+ | **LoRA Alpha** | 128 |
123
+ | **Target Modules** | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
124
+ | **Trainable Params** | 40,372,224 (6.34% of total) |
125
+ | **Total Params** | 636,424,192 |
126
+ | **Precision** | bf16 (native A100) |
127
+
128
+ ### Training Configuration
129
+
130
+ | Hyperparameter | Value |
131
+ |---|---|
132
+ | **Epochs** | 10 |
133
+ | **Batch Size** | 32 per device |
134
+ | **Gradient Accumulation** | 2 steps |
135
+ | **Effective Batch Size** | 64 |
136
+ | **Learning Rate** | 3e-5 |
137
+ | **LR Scheduler** | Cosine decay |
138
+ | **Warmup Ratio** | 5% |
139
+ | **Weight Decay** | 0.01 |
140
+ | **Label Smoothing** | 0.05 |
141
+ | **Max Sequence Length** | 512 tokens |
142
+ | **Hardware** | A100 80GB |
143
+ | **Training Time** | 4h 32m |
144
+
145
+ ### Dataset
146
+
147
+ **50,000 balanced samples** (25,000 human Β· 25,000 AI) across 6 diverse sources,
148
+ collected concurrently via multi-threaded streaming:
149
+
150
+ | Source | Type | Samples | Writing Style |
151
+ |---|---|---|---|
152
+ | RAID Dataset | Human | 6,250 | Formal β€” Wikipedia, news articles |
153
+ | ELI5 / Reddit | Human | 6,250 | Casual β€” conversational Q&A |
154
+ | WritingPrompts | Human | 6,250 | Creative β€” storytelling, fiction |
155
+ | ArXiv Abstracts | Human | 6,250 | Academic β€” scientific writing |
156
+ | artem9k Detection Pile | AI | 12,500 | Multi-model AI outputs |
157
+ | RAID AI Portion | AI | 12,500 | 11 different AI model outputs |
158
+
159
+ **Data split:** 88% train (44,000) Β· 6% validation (3,000) Β· 6% test (3,000)
160
+
161
+ The diversity of human writing styles (formal, casual, creative, academic) is what
162
+ enables the model to correctly classify both Reddit posts and news articles as human,
163
+ without being tricked by writing style alone.
164
 
165
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
+ ## Usage
168
+
169
+ ### Quick Start
170
+
171
+ ```python
172
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
173
+ from peft import PeftModel
174
+ import torch
175
+
176
+ # Load
177
+ tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B", trust_remote_code=True)
178
+ tokenizer.pad_token = tokenizer.eos_token
179
+
180
+ base = AutoModelForSequenceClassification.from_pretrained(
181
+ "Qwen/Qwen3-0.6B",
182
+ num_labels=2,
183
+ id2label={0: "HUMAN", 1: "AI"},
184
+ label2id={"HUMAN": 0, "AI": 1},
185
+ torch_dtype=torch.bfloat16,
186
+ trust_remote_code=True,
187
+ )
188
+ model = PeftModel.from_pretrained(base, "tusarway/refusion-3")
189
+ model.eval()
190
+
191
+ # Detect
192
+ def detect(text: str) -> dict:
193
+ inputs = tokenizer(
194
+ text, return_tensors="pt",
195
+ truncation=True, max_length=512, padding=True
196
+ )
197
+ with torch.inference_mode():
198
+ logits = model(**inputs).logits
199
+ probs = torch.softmax(logits, dim=-1)[0]
200
+ label = "AI" if probs[1] > probs[0] else "HUMAN"
201
+ return {
202
+ "label": label,
203
+ "ai_score": round(float(probs[1]), 4),
204
+ "human_score": round(float(probs[0]), 4),
205
+ "confidence": f"{max(probs[0], probs[1]):.1%}",
206
+ }
207
+
208
+ # Example
209
+ result = detect("This is the text you want to analyze...")
210
+ print(result)
211
+ # β†’ {'label': 'AI', 'ai_score': 0.9604, 'human_score': 0.0396, 'confidence': '96.0%'}
212
+ ```
213
+
214
+ ### Sentence-Level Detection
215
+
216
+ ```python
217
+ import re
218
+
219
+ def detect_sentences(text: str) -> list[dict]:
220
+ sentences = re.split(r'(?<=[.!?])\s+', text.strip())
221
+ return [
222
+ {"sentence": s, **detect(s)}
223
+ for s in sentences if s.strip()
224
+ ]
225
+
226
+ results = detect_sentences(your_text)
227
+ for r in results:
228
+ icon = "πŸ€–" if r["label"] == "AI" else "✍️"
229
+ print(f"{icon} {r['confidence']} β€” {r['sentence'][:80]}...")
230
+ ```
231
+
232
+ ### Via REST API (Live)
233
+
234
+ ```bash
235
+ # Free tier (500 words, 5 checks/day)
236
+ curl -X POST https://tusarway-tus-ai-detector-api.hf.space/detect \
237
+ -H "Content-Type: application/json" \
238
+ -H "X-API-Key: free-demo-key" \
239
+ -d '{"text": "Your text to analyze goes here..."}'
240
+ ```
241
+
242
+ Response:
243
+ ```json
244
+ {
245
+ "verdict": "AI Generated",
246
+ "ai_score": 0.9604,
247
+ "human_score": 0.0396,
248
+ "metrics": {
249
+ "ai_percentage": 96.0,
250
+ "human_percentage": 4.0,
251
+ "total_words": 142,
252
+ "total_chars": 891,
253
+ "total_sentences": 6
254
+ },
255
+ "sentences": [
256
+ {
257
+ "text": "Learning guitar is a rewarding journey...",
258
+ "is_ai": true,
259
+ "ai_score": 0.9604,
260
+ "human_score": 0.0396
261
+ }
262
+ ]
263
+ }
264
+ ```
265
 
266
+ ---
267
 
268
+ ## API Tiers
269
 
270
+ | Tier | Words / Check | Checks / Day | Access |
271
+ |---|---|---|---|
272
+ | **Free** | 500 | 5 | `free-demo-key` |
273
+ | **Premium** | 10,000 | 100 | Contact via LinkedIn |
274
+ | **Premium Plus** | Unlimited | Unlimited | Contact via LinkedIn |
275
 
276
+ β†’ **Get a key:** [linkedin.com/in/imtrt](https://www.linkedin.com/in/imtrt/)
277
 
278
+ ---
279
 
280
+ ## Version History
281
 
282
+ | Version | Model | Samples | Accuracy | Notes |
283
+ |---|---|---|---|---|
284
+ | v1 | Qwen3-0.6B (generative) | 10,000 | ~50% | Mode collapse β€” always predicted AI |
285
+ | v2 | Qwen3-0.6B (classifier) | 10,000 | ~85% | Fixed architecture, dataset imbalance |
286
+ | v3 | Qwen2.5-0.5B | 10,000 | ~91% | Switched dataset to RAID |
287
+ | v4 | Qwen3-0.6B | 10,000 | ~93% | HC3 dataset attempt, reverted to RAID |
288
+ | v5 | Qwen3-0.6B | 10,000 | ~99% | Balanced dataset, proper regularization |
289
+ | **ReFusion 3.0** | **Qwen3-0.6B** | **50,000** | **100%** | **6-source diverse dataset, r=64 LoRA, A100 native bf16** |
290
 
291
+ ---
292
 
293
+ ## Limitations
294
 
295
+ - Works best on texts of **100+ words**. Short texts (< 30 words) may be unreliable.
296
+ - Trained primarily on **English text**. Other languages are unsupported.
297
+ - May have reduced accuracy on **very recent AI models** released after the training data cutoff.
298
+ - 100% eval accuracy reflects strong generalization on this dataset;
299
+ real-world accuracy on adversarial or paraphrased AI text may vary.
300
 
301
+ ---
302
 
303
+ ## Citation
304
 
305
+ ```bibtex
306
+ @misc{refusion3_2026,
307
+ author = {Tusar Akon},
308
+ title = {ReFusion 3.0: A Fine-Tuned AI Text Detection Model},
309
+ year = {2026},
310
+ publisher = {Hugging Face},
311
+ url = {https://huggingface.co/tusarway/refusion-3}
312
+ }
313
+ ```
314
 
315
+ ---
316
 
317
+ ## About
318
 
319
+ Built by **Tusar Akon** as part of a fully open-source AI detection pipeline.
320
 
321
+ - 🌐 **Live tool:** [ai-detector.tusarakon.com](https://ai-detector.tusarakon.com)
322
+ - πŸ’Ό **Contact:** [linkedin.com/in/imtrt](https://www.linkedin.com/in/imtrt/)
323
+ - πŸ€— **HuggingFace:** [huggingface.co/tusarway](https://huggingface.co/tusarway)
324
 
325
+ *If this model helped you, consider starring the repo ⭐*