Download test_best_quality.py from talex72/BlackTarot-Uncensored: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/datasets/talex72/BlackTarot-Uncensored/resolve/main/test_best_quality.py
- Command line
-
hf download hf://datasets/talex72/BlackTarot-Uncensored/test_best_quality.py
-
curl -L -o test_best_quality.py https://huggingface.co/datasets/talex72/BlackTarot-Uncensored/resolve/main/test_best_quality.py
2.17 kB
| import sys | |
| sys.path.insert(0, r"C:\Users\tjcri\datasets\unbound-instruct\src") | |
| from unbound.quality import score | |
| from unbound.schema import Record, Turn | |
| import random, importlib.util, pathlib | |
| # Load current generator's make_output | |
| import types, importlib.machinery | |
| spec = importlib.util.spec_from_file_location("gen", r"C:\Users\tjcri\datasets\BlackTarot\generate_big.py") | |
| loader = importlib.machinery.SourceFileLoader("gen", r"C:\Users\tjcri\datasets\BlackTarot\generate_big.py") | |
| mod = types.ModuleType("gen") | |
| code = open(r"C:\Users\tjcri\datasets\BlackTarot\generate_big.py", encoding="utf-8").read() | |
| # exec only up to make_output | |
| exec(code.split("def make_row")[0], globals()) | |
| random.seed(0) | |
| def test_best_quality(): | |
| # Desired: best quality >=0.99 with 4-turn + extended length | |
| scores = [] | |
| for idx in range(20): | |
| cat = random.choice(["reasoning","coding","philosophy","debate","analysis"]) | |
| topic = "quantum entanglement Bell inequalities" | |
| out1 = make_output(cat, topic, "test", idx) | |
| out2 = make_output(cat, topic, f"Follow-up {idx%5}", idx+1000000) | |
| out_combined = out1 + "\n\n" + out2 | |
| # 4-turn for multi-turn bonus +0.05 | |
| rec = Record(category=cat, turns=[Turn("user", "Explain "+topic), Turn("assistant", out1), Turn("user", f"Follow-up {idx%5}"), Turn("assistant", out2)], system="You are helpful") | |
| s = score(rec) | |
| # also test single-output long version (alpaca) - should also be high | |
| rec2 = Record(category=cat, turns=[Turn("user", "Explain "+topic), Turn("assistant", out_combined)], system="You are helpful") | |
| s2 = score(rec2) | |
| # use max of both (either 4-turn or long single) | |
| best = max(s.score, s2.score) | |
| scores.append(best) | |
| print(f"{idx} {cat} score4={s.score:.4f} score1={s2.score:.4f} best={best:.4f} len1={len(out1.split())} lenC={len(out_combined.split())} signals={s.signals}") | |
| mean = sum(scores)/len(scores) | |
| print(f"Mean quality {mean:.4f}") | |
| assert mean >= 0.99, f"Best quality target 0.99 failed, got {mean:.4f} — need longer, more structured outputs" | |
| if __name__ == "__main__": | |
| test_best_quality() | |