Download tests/test_classifier.py from devadit15/rubriq: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/devadit15/rubriq/resolve/main/tests/test_classifier.py
- Command line
-
hf download hf://spaces/devadit15/rubriq/tests/test_classifier.py
-
curl -L -o test_classifier.py https://huggingface.co/spaces/devadit15/rubriq/resolve/main/tests/test_classifier.py
1.4 kB
| """Task classification on the sample pairs (rules; embeddings when cached).""" | |
| import samples | |
| from rubriq.classify import classify, split_instruction_and_source | |
| from rubriq.schemas import TaskType | |
| def test_summarization_detected(): | |
| c = classify(samples.SUMM_PROMPT, samples.SUMM_GOOD) | |
| assert c.task_type == TaskType.SUMMARIZATION | |
| assert c.has_source_text | |
| def test_code_detected(): | |
| c = classify(samples.CODE_PROMPT, samples.CODE_GOOD) | |
| assert c.task_type == TaskType.CODE_GENERATION | |
| def test_extraction_detected(): | |
| c = classify(samples.EXTRACT_PROMPT, samples.EXTRACT_GOOD) | |
| assert c.task_type == TaskType.EXTRACTION | |
| assert c.has_source_text | |
| def test_creative_detected(): | |
| c = classify(samples.CREATIVE_PROMPT, samples.CREATIVE_CLICHED) | |
| assert c.task_type == TaskType.CREATIVE_WRITING | |
| def test_open_qa_detected(): | |
| c = classify(samples.QA_OPEN_PROMPT, samples.QA_OPEN_RISKY) | |
| assert c.task_type == TaskType.QA_OPEN | |
| assert not c.has_source_text | |
| def test_grounded_qa_upgrade(): | |
| c = classify(samples.QA_MULTI_PROMPT, samples.QA_MULTI_PARTIAL) | |
| assert c.task_type == TaskType.QA_GROUNDED | |
| assert c.has_source_text | |
| def test_source_split_keeps_instruction(): | |
| instruction, source = split_instruction_and_source(samples.SUMM_PROMPT) | |
| assert "at most 60 words" in instruction | |
| assert source is not None and "Solheim" in source | |