Download sail_scripts/kernel/test_kernel.py from muterornament/sail: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/muterornament/sail/resolve/main/sail_scripts/kernel/test_kernel.py
- Command line
-
hf download hf://muterornament/sail/sail_scripts/kernel/test_kernel.py
-
curl -L -o test_kernel.py https://huggingface.co/muterornament/sail/resolve/main/sail_scripts/kernel/test_kernel.py
1.48 kB
| import sail_kernel | |
| print("sail_kernel version:", sail_kernel.__version__) | |
| # Test 1: text cleaning | |
| result = sail_kernel.clean_text("<b>Hello World</b>\n\n\n\nFoo") | |
| print("clean_text:", repr(result)) | |
| # Test 2: batch cleaning | |
| batch = sail_kernel.clean_batch(["<p>First</p>", "<b>Second text</b>", "Normal text"]) | |
| print("clean_batch:", batch) | |
| # Test 3: dynamic token budget | |
| budget = sail_kernel.compute_budget("Define photosynthesis. [2 marks]") | |
| print("budget (2 marks):", budget) | |
| budget8 = sail_kernel.compute_budget("Explain with examples how TCP/IP works. (8 marks)") | |
| print("budget (8 marks):", budget8) | |
| budget_deep = sail_kernel.compute_budget("Analyze and compare the causes of WW1 and WW2 in detail step-by-step") | |
| print("budget (deep Q):", budget_deep) | |
| # Test 4: reward scorer | |
| score = sail_kernel.score_output("## Answer\n\n**Key point**: Use `cargo build`.\n\n- Item 1\n- Item 2", 500) | |
| print("format-rich score:", score.format_score, "total:", score.total_score) | |
| score_plain = sail_kernel.score_output("just plain text with no formatting at all", 100) | |
| print("plain text score:", score_plain.format_score, "total:", score_plain.total_score) | |
| # Test 5: batch reward scoring | |
| scores = sail_kernel.score_batch([ | |
| "## Section\n\n**Bold**: some content\n\n- list item", | |
| "plain text answer", | |
| "## Deep Answer\n\n**Critical**: step by step analysis\n\n```python\ncode```" | |
| ], target_tokens=300) | |
| print("batch scores:", scores) | |
| print("\nAll SAIL kernel tests PASSED!") | |