Spaces:
Running
Running
Download scripts/experiments/verify_fieldfit_ml.py from ArielJoe/Prompt-Builder: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/ArielJoe/Prompt-Builder/resolve/main/scripts/experiments/verify_fieldfit_ml.py
- Command line
-
hf download hf://spaces/ArielJoe/Prompt-Builder/scripts/experiments/verify_fieldfit_ml.py
-
curl -L -o verify_fieldfit_ml.py https://huggingface.co/spaces/ArielJoe/Prompt-Builder/resolve/main/scripts/experiments/verify_fieldfit_ml.py
1.48 kB
| """Quick check for Field-Fit ML layer: cross-field misplacement detection + dedup.""" | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "src")) | |
| from field_fit.field_fit_detector import FieldFitDetector | |
| det = FieldFitDetector(use_ml=True) | |
| det.load() | |
| print("ML active:", det.ml_active, "\n") | |
| # (text, current_field, expected: target_field or None if clean) | |
| CASES = [ | |
| ("Kamu adalah seorang dokter spesialis anak", "task", "role"), # rule+ML, dedup -> role | |
| ("Sajikan dalam bentuk tabel dengan kolom tujuan", "task", "outputFormat"), | |
| ("Khusus untuk siswa kelas 3 SD", "task", "audience"), | |
| ("Jangan lebih dari 100 kata", "task", "constraints"), | |
| ("Gunakan bahasa yang ramah dan santai", "context", "tone"), | |
| ("Buatkan rencana pembelajaran tentang fotosintesis", "task", None), # valid in Task | |
| ("Untuk kelas 7 SMP, durasi 80 menit", "context", None), # valid in Context | |
| ("Gunakan buku paket halaman 20-35", "references", None), # valid in References | |
| ] | |
| ok = 0 | |
| for text, cur, expect in CASES: | |
| fs = det.detect(text, cur) | |
| got = fs[0].target_field if fs else None | |
| n = len(fs) | |
| verdict = "OK " if got == expect else "DIFF" | |
| if got == expect: | |
| ok += 1 | |
| print(f"[{verdict}] field={cur:11} -> target={str(got):12} (expected {str(expect):12}) " | |
| f"n={n} '{text[:42]}'") | |
| print(f"\nMatched expected: {ok}/{len(CASES)}") | |