Spaces:
Sleeping
Sleeping
Commit
·
c994382
1
Parent(s):
8205d6b
README rendering issue fixed
Browse files
README.md
CHANGED
|
@@ -162,7 +162,9 @@ This section provides the exact metric definitions implemented in `metrics/` and
|
|
| 162 |
### 1) Perplexity (25% weight)
|
| 163 |
|
| 164 |
**Definition**
|
| 165 |
-
|
|
|
|
|
|
|
| 166 |
|
| 167 |
**Implementation sketch**
|
| 168 |
```python
|
|
@@ -187,7 +189,9 @@ elif domain == Domain.SOCIAL_MEDIA:
|
|
| 187 |
### 2) Entropy (20% weight)
|
| 188 |
|
| 189 |
**Shannon entropy (token level)**
|
| 190 |
-
|
|
|
|
|
|
|
| 191 |
|
| 192 |
**Implementation sketch**
|
| 193 |
```python
|
|
@@ -203,10 +207,14 @@ def calculate_text_entropy(text):
|
|
| 203 |
### 3) Structural Metric (15% weight)
|
| 204 |
|
| 205 |
**Burstiness**
|
| 206 |
-
|
|
|
|
|
|
|
| 207 |
|
| 208 |
**Uniformity**
|
| 209 |
-
|
|
|
|
|
|
|
| 210 |
|
| 211 |
**Sketch**
|
| 212 |
```python
|
|
@@ -223,7 +231,9 @@ def calculate_burstiness(text):
|
|
| 223 |
### 4) Semantic Analysis (15% weight)
|
| 224 |
|
| 225 |
**Coherence (sentence embedding cosine similarity)**
|
| 226 |
-
|
|
|
|
|
|
|
| 227 |
|
| 228 |
**Sketch**
|
| 229 |
```python
|
|
@@ -250,7 +260,9 @@ def calculate_linguistic_features(text, nlp_model):
|
|
| 250 |
### 6) DetectGPT (10% weight)
|
| 251 |
|
| 252 |
**Stability under perturbation** (curvature principle)
|
| 253 |
-
|
|
|
|
|
|
|
| 254 |
|
| 255 |
```python
|
| 256 |
def detect_gpt_score(text, model, num_perturbations=20):
|
|
|
|
| 162 |
### 1) Perplexity (25% weight)
|
| 163 |
|
| 164 |
**Definition**
|
| 165 |
+
```math
|
| 166 |
+
Perplexity = \exp\left(-\frac{1}{N}\sum_{i=1}^N \log P(w_i\mid context)\right)
|
| 167 |
+
```
|
| 168 |
|
| 169 |
**Implementation sketch**
|
| 170 |
```python
|
|
|
|
| 189 |
### 2) Entropy (20% weight)
|
| 190 |
|
| 191 |
**Shannon entropy (token level)**
|
| 192 |
+
```math
|
| 193 |
+
H(X) = -Σ p(x_i) * log₂ p(x_i)
|
| 194 |
+
```
|
| 195 |
|
| 196 |
**Implementation sketch**
|
| 197 |
```python
|
|
|
|
| 207 |
### 3) Structural Metric (15% weight)
|
| 208 |
|
| 209 |
**Burstiness**
|
| 210 |
+
```math
|
| 211 |
+
Burstiness=\frac{\sigma-\mu}{\sigma+\mu}\ where \(\mu\)=mean sentence length, \(\sigma\)=std dev
|
| 212 |
+
```
|
| 213 |
|
| 214 |
**Uniformity**
|
| 215 |
+
```math
|
| 216 |
+
Uniformity = 1 - \frac{\sigma}{\mu}\
|
| 217 |
+
```
|
| 218 |
|
| 219 |
**Sketch**
|
| 220 |
```python
|
|
|
|
| 231 |
### 4) Semantic Analysis (15% weight)
|
| 232 |
|
| 233 |
**Coherence (sentence embedding cosine similarity)**
|
| 234 |
+
```math
|
| 235 |
+
Coherence=\frac{1}{n}\sum_{i=1}^{n-1} \cos(e_i, e_{i+1})\
|
| 236 |
+
```
|
| 237 |
|
| 238 |
**Sketch**
|
| 239 |
```python
|
|
|
|
| 260 |
### 6) DetectGPT (10% weight)
|
| 261 |
|
| 262 |
**Stability under perturbation** (curvature principle)
|
| 263 |
+
```math
|
| 264 |
+
Stability = \frac{1}{n}\sum_{j} \left|\log P(x) - \log P(x_{perturbed}^j)\right|\
|
| 265 |
+
```
|
| 266 |
|
| 267 |
```python
|
| 268 |
def detect_gpt_score(text, model, num_perturbations=20):
|