Datasets:
Delete scripts/analyze_quality.py with huggingface_hub
Browse files- scripts/analyze_quality.py +0 -56
scripts/analyze_quality.py
DELETED
|
@@ -1,56 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
from __future__ import annotations
|
| 3 |
-
|
| 4 |
-
import argparse
|
| 5 |
-
import json
|
| 6 |
-
import re
|
| 7 |
-
from collections import Counter
|
| 8 |
-
from pathlib import Path
|
| 9 |
-
from typing import Any
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def read_jsonl(path: Path) -> list[dict[str, Any]]:
|
| 13 |
-
rows: list[dict[str, Any]] = []
|
| 14 |
-
if not path.exists():
|
| 15 |
-
return rows
|
| 16 |
-
with path.open("r", encoding="utf-8") as handle:
|
| 17 |
-
for line in handle:
|
| 18 |
-
line = line.strip()
|
| 19 |
-
if line:
|
| 20 |
-
rows.append(json.loads(line))
|
| 21 |
-
return rows
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
def word_count(text: Any) -> int:
|
| 25 |
-
return len(re.findall(r"\b[\w'-]+\b", str(text)))
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
def avg(values: list[float]) -> float:
|
| 29 |
-
return sum(values) / len(values) if values else 0.0
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
def main() -> None:
|
| 33 |
-
parser = argparse.ArgumentParser(description="Summarize LifeTextSingleTurnStreamingCoT v0.4 quality metrics.")
|
| 34 |
-
parser.add_argument("--data-dir", default="life_streaming_cot_dataset")
|
| 35 |
-
args = parser.parse_args()
|
| 36 |
-
|
| 37 |
-
data_dir = Path(args.data_dir) / "data"
|
| 38 |
-
rows = read_jsonl(data_dir / "train.jsonl") + read_jsonl(data_dir / "eval.jsonl")
|
| 39 |
-
hq_rows = read_jsonl(data_dir / "train_high_quality.jsonl") + read_jsonl(data_dir / "eval_high_quality.jsonl")
|
| 40 |
-
total_chunks = sum(row.get("num_chunks", 0) for row in rows)
|
| 41 |
-
skip_chunks = sum(len(row.get("skip_chunks", [])) for row in rows)
|
| 42 |
-
|
| 43 |
-
print("Quality analysis")
|
| 44 |
-
print(f"total rows: {len(rows)}")
|
| 45 |
-
print(f"high-quality rows: {len(hq_rows)}")
|
| 46 |
-
print(f"domains: {dict(sorted(Counter(row.get('domain') for row in rows).items()))}")
|
| 47 |
-
print(f"quality flags: {dict(sorted(Counter(flag for row in rows for flag in row.get('quality_flags', [])).items()))}")
|
| 48 |
-
print(f"average quality_score: {avg([float(row.get('quality_score', 0)) for row in rows]):.3f}")
|
| 49 |
-
print(f"average streaming words: {avg([word_count(row.get('streaming_reasoning', '')) for row in rows]):.2f}")
|
| 50 |
-
print(f"average deep words: {avg([word_count(row.get('deep_reasoning', '')) for row in rows]):.2f}")
|
| 51 |
-
print(f"skip ratio: {skip_chunks / total_chunks if total_chunks else 0:.4f}")
|
| 52 |
-
print(f"llm_augmented rows: {sum(1 for row in rows if row.get('llm_augmented'))}")
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
if __name__ == "__main__":
|
| 56 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|