repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
huggingface/lighteval | import tempfile
import unittest
from typing import Optional
from unittest.mock import patch
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.metrics.metrics import Metrics
from lighteval.models.dummy.dummy_model import DummyModel, DummyModelConfig
from lighteval.models.model_output imp... | ["Some textFinal: 4"]) | self.assertEqual | collection | tests/unit/pipeline/test_reasoning_tags.py | test_multiple_reasoning_tags | TestPipelineReasoningTags | 385 | null |
huggingface/lighteval | import json
import os
import pytest
from lighteval.metrics import apply_metric
from lighteval.metrics.metrics import Metrics
from lighteval.metrics.sample_preparator import (
GenerativeCorpusMetricInput,
LogprobCorpusMetricInput,
PerplexityCorpusMetricInput,
)
from lighteval.models.model_output import Mod... | cur_ref_list, rel=1e-8) | pytest.approx | complex_expr | tests/test_unit_harness_metrics.py | test_model_prediction | 134 | null | |
huggingface/lighteval | from lighteval.tasks.templates.translation import get_translation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_translation_prompt_cf_formatting():
"""
Tests that translation prompt function works cor... | [" 你好吗?"] | assert | collection | tests/unit/tasks/templates/test_translation.py | test_translation_prompt_cf_formatting | 119 | null | |
huggingface/lighteval | from unittest.mock import Mock
import pytest
from lighteval.tasks.prompt_manager import PromptManager
from lighteval.tasks.requests import Doc
class TestPromptManager:
def test_init_default_values(self):
"""Test PromptManager initialization with default values."""
pm = PromptManager()
a... | False | assert | bool_literal | tests/unit/prompt/test_prompt_manager_class.py | test_init_default_values | TestPromptManager | 37 | null |
huggingface/lighteval | import pytest
from lighteval.tasks.templates.copa import get_copa_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation
from lighteval.utils.language import Language
@pytest.mark.parametrize("cause_effect", ["cause", "effect"])
def test_copa_prompt_cf(cause_effect):
"""
Tests t... | "" | assert | string_literal | tests/unit/tasks/templates/test_copa.py | test_copa_prompt_cf | 60 | null | |
huggingface/lighteval | from lighteval.data import GenerativeTaskDataset
from lighteval.metrics.utils.metric_utils import SamplingMethod
from lighteval.tasks.requests import Doc
TEST_DATA = [
Doc(
query="1 The quick brown fox jumps over the lazy dog",
choices=["A", "B", "C"],
gold_index=0,
),
Doc(
... | orignal | assert | variable | tests/unit/test_unit_reorder.py | test_reorder_dataset | TestReorderGenerativeTaskDataset | 84 | null |
huggingface/lighteval | import unittest
from lighteval.utils.utils import remove_reasoning_tags
class TestRemoveReasoningTags(unittest.TestCase):
def test_no_opening_tag(self):
text = "No opening tag <think> Reasoning section. </think> Answer section"
tag_pairs = [("<think>", "</think>")]
result = remove_reasoni... | "No opening tag Answer section") | self.assertEqual | string_literal | tests/unit/utils/test_utils.py | test_no_opening_tag | TestRemoveReasoningTags | 57 | null |
huggingface/lighteval | from lighteval.tasks.templates.continuation import get_continuation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_continuation_prompt_mcf():
"""Test multiple-choice format continuation prompt generation."... | "Answer:" | assert | string_literal | tests/unit/tasks/templates/test_continuation.py | test_continuation_prompt_mcf | 56 | null | |
huggingface/lighteval | from lighteval.tasks.templates.translation import get_translation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_translation_prompt_mcf():
"""
Tests that translation prompt function works correctly for... | """\ CS: Ahoj, jak se máš? FR: A. Bonjour, comment allez-vous? B. Ciao, come stai? Answer:\ """ | assert | string_literal | tests/unit/tasks/templates/test_translation.py | test_translation_prompt_mcf | 80 | null | |
huggingface/lighteval | import unittest
from unittest.mock import Mock
from lighteval.models.utils import uses_chat_template
class TestUseChatTemplate(unittest.TestCase):
def test_uses_chat_template_with_chat_template_present(self):
"""Test that uses_chat_template returns True when tokenizer has a chat template."""
mock_... | result) | self.assertTrue | variable | tests/unit/models/test_model_utils.py | test_uses_chat_template_with_chat_template_present | TestUseChatTemplate | 36 | null |
huggingface/lighteval | import pytest
from lighteval.tasks.lighteval_task import LightevalTask, LightevalTaskConfig
from lighteval.tasks.registry import Registry
def test_superset_expansion():
"""
Tests that task info selector correctly handles supersets.
"""
registry = Registry(tasks="storycloze|0")
# The task list is ... | 0 | assert | numeric_literal | tests/unit/tasks/test_registry.py | test_superset_expansion | 43 | null | |
huggingface/lighteval | from lighteval.tasks.templates.hellaswag import get_hellaswag_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_hellaswag_prompt_mcf():
"""
Tests that hellaswag prompt function works correctly.
Since ... | "Answer:" | assert | string_literal | tests/unit/tasks/templates/test_hellaswag.py | test_hellaswag_prompt_mcf | 100 | null | |
huggingface/lighteval | from lighteval.tasks.templates.translation import get_translation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_translation_prompt_cf_formatting():
"""
Tests that translation prompt function works cor... | "EN: How are you? ZH:" | assert | string_literal | tests/unit/tasks/templates/test_translation.py | test_translation_prompt_cf_formatting | 117 | null | |
huggingface/lighteval | from lighteval.tasks.templates.multichoice import get_mcq_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_thai_multichoice_prompt():
"""Test multichoice prompt generation for Thai language."""
test_inpu... | "คำตอบ:" | assert | string_literal | tests/unit/tasks/templates/test_multichoice.py | test_thai_multichoice_prompt | 148 | null | |
huggingface/lighteval | import tempfile
import unittest
from dataclasses import asdict
from unittest.mock import Mock, patch
import pytest
import torch
from lighteval.models.abstract_model import LightevalModel
from lighteval.models.model_output import ModelResponse
from lighteval.tasks.requests import Doc, SamplingMethod
from lighteval.uti... | cache_file.exists()) | self.assertTrue | func_call | tests/unit/utils/test_caching.py | _test_cache | TestCaching | 160 | null |
huggingface/lighteval | import tempfile
import unittest
from dataclasses import asdict
from unittest.mock import Mock, patch
import pytest
import torch
from lighteval.models.abstract_model import LightevalModel
from lighteval.models.model_output import ModelResponse
from lighteval.tasks.requests import Doc, SamplingMethod
from lighteval.uti... | hasattr(method, "__wrapped__")) | self.assertTrue | func_call | tests/unit/utils/test_caching.py | test_cache_decorator_presence | TestCaching | 140 | null |
huggingface/lighteval | import pytest
from lighteval.metrics.normalizations import LogProbCharNorm, LogProbPMINorm, LogProbTokenNorm, normalize_log_probs
def test_char_norm():
choices_logprob = [10.0, 20.0]
choices_text = [" hell", "world"]
result = normalize_log_probs(LogProbCharNorm(ignore_first_space=False), choices_logprob,... | pytest.approx([2.5, 4.0]) | assert | func_call | tests/unit/metrics/test_normalizations.py | test_char_norm | 36 | null | |
huggingface/lighteval | import json
import os
import tempfile
from datetime import datetime
from pathlib import Path
import pytest
from datasets import Dataset
from huggingface_hub import HfApi
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.logging.info_loggers import DetailsLogger
from tests.fixtures imp... | task_details[task][0].padded | assert | complex_expr | tests/unit/logging/test_evaluation_tracker.py | test_details_logging | TestLogging | 150 | null |
huggingface/lighteval | from lighteval.tasks.templates.nli import get_nli_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, HybridFormulation
from lighteval.utils.language import Language
def test_nli_prompt_mcf():
"""Test multiple-choice format NLI prompt generation."""
test_input = {
"pr... | """\ The cat is sleeping on the couch. Question: The cat is awake. A. True B. Neither C. False Answer:\ """ | assert | string_literal | tests/unit/tasks/templates/test_nli.py | test_nli_prompt_mcf | 44 | null | |
huggingface/lighteval | from lighteval.tasks.templates.hellaswag import get_hellaswag_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_hellaswag_prompt_cf():
"""
Tests that hellaswag prompt function works correctly.
Since i... | "Fitness:\nHe is strong he is fast" | assert | string_literal | tests/unit/tasks/templates/test_hellaswag.py | test_hellaswag_prompt_cf | 56 | null | |
huggingface/lighteval | import pytest
from lighteval.tasks.lighteval_task import LightevalTask, LightevalTaskConfig
from lighteval.tasks.registry import Registry
def test_cli_sampling_params_fail():
"""
Tests task setting the sampling parameters in CLI failure when args are wrong.
"""
# creation of object should fail
wi... | ValueError) | pytest.raises | variable | tests/unit/tasks/test_registry.py | test_cli_sampling_params_fail | 83 | null | |
huggingface/lighteval | import json
import os
import tempfile
from datetime import datetime
from pathlib import Path
import pytest
from datasets import Dataset
from huggingface_hub import HfApi
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.logging.info_loggers import DetailsLogger
from tests.fixtures imp... | v) | self.assertEqual | variable | tests/unit/logging/test_evaluation_tracker.py | test_model_config_property_with_different_model_configs | TestProperties | 487 | null |
huggingface/lighteval | import pytest
from lighteval.metrics.normalizations import LogProbCharNorm, LogProbPMINorm, LogProbTokenNorm, normalize_log_probs
def test_token_norm():
choices_logprob = [10.0, 20.0]
choices_tokens = [[1, 2, 3], [4, 5]]
result = normalize_log_probs(LogProbTokenNorm(), choices_logprob, None, None, choice... | [3.333333, 10.0]) | pytest.approx | collection | tests/unit/metrics/test_normalizations.py | test_token_norm | 44 | null | |
huggingface/lighteval | from lighteval.tasks.templates.translation import get_translation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_translation_prompt_cf():
"""
Tests that translation prompt function works correctly for ... | "CS: Ahoj, jak se máš? FR:" | assert | string_literal | tests/unit/tasks/templates/test_translation.py | test_translation_prompt_cf | 51 | null | |
huggingface/lighteval | from transformers import AutoTokenizer
from lighteval.models.dummy.dummy_model import DummyModel, DummyModelConfig
def test_tok_encode_pair():
model = DummyModel(config=DummyModelConfig(seed=42))
model._tokenizer = AutoTokenizer.from_pretrained("facebook/xglm-564M")
context = "答案:"
continuation = ["1"... | ([[6, 47873]], [[34871]]) | assert | collection | tests/unit/models/test_abstract_model.py | test_tok_encode_pair | 36 | null | |
huggingface/lighteval | from unittest.mock import Mock
import pytest
from lighteval.tasks.prompt_manager import PromptManager
from lighteval.tasks.requests import Doc
class TestPromptManager:
def test_prepare_prompt_chat_template_with_fewshot(self):
"""Test prepare_prompt with chat template format and few-shot examples."""
... | 3 | assert | numeric_literal | tests/unit/prompt/test_prompt_manager_class.py | test_prepare_prompt_chat_template_with_fewshot | TestPromptManager | 183 | null |
huggingface/lighteval | from lighteval.tasks.templates.nli import get_nli_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, HybridFormulation
from lighteval.utils.language import Language
def test_nli_prompt_cf():
"""Test cloze format NLI prompt generation."""
test_input = {
"premise": "Th... | "The cat is sleeping on the couch right?" | assert | string_literal | tests/unit/tasks/templates/test_nli.py | test_nli_prompt_cf | 77 | null | |
huggingface/lighteval | import json
import os
import tempfile
from datetime import datetime
from pathlib import Path
import pytest
from datasets import Dataset
from huggingface_hub import HfApi
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.logging.info_loggers import DetailsLogger
from tests.fixtures imp... | 2 | assert | numeric_literal | tests/unit/logging/test_evaluation_tracker.py | test_push_to_hub_works | TestLogging | 195 | null |
huggingface/lighteval | from lighteval.tasks.templates.translation import get_translation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_translation_prompt_mcf():
"""
Tests that translation prompt function works correctly for... | [" A", " B"] | assert | collection | tests/unit/tasks/templates/test_translation.py | test_translation_prompt_mcf | 90 | null | |
huggingface/lighteval | from lighteval.tasks.templates.translation import get_translation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_translation_prompt_cf():
"""
Tests that translation prompt function works correctly for ... | "" | assert | string_literal | tests/unit/tasks/templates/test_translation.py | test_translation_prompt_cf | 52 | null | |
huggingface/lighteval | import pytest
from lighteval.metrics.normalizations import LogProbCharNorm, LogProbPMINorm, LogProbTokenNorm, normalize_log_probs
def test_char_norm():
choices_logprob = [10.0, 20.0]
choices_text = [" hell", "world"]
result = normalize_log_probs(LogProbCharNorm(ignore_first_space=False), choices_logprob,... | [2.5, 4.0]) | pytest.approx | collection | tests/unit/metrics/test_normalizations.py | test_char_norm | 36 | null | |
huggingface/lighteval | import json
import os
import tempfile
from datetime import datetime
from pathlib import Path
import pytest
from datasets import Dataset
from huggingface_hub import HfApi
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.logging.info_loggers import DetailsLogger
from tests.fixtures imp... | "test/case") | self.assertEqual | string_literal | tests/unit/logging/test_evaluation_tracker.py | test_default_property_with_different_model_configs | TestProperties | 459 | null |
huggingface/lighteval | from transformers import AutoTokenizer
from lighteval.models.dummy.dummy_model import DummyModel, DummyModelConfig
def test_tok_encode_pair():
model = DummyModel(config=DummyModelConfig(seed=42))
model._tokenizer = AutoTokenizer.from_pretrained("facebook/xglm-564M")
context = "答案:"
continuation = ["1"... | ([[6, 47873, 13]], [[82]]) | assert | collection | tests/unit/models/test_abstract_model.py | test_tok_encode_pair | 38 | null | |
huggingface/lighteval | import unittest
from unittest.mock import Mock, patch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from lighteval.models.model_output import ModelResponse
from lighteval.models.transformers.transformers_model import TransformersModel, TransformersModelConfig
from lighteval.tasks.requests ... | expected_result) | self.assertEqual | variable | tests/unit/models/test_transformers_model.py | test_transformers_model_use_chat_template_with_different_model_names | TestTransformersModelUseChatTemplate | 425 | null |
huggingface/lighteval | from lighteval.tasks.templates.continuation import get_continuation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_continuation_prompt_sequence_end():
"""Test continuation prompt generation when the contex... | "The sun is." | assert | string_literal | tests/unit/tasks/templates/test_continuation.py | test_continuation_prompt_sequence_end | 100 | null | |
huggingface/lighteval | import copy
import json
import logging
from dataclasses import field
from pathlib import Path
from typing import Any
import pytest
from pydantic import BaseModel
from lighteval.metrics.metrics import Metrics
from lighteval.models.model_output import ModelResponse
from lighteval.tasks.requests import Doc
logger = log... | expected, abs=tolerance) | pytest.approx | complex_expr | tests/unit/metrics/test_metrics_automated.py | _compare_scalar_outputs | AutomatedMetricTester | 215 | null |
huggingface/lighteval | from unittest.mock import Mock
import pytest
from lighteval.tasks.prompt_manager import PromptManager
from lighteval.tasks.requests import Doc
class TestPromptManager:
def test_prepare_prompt_chat_template_with_fewshot_and_instruction_and_system_prompt(self):
"""Test prepare_prompt with chat template fo... | 4 | assert | numeric_literal | tests/unit/prompt/test_prompt_manager_class.py | test_prepare_prompt_chat_template_with_fewshot_and_instruction_and_system_prompt | TestPromptManager | 263 | null |
huggingface/lighteval | from lighteval.tasks.templates.nli import get_nli_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, HybridFormulation
from lighteval.utils.language import Language
def test_nli_prompt_hybrid():
"""Test hybrid format NLI prompt generation."""
test_input = {
"premise... | """\ The cat is sleeping on the couch. Question: The cat is awake True, False or Neither? Answer:\ """ | assert | string_literal | tests/unit/tasks/templates/test_nli.py | test_nli_prompt_hybrid | 106 | null | |
huggingface/lighteval | from lighteval.tasks.templates.hellaswag import get_hellaswag_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_hellaswag_prompt_mcf():
"""
Tests that hellaswag prompt function works correctly.
Since ... | """\ Fitness:\nHe is strong he is fast A. he has big muscles B. he is weak Answer:\ """ | assert | string_literal | tests/unit/tasks/templates/test_hellaswag.py | test_hellaswag_prompt_mcf | 90 | null | |
huggingface/lighteval | from unittest.mock import Mock
import pytest
from lighteval.tasks.prompt_manager import PromptManager
from lighteval.tasks.requests import Doc
class TestPromptManager:
def test_init_with_chat_template(self):
"""Test PromptManager initialization with chat template enabled."""
tokenizer = Mock()
... | True | assert | bool_literal | tests/unit/prompt/test_prompt_manager_class.py | test_init_with_chat_template | TestPromptManager | 46 | null |
huggingface/lighteval | import numpy as np
import pytest
from lighteval.metrics.dynamic_metrics import (
LogLikelihoodAccMetric,
MultilingualQuasiExactMatchMetric,
MultilingualQuasiF1ScoreMetric,
NormalizedMultiChoiceProbMetric,
ProbabilityMetric,
)
from lighteval.metrics.metrics_sample import ExactMatches
from lighteval.... | 0 | assert | numeric_literal | tests/test_unit_base_metrics.py | test_exact_match | TestBaseMetrics | 60 | null |
huggingface/lighteval | import pytest
from lighteval.tasks.lighteval_task import LightevalTask, LightevalTaskConfig
from lighteval.tasks.registry import Registry
def test_task_creation():
"""
Tests that tasks registry correctly creates tasks
"""
registry = Registry(tasks="storycloze:2016|0")
task = registry.load_tasks()[... | "storycloze:2016" | assert | string_literal | tests/unit/tasks/test_registry.py | test_task_creation | 122 | null | |
huggingface/lighteval | import pytest
from lighteval.utils.imports import Extra, is_package_available, requires
def test_requires_with_wrong_dependency():
with | RuntimeError, match="A dependency was specified with @requires, but it is not defined in the possible dependencies defined in the pyproject.toml: `random_dependency`") | pytest.raises | complex_expr | tests/test_dependencies.py | test_requires_with_wrong_dependency | 56 | null | |
huggingface/lighteval | from lighteval.tasks.templates.multichoice import get_mcq_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_multichoice_prompt_nli_cf():
"""Test cloze format (CF) prompt generation for multichoice questions."... | """\ Question: What is the capital of France? Answer:\ """ | assert | string_literal | tests/unit/tasks/templates/test_multichoice.py | test_multichoice_prompt_nli_cf | 83 | null | |
huggingface/lighteval | import pytest
from lighteval.models.model_input import GenerationParameters
class TestGenerationParameters:
@pytest.mark.parametrize(
"model_args, expected",
[
(
"generation_parameters={temperature: 0.7,top_p: 0.95},pretrained=deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B,d... | v | assert | variable | tests/unit/models/test_model_input.py | test_extract_num_samples | TestGenerationParameters | 49 | null |
huggingface/lighteval | from lighteval.tasks.templates.nli import get_nli_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, HybridFormulation
from lighteval.utils.language import Language
def test_nli_prompt_mcf():
"""Test multiple-choice format NLI prompt generation."""
test_input = {
"pr... | [2] | assert | collection | tests/unit/tasks/templates/test_nli.py | test_nli_prompt_mcf | 57 | null | |
huggingface/lighteval | import unittest
from lighteval.utils.utils import remove_reasoning_tags
class TestRemoveReasoningTags(unittest.TestCase):
def test_no_closing_tag(self):
text = "<think> Reasoning section. Answer section"
tag_pairs = [("<think>", "</think>")]
result = remove_reasoning_tags(text, tag_pairs)... | "<think> Reasoning section. Answer section") | self.assertEqual | string_literal | tests/unit/utils/test_utils.py | test_no_closing_tag | TestRemoveReasoningTags | 63 | null |
huggingface/lighteval | import pytest
from lighteval.tasks.lighteval_task import LightevalTask, LightevalTaskConfig
from lighteval.tasks.registry import Registry
def test_superset_expansion():
"""
Tests that task info selector correctly handles supersets.
"""
registry = Registry(tasks="storycloze|0")
# The task list is ... | ["storycloze|0"] | assert | collection | tests/unit/tasks/test_registry.py | test_superset_expansion | 36 | null | |
huggingface/lighteval | import pytest
from lighteval.metrics.normalizations import LogProbCharNorm, LogProbPMINorm, LogProbTokenNorm, normalize_log_probs
def test_pmi_norm():
choices_logprob = [10.0, 20.0]
unconditioned_logprob = [5.0, 8.0]
result = normalize_log_probs(LogProbPMINorm(), choices_logprob, unconditioned_logprob, N... | pytest.approx([5.0, 12.0]) | assert | func_call | tests/unit/metrics/test_normalizations.py | test_pmi_norm | 52 | null | |
huggingface/lighteval | import tempfile
import unittest
from dataclasses import asdict
from unittest.mock import Mock, patch
import pytest
import torch
from lighteval.models.abstract_model import LightevalModel
from lighteval.models.model_output import ModelResponse
from lighteval.tasks.requests import Doc, SamplingMethod
from lighteval.uti... | sampling_method) | self.assertEqual | variable | tests/unit/utils/test_caching.py | _test_cache | TestCaching | 156 | null |
huggingface/lighteval | from lighteval.tasks.templates.nli import get_nli_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, HybridFormulation
from lighteval.utils.language import Language
def test_nli_prompt_cf():
"""Test cloze format NLI prompt generation."""
test_input = {
"premise": "Th... | 2 | assert | numeric_literal | tests/unit/tasks/templates/test_nli.py | test_nli_prompt_cf | 80 | null | |
huggingface/lighteval | import tempfile
import unittest
from typing import Optional
from unittest.mock import patch
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.metrics.metrics import Metrics
from lighteval.models.dummy.dummy_model import DummyModel, DummyModelConfig
from lighteval.models.model_output imp... | [("<think>", "</think>")]) | self.assertEqual | collection | tests/unit/pipeline/test_reasoning_tags.py | test_default_reasoning_tags | TestPipelineReasoningTags | 410 | null |
huggingface/lighteval | import json
import os
import pytest
from lighteval.metrics import apply_metric
from lighteval.metrics.metrics import Metrics
from lighteval.metrics.sample_preparator import (
GenerativeCorpusMetricInput,
LogprobCorpusMetricInput,
PerplexityCorpusMetricInput,
)
from lighteval.models.model_output import Mod... | pytest.approx(cur_ref_list, rel=1e-8) | assert | func_call | tests/test_unit_harness_metrics.py | test_model_prediction | 134 | null | |
huggingface/lighteval | import unittest
from unittest.mock import Mock, patch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from lighteval.models.model_output import ModelResponse
from lighteval.models.transformers.transformers_model import TransformersModel, TransformersModelConfig
from lighteval.tasks.requests ... | None) | self.assertEqual | none_literal | tests/unit/models/test_transformers_model.py | test_model_creation_attributes | TestTransformersModelCreation | 95 | null |
huggingface/lighteval | import pytest
from lighteval.metrics.normalizations import LogProbCharNorm, LogProbPMINorm, LogProbTokenNorm, normalize_log_probs
def test_char_norm():
choices_logprob = [10.0, 20.0]
choices_text = [" hell", "world"]
result = normalize_log_probs(LogProbCharNorm(ignore_first_space=False), choices_logprob,... | pytest.approx([2.0, 4.0]) | assert | func_call | tests/unit/metrics/test_normalizations.py | test_char_norm | 33 | null | |
huggingface/lighteval | import json
import os
import tempfile
from datetime import datetime
from pathlib import Path
import pytest
from datasets import Dataset
from huggingface_hub import HfApi
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.logging.info_loggers import DetailsLogger
from tests.fixtures imp... | {}) | self.assertEqual | collection | tests/unit/logging/test_evaluation_tracker.py | test_default_property_with_different_model_configs | TestProperties | 437 | null |
huggingface/lighteval | from lighteval.tasks.templates.hellaswag import get_hellaswag_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_hellaswag_prompt_cf():
"""
Tests that hellaswag prompt function works correctly.
Since i... | [" he has big muscles", " he is weak"] | assert | collection | tests/unit/tasks/templates/test_hellaswag.py | test_hellaswag_prompt_cf | 59 | null | |
huggingface/lighteval | from lighteval.tasks.templates.nli import get_nli_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, HybridFormulation
from lighteval.utils.language import Language
def test_nli_prompt_cf():
"""Test cloze format NLI prompt generation."""
test_input = {
"premise": "Th... | "right?" | assert | string_literal | tests/unit/tasks/templates/test_nli.py | test_nli_prompt_cf | 78 | null | |
huggingface/lighteval | import pytest
from lighteval.utils.imports import Extra, is_package_available, requires
def test_requires_with_extra():
@requires(Extra.TGI)
class RandomModel:
pass
with | ImportError, match=r"Through the use of RandomModel, you are trying to run an evaluation requiring tgi capabilities. Please install the required extra: `pip install lighteval\[tgi\]`") | pytest.raises | complex_expr | tests/test_dependencies.py | test_requires_with_extra | 48 | null | |
huggingface/lighteval | import unittest
from lighteval.utils.utils import remove_reasoning_tags
class TestRemoveReasoningTags(unittest.TestCase):
def test_empty_text(self):
text = ""
tag_pairs = [("<think>", "</think>")]
result = remove_reasoning_tags(text, tag_pairs)
self.assertEqual(result, | "") | self.assertEqual | string_literal | tests/unit/utils/test_utils.py | test_empty_text | TestRemoveReasoningTags | 51 | null |
huggingface/lighteval | from lighteval.tasks.templates.hellaswag import get_hellaswag_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_hellaswag_prompt_mcf():
"""
Tests that hellaswag prompt function works correctly.
Since ... | [" A", " B"] | assert | collection | tests/unit/tasks/templates/test_hellaswag.py | test_hellaswag_prompt_mcf | 101 | null | |
huggingface/lighteval | import pytest
from lighteval.tasks.lighteval_task import LightevalTask, LightevalTaskConfig
from lighteval.tasks.registry import Registry
def test_superset_with_subset_task():
"""
Tests that task info selector correctly handles if both superset and one of subset tasks are provided.
"""
registry = Regi... | 57 | assert | numeric_literal | tests/unit/tasks/test_registry.py | test_superset_with_subset_task | 54 | null | |
huggingface/lighteval | import tempfile
import unittest
from typing import Optional
from unittest.mock import patch
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.metrics.metrics import Metrics
from lighteval.models.dummy.dummy_model import DummyModel, DummyModelConfig
from lighteval.models.model_output imp... | ["The answer is 4"]) | self.assertEqual | collection | tests/unit/pipeline/test_reasoning_tags.py | test_remove_reasoning_tags_enabled | TestPipelineReasoningTags | 158 | null |
huggingface/lighteval | import numpy as np
import pytest
from lighteval.metrics.dynamic_metrics import (
LogLikelihoodAccMetric,
MultilingualQuasiExactMatchMetric,
MultilingualQuasiF1ScoreMetric,
NormalizedMultiChoiceProbMetric,
ProbabilityMetric,
)
from lighteval.metrics.metrics_sample import ExactMatches
from lighteval.... | 1 | assert | numeric_literal | tests/test_unit_base_metrics.py | test_exact_match | TestBaseMetrics | 48 | null |
huggingface/lighteval | from lighteval.tasks.templates.multichoice import get_mcq_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_multichoice_prompt_nli_cf():
"""Test cloze format (CF) prompt generation for multichoice questions."... | [" London", " Paris", " Berlin", " Madrid"] | assert | collection | tests/unit/tasks/templates/test_multichoice.py | test_multichoice_prompt_nli_cf | 92 | null | |
huggingface/lighteval | import unittest
from unittest.mock import Mock, patch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from lighteval.models.model_output import ModelResponse
from lighteval.models.transformers.transformers_model import TransformersModel, TransformersModelConfig
from lighteval.tasks.requests ... | len(result.logprobs) > 0) | self.assertTrue | func_call | tests/unit/models/test_transformers_model.py | test_loglikelihood_eval | TestTransformersModelProcessing | 240 | null |
huggingface/lighteval | from lighteval.tasks.templates.multichoice import get_mcq_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_thai_multichoice_prompt():
"""Test multichoice prompt generation for Thai language."""
test_inpu... | """\ คำถาม: สิ่งใดต่อไปนี้เป็นสิ่งที่คุณชอบมากที่สุด? A. รถยนต์ B. รถจักรยานยนต์ C. รถจักรยานยนต์ D. รถยนต์ คำตอบ:\ """ | assert | string_literal | tests/unit/tasks/templates/test_multichoice.py | test_thai_multichoice_prompt | 136 | null | |
huggingface/lighteval | from lighteval.tasks.templates.multichoice import get_mcq_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_multichoice_prompt_mcf():
"""Test multiple-choice format (MCF) prompt generation for multichoice que... | [" A", " B", " C", " D"] | assert | collection | tests/unit/tasks/templates/test_multichoice.py | test_multichoice_prompt_mcf | 61 | null | |
huggingface/lighteval | from lighteval.tasks.templates.translation import get_translation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_translation_prompt_cf():
"""
Tests that translation prompt function works correctly for ... | None | assert | none_literal | tests/unit/tasks/templates/test_translation.py | test_translation_prompt_cf | 49 | null | |
huggingface/lighteval | import tempfile
import unittest
from dataclasses import asdict
from unittest.mock import Mock, patch
import pytest
import torch
from lighteval.models.abstract_model import LightevalModel
from lighteval.models.model_output import ModelResponse
from lighteval.tasks.requests import Doc, SamplingMethod
from lighteval.uti... | hasattr(model_class, method_name)) | self.assertTrue | func_call | tests/unit/utils/test_caching.py | test_cache_decorator_presence | TestCaching | 135 | null |
huggingface/lighteval | import json
import os
import tempfile
from datetime import datetime
from pathlib import Path
import pytest
from datasets import Dataset
from huggingface_hub import HfApi
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.logging.info_loggers import DetailsLogger
from tests.fixtures imp... | 1 | assert | numeric_literal | tests/unit/logging/test_evaluation_tracker.py | test_results_logging | TestLogging | 99 | null |
huggingface/lighteval | from lighteval.data import GenerativeTaskDataset
from lighteval.metrics.utils.metric_utils import SamplingMethod
from lighteval.tasks.requests import Doc
TEST_DATA = [
Doc(
query="1 The quick brown fox jumps over the lazy dog",
choices=["A", "B", "C"],
gold_index=0,
),
Doc(
... | len(original_data) | assert | func_call | tests/unit/test_unit_reorder.py | test_reorder_dataset | TestReorderGenerativeTaskDataset | 79 | null |
huggingface/lighteval | import pytest
from lighteval.metrics.normalizations import LogProbCharNorm, LogProbPMINorm, LogProbTokenNorm, normalize_log_probs
def test_empty_input():
empty_logprob = []
empty_text = []
empty_tokens = []
# Test with empty inputs
assert normalize_log_probs(LogProbCharNorm(), empty_logprob, Non... | [] | assert | collection | tests/unit/metrics/test_normalizations.py | test_empty_input | 61 | null | |
huggingface/lighteval | import ast
import base64
import faulthandler
import json
import multiprocessing
import os
import pickle
import platform
import signal
import sys
import time
import zlib
from concurrent.futures import ProcessPoolExecutor, as_completed
from decimal import Decimal
from enum import Enum
from io import StringIO
from types ... | len(num_correct) | assert | func_call | src/lighteval/tasks/tasks/lcb/codegen_metrics.py | estimate_pass_at_k | 623 | null | |
huggingface/lighteval | import unittest
from lighteval.utils.utils import remove_reasoning_tags
class TestRemoveReasoningTags(unittest.TestCase):
def test_remove_multiple_tags(self):
text = "<think> Reasoning </think> Interlude <think> More reasoning </think> Answer"
tag_pairs = [("<think>", "</think>")]
result ... | " Interlude Answer") | self.assertEqual | string_literal | tests/unit/utils/test_utils.py | test_remove_multiple_tags | TestRemoveReasoningTags | 39 | null |
huggingface/lighteval | from lighteval.tasks.templates.continuation import get_continuation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_continuation_prompt_cf():
"""Test cloze format continuation prompt generation."""
test... | [" shining brightly", " setting in the west", " hidden behind clouds"] | assert | collection | tests/unit/tasks/templates/test_continuation.py | test_continuation_prompt_cf | 80 | null | |
huggingface/lighteval | from lighteval.tasks.templates.nli import get_nli_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, HybridFormulation
from lighteval.utils.language import Language
def test_nli_prompt_hybrid():
"""Test hybrid format NLI prompt generation."""
test_input = {
"premise... | [" True", " Neither", " False"] | assert | collection | tests/unit/tasks/templates/test_nli.py | test_nli_prompt_hybrid | 115 | null | |
huggingface/lighteval | import ast
import asyncio
import collections
import os
import random
from dataclasses import dataclass
from datetime import timedelta
from enum import Enum, auto
import numpy as np
from tqdm import tqdm
from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.metrics import apply_metric
from ... | None | assert | none_literal | src/lighteval/pipeline.py | _load_responses_from_details | Pipeline | 412 | null |
huggingface/lighteval | import pytest
from lighteval.tasks.templates.copa import get_copa_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation
from lighteval.utils.language import Language
@pytest.mark.parametrize("cause_effect", ["cause", "effect"])
def test_copa_prompt_cf(cause_effect):
"""
Tests t... | [0] | assert | collection | tests/unit/tasks/templates/test_copa.py | test_copa_prompt_cf | 62 | null | |
huggingface/lighteval | from lighteval.tasks.templates.continuation import get_continuation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_continuation_prompt_cf():
"""Test cloze format continuation prompt generation."""
test... | "" | assert | string_literal | tests/unit/tasks/templates/test_continuation.py | test_continuation_prompt_cf | 79 | null | |
huggingface/lighteval | from lighteval.tasks.templates.continuation import get_continuation_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_continuation_prompt_cf():
"""Test cloze format continuation prompt generation."""
test... | "The sun is" | assert | string_literal | tests/unit/tasks/templates/test_continuation.py | test_continuation_prompt_cf | 77 | null | |
huggingface/lighteval | import pytest
from lighteval.tasks.templates.copa import get_copa_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation
from lighteval.utils.language import Language
@pytest.mark.parametrize("cause_effect", ["cause", "effect"])
def test_copa_prompt_cf(cause_effect):
"""
Tests t... | [" he has big muscles", " he is weak"] | assert | collection | tests/unit/tasks/templates/test_copa.py | test_copa_prompt_cf | 61 | null | |
huggingface/lighteval | import json
import os
import pytest
from lighteval.metrics import apply_metric
from lighteval.metrics.metrics import Metrics
from lighteval.metrics.sample_preparator import (
GenerativeCorpusMetricInput,
LogprobCorpusMetricInput,
PerplexityCorpusMetricInput,
)
from lighteval.models.model_output import Mod... | ref, rel=1e-8) | pytest.approx | complex_expr | tests/test_unit_harness_metrics.py | test_model_prediction | 127 | null | |
huggingface/lighteval | import unittest
from unittest.mock import Mock, patch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from lighteval.models.model_output import ModelResponse
from lighteval.models.transformers.transformers_model import TransformersModel, TransformersModelConfig
from lighteval.tasks.requests ... | "left") | self.assertEqual | string_literal | tests/unit/models/test_transformers_model.py | test_tokenizer_padding_configuration | TestTransformersTokenizerCreation | 59 | null |
huggingface/lighteval | import tempfile
import unittest
from dataclasses import asdict
from unittest.mock import Mock, patch
import pytest
import torch
from lighteval.models.abstract_model import LightevalModel
from lighteval.models.model_output import ModelResponse
from lighteval.tasks.requests import Doc, SamplingMethod
from lighteval.uti... | asdict(response)) | self.assertEqual | func_call | tests/unit/utils/test_caching.py | _test_cache | TestCaching | 177 | null |
huggingface/lighteval | from lighteval.data import GenerativeTaskDataset
from lighteval.metrics.utils.metric_utils import SamplingMethod
from lighteval.tasks.requests import Doc
TEST_DATA = [
Doc(
query="1 The quick brown fox jumps over the lazy dog",
choices=["A", "B", "C"],
gold_index=0,
),
Doc(
... | len(sorted_data[i + 1].query) | assert | func_call | tests/unit/test_unit_reorder.py | test_reorder_dataset | TestReorderGenerativeTaskDataset | 75 | null |
huggingface/lighteval | from unittest.mock import Mock
import pytest
from lighteval.tasks.prompt_manager import PromptManager
from lighteval.tasks.requests import Doc
class TestPromptManager:
def test_init_default_values(self):
"""Test PromptManager initialization with default values."""
pm = PromptManager()
as... | None | assert | none_literal | tests/unit/prompt/test_prompt_manager_class.py | test_init_default_values | TestPromptManager | 38 | null |
huggingface/lighteval | import unittest
from unittest.mock import Mock, patch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from lighteval.models.model_output import ModelResponse
from lighteval.models.transformers.transformers_model import TransformersModel, TransformersModelConfig
from lighteval.tasks.requests ... | self.model.batch_size) | self.assertIsNone | complex_expr | tests/unit/models/test_transformers_model.py | test_model_creation_attributes | TestTransformersModelCreation | 98 | null |
huggingface/lighteval | import tempfile
import unittest
from dataclasses import asdict
from unittest.mock import Mock, patch
import pytest
import torch
from lighteval.models.abstract_model import LightevalModel
from lighteval.models.model_output import ModelResponse
from lighteval.tasks.requests import Doc, SamplingMethod
from lighteval.uti... | folder.exists()) | self.assertTrue | func_call | tests/unit/utils/test_caching.py | test_cache_directory_structure | TestCaching | 100 | null |
huggingface/lighteval | import pytest
from lighteval.tasks.lighteval_task import LightevalTask, LightevalTaskConfig
from lighteval.tasks.registry import Registry
def test_cli_sampling_params():
"""
Tests task setting the sampling parameters in CLI.
"""
registry_no_sampling = Registry(tasks="math_500|0")
task_info_no_sam... | 10 | assert | numeric_literal | tests/unit/tasks/test_registry.py | test_cli_sampling_params | 75 | null | |
huggingface/lighteval | import ast
import base64
import faulthandler
import json
import multiprocessing
import os
import pickle
import platform
import signal
import sys
import time
import zlib
from concurrent.futures import ProcessPoolExecutor, as_completed
from decimal import Decimal
from enum import Enum
from io import StringIO
from types ... | len(inputs) | assert | func_call | src/lighteval/tasks/tasks/lcb/codegen_metrics.py | evaluate_generations | 586 | null | |
huggingface/lighteval | import pytest
from lighteval.tasks.templates.copa import get_copa_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation
from lighteval.utils.language import Language
@pytest.mark.parametrize("cause_effect", ["cause", "effect"])
def test_copa_prompt_cf(cause_effect):
"""
Tests t... | f"He is strong {cause_effect_word}" | assert | string_literal | tests/unit/tasks/templates/test_copa.py | test_copa_prompt_cf | 58 | null | |
huggingface/lighteval | from lighteval.tasks.templates.hellaswag import get_hellaswag_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_hellaswag_ctx_joining():
"""
Tests that hellaswag prompt function works correctly.
Since... | "Fitness:\nHe is strong. He is fast." | assert | string_literal | tests/unit/tasks/templates/test_hellaswag.py | test_hellaswag_ctx_joining | 132 | null | |
huggingface/lighteval | import unittest
from unittest.mock import Mock, patch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from lighteval.models.model_output import ModelResponse
from lighteval.models.transformers.transformers_model import TransformersModel, TransformersModelConfig
from lighteval.tasks.requests ... | [2, 1]) | self.assertEqual | collection | tests/unit/models/test_transformers_model.py | test_loglikelihood_padded_tensors_shapes | TestTransformersModelProcessing | 355 | null |
huggingface/lighteval | import pytest
import sympy
from lighteval.metrics.dynamic_metrics import MultilingualExtractiveMatchMetric
from lighteval.metrics.utils.extractive_match_utils import (
ExprExtractionConfig,
IndicesExtractionConfig,
LatexExtractionConfig,
)
from lighteval.metrics.utils.math_comparison import sympy_expr_eq
f... | expected | assert | variable | tests/unit/metrics/test_extractive_match.py | test_extraction_abc | 100 | null | |
huggingface/lighteval | from lighteval.tasks.templates.multichoice import get_mcq_prompt_function
from lighteval.tasks.templates.utils.formulation import CFFormulation, MCFFormulation
from lighteval.utils.language import Language
def test_multichoice_prompt_mcf():
"""Test multiple-choice format (MCF) prompt generation for multichoice que... | """\ Question: What is the capital of France? A. London B. Paris C. Berlin D. Madrid Answer:\ """ | assert | string_literal | tests/unit/tasks/templates/test_multichoice.py | test_multichoice_prompt_mcf | 48 | null | |
rtCamp/Frappe-Manager | from datetime import datetime, timedelta
from unittest.mock import patch
import pytest
from frappe_manager.ssl_manager.certificate_exceptions import (
SSLCertificateChallengeFailed,
SSLCertificateGenerateFailed,
SSLCertificateNotDueForRenewalError,
SSLCertificateNotFoundError,
SSLDNSChallengeCrede... | custom_message | assert | variable | tests/unit/ssl_manager/test_certificate_exceptions.py | test_custom_message_override | TestSSLDNSChallengeCredentailsNotFound | 71 | null |
rtCamp/Frappe-Manager | from datetime import datetime, timedelta
from unittest.mock import patch
import pytest
from frappe_manager.ssl_manager.certificate_exceptions import (
SSLCertificateChallengeFailed,
SSLCertificateGenerateFailed,
SSLCertificateNotDueForRenewalError,
SSLCertificateNotFoundError,
SSLDNSChallengeCrede... | expiry_date) | assert_* | variable | tests/unit/ssl_manager/test_certificate_exceptions.py | test_message_formatting_with_domain_and_time | TestSSLCertificateNotDueForRenewalError | 141 | null |
rtCamp/Frappe-Manager | from unittest.mock import MagicMock, patch
import pytest
from typer.testing import CliRunner
from frappe_manager.commands import app
runner = CliRunner()
def patch_log_and_bench_dirs(temp_log_dir):
"""Context manager to patch both log directory and benches directory for testing."""
from contextlib import Ex... | clean_output | assert | variable | tests/integration/test_logger_integration.py | test_help_shows_log_level_flag | TestHelpCommand | 253 | null |
rtCamp/Frappe-Manager | from unittest.mock import MagicMock, patch
import pytest
from frappe_manager.output_manager.rich_output import RichOutputHandler
class TestRichOutputHandlerBasicOperations:
def test_print_with_emoji(self):
"""print() includes emoji when provided."""
handler = RichOutputHandler()
with pa... | call_args.lower() | assert | func_call | tests/unit/output_manager/test_rich_output.py | test_print_with_emoji | TestRichOutputHandlerBasicOperations | 97 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.