Spaces:
Sleeping
Sleeping
Download scripts/test_all_layers.py from Abdulahad79/KingsGuard: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/Abdulahad79/KingsGuard/resolve/main/scripts/test_all_layers.py
- Command line
-
hf download hf://spaces/Abdulahad79/KingsGuard/scripts/test_all_layers.py
-
curl -L -o test_all_layers.py https://huggingface.co/spaces/Abdulahad79/KingsGuard/resolve/main/scripts/test_all_layers.py
1.12 kB
| import os | |
| import sys | |
| import json | |
| # Add project root and core to sys.path | |
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) | |
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "core"))) | |
| from tools import KingsGuardL1Tool, PerplexityCalcTool, KingsGuardL2Tool, KingsGuardL3Tool | |
| def test(): | |
| prompt = "What is the weather today?" | |
| print("--- L1 ---") | |
| try: | |
| print(KingsGuardL1Tool()._run(prompt)) | |
| except Exception as e: | |
| print(f"Exception: {e}") | |
| print("\n--- L1 PPL ---") | |
| try: | |
| print(PerplexityCalcTool()._run(prompt)) | |
| except Exception as e: | |
| print(f"Exception: {e}") | |
| print("\n--- L2 ---") | |
| try: | |
| print(KingsGuardL2Tool()._run(prompt)) | |
| except Exception as e: | |
| print(f"Exception: {e}") | |
| print("\n--- L3 ---") | |
| try: | |
| # Pass dummy values for l1_score and l2_mse | |
| print(KingsGuardL3Tool()._run(prompt, f"Execute: {prompt}", 0.542, 0.01)) | |
| except Exception as e: | |
| print(f"Exception: {e}") | |
| if __name__ == "__main__": | |
| test() | |