-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a89d4de
commit d8db5fd
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Pytest fixtures. | ||
""" | ||
from __future__ import annotations | ||
|
||
import pytest | ||
import numpy as np | ||
|
||
|
||
TEST_CAUSAL_LMS = [ | ||
"hf-internal-testing/tiny-random-gpt2", | ||
# "hf-internal-testing/tiny-random-MistralForCausalLM", | ||
] | ||
|
||
|
||
@pytest.fixture(params=[42]) | ||
def random_seed(request) -> int: | ||
return request.param | ||
|
||
|
||
@pytest.fixture | ||
def rng(random_seed: int) -> np.random.Generator: | ||
return np.random.default_rng(random_seed) | ||
|
||
|
||
@pytest.fixture(params=TEST_CAUSAL_LMS) | ||
def causal_lm_name_or_path(request) -> str: | ||
"""Name or path of the CausalLM used for testing.""" | ||
return request.param |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Test functions in folktexts.llm_utils | ||
""" | ||
|
||
from transformers import PreTrainedModel, PreTrainedTokenizerBase | ||
from folktexts.llm_utils import load_model_tokenizer | ||
|
||
|
||
def test_load_model_tokenizer(causal_lm_name_or_path: str): | ||
model, tokenizer = load_model_tokenizer(causal_lm_name_or_path) | ||
|
||
assert isinstance(model, PreTrainedModel), \ | ||
f"Expected model type `PreTrainedModel`, got {type(model)}." | ||
|
||
assert isinstance(tokenizer, PreTrainedTokenizerBase), \ | ||
f"Expected tokenizer type `PreTrainedTokenizer`, got {type(tokenizer)}." |