johnbean393 commited on
Commit
e8850c3
·
verified ·
1 Parent(s): d3cb7c8

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +126 -0
README.md ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ base_model:
6
+ - Qwen/Qwen3-Embedding-0.6B
7
+ pipeline_tag: text-classification
8
+ ---
9
+
10
+ # Argus
11
+
12
+ **AI-Generated Text Detection Classifier**
13
+
14
+ Argus is a binary text classifier that detects whether text was written by a human or generated by AI. It is fine-tuned from [Qwen/Qwen3-Embedding-0.6B](https://huggingface.co/Qwen/Qwen3-Embedding-0.6B) using a classification head with last-token pooling.
15
+
16
+ ## Features
17
+
18
+ - **High Accuracy**: Achieves near-perfect classification on held-out test data
19
+ - **Long Context**: Supports sequences up to 4,096 tokens with automatic chunking for longer texts
20
+ - **Fast Inference**: Optimized with Flash Attention 2 and bfloat16 precision on CUDA
21
+ - **Batch Processing**: Parallel tokenization and batched inference for high throughput
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install torch transformers
27
+ ```
28
+
29
+ ## Minimal Inference Example
30
+
31
+ ```python
32
+ import torch
33
+ import torch.nn as nn
34
+ import torch.nn.functional as F
35
+ from transformers import AutoModel, AutoTokenizer, AutoConfig
36
+
37
+ class Qwen3ForSequenceClassification(nn.Module):
38
+ """Qwen3-Embedding with classification head using last-token pooling."""
39
+
40
+ def __init__(self, model_name="Qwen/Qwen3-Embedding-0.6B", num_labels=2):
41
+ super().__init__()
42
+ self.encoder = AutoModel.from_pretrained(
43
+ model_name,
44
+ torch_dtype=torch.bfloat16,
45
+ trust_remote_code=True,
46
+ )
47
+ hidden_size = AutoConfig.from_pretrained(model_name).hidden_size
48
+ self.classifier = nn.Linear(hidden_size, num_labels)
49
+
50
+ def forward(self, input_ids, attention_mask):
51
+ outputs = self.encoder(input_ids=input_ids, attention_mask=attention_mask)
52
+ # Last-token pooling (not CLS token)
53
+ pooled = outputs.last_hidden_state[:, -1]
54
+ return self.classifier(pooled)
55
+
56
+
57
+ # Load model and weights
58
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
59
+ model = Qwen3ForSequenceClassification()
60
+ model.load_state_dict(torch.load("weights/model.pt", map_location=device, weights_only=True))
61
+ model.to(device).eval()
62
+
63
+ # Load tokenizer
64
+ tokenizer = AutoTokenizer.from_pretrained("weights/", padding_side="left", trust_remote_code=True)
65
+ if tokenizer.pad_token is None:
66
+ tokenizer.pad_token = tokenizer.eos_token
67
+
68
+ # Inference
69
+ text = "Your text to classify here."
70
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=4096)
71
+ inputs = {k: v.to(device) for k, v in inputs.items()}
72
+
73
+ with torch.no_grad():
74
+ logits = model(inputs["input_ids"], inputs["attention_mask"])
75
+ probs = F.softmax(logits.float(), dim=-1)[0]
76
+
77
+ label = "ai" if probs[1] > probs[0] else "human"
78
+ confidence = probs[1].item() if label == "ai" else probs[0].item()
79
+
80
+ print(f"Label: {label}, Confidence: {confidence:.2%}")
81
+ # Example output: Label: human, Confidence: 94.32%
82
+ ```
83
+
84
+ ## Model Architecture
85
+
86
+ | Component | Details |
87
+ |-----------|---------|
88
+ | Base Model | Qwen/Qwen3-Embedding-0.6B |
89
+ | Hidden Size | 1024 |
90
+ | Parameters | ~600M |
91
+ | Pooling | Last-token (not CLS) |
92
+ | Classification Head | Linear (1024 → 2) |
93
+ | Precision | bfloat16 (CUDA) / float32 (CPU) |
94
+
95
+ ## Performance
96
+
97
+ | Metric | Score |
98
+ |--------|-------|
99
+ | Accuracy | 98.86% |
100
+
101
+ *Note: These metrics are from the validation set during training. Real-world performance may vary depending on the domain and AI models used to generate text.*
102
+
103
+ ## Training Data
104
+
105
+ Trained on a combination of:
106
+ - [RAID](https://huggingface.co/datasets/liamdugan/raid) - Multi-domain, multi-model dataset
107
+ - [HC3](https://huggingface.co/datasets/Hello-SimpleAI/HC3) - Human vs ChatGPT responses
108
+ - [AI-human-text](https://huggingface.co/datasets/andythetechnerd03/AI-human-text)
109
+ - [AI Text Detection Pile](https://huggingface.co/datasets/artem9k/ai-text-detection-pile)
110
+
111
+ ## License
112
+
113
+ MIT License
114
+
115
+ ## Citation
116
+
117
+ If you use Argus in your research, please cite:
118
+
119
+ ```bibtex
120
+ @software{,
121
+ title={Argus: AI-Generated Text Detection Classifier},
122
+ author={Xi Nai Lai},
123
+ year={2026},
124
+ url={https://huggingface.co/johnbean393/argus/}
125
+ }
126
+ ```