file_name large_stringlengths 6 73 | file_path large_stringlengths 8 117 | type large_stringclasses 3
values | name large_stringlengths 1 91 | start_line int64 1 6.25k | end_line int64 5 6.27k | content large_stringlengths 18 250k | docstring large_stringlengths 0 41.1k ⌀ | embedding listlengths 768 768 | embedding_model large_stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|
test_tokenization_common.py | tests/test_tokenization_common.py | function | tokenizer_integration_test_util | 484 | 552 | def tokenizer_integration_test_util(
self,
expected_encoding: dict,
model_name: str,
revision: str | None = None,
sequences: list[str] | None = None,
decode_kwargs: dict[str, Any] | None = None,
padding: bool = True,
):
"""
Util for integration... |
Util for integration test.
Text is tokenized and then reverted back to text. Both results are then checked.
Args:
expected_encoding:
The expected result of the tokenizer output.
model_name:
The model name of the tokenizer to load and use... | [
-0.0027986764907836914,
-0.03209458664059639,
0.013307389803230762,
-0.012545387260615826,
-0.0033188180532306433,
0.036010805517435074,
-0.028197389096021652,
-0.024771148338913918,
-0.00351885543204844,
0.04664662852883339,
-0.06416616588830948,
-0.006409802939742804,
-0.019899871200323105... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | assert_padded_input_match | 554 | 562 | def assert_padded_input_match(self, input_r: list, input_p: list, max_length: int, pad_token_id: int):
# Ensure we match max_length
self.assertEqual(len(input_r), max_length)
self.assertEqual(len(input_p), max_length)
# Ensure the number of padded tokens is the same
padded_token... | null | [
-0.008559548296034336,
-0.01444981712847948,
0.019994063302874565,
-0.031341951340436935,
-0.0398547500371933,
0.030152738094329834,
-0.013781307265162468,
-0.06752552837133408,
-0.007033900823444128,
0.00615570368245244,
-0.011427981778979301,
-0.013959321193397045,
-0.05149546638131142,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | assert_batch_padded_input_match | 564 | 588 | def assert_batch_padded_input_match(
self,
input_r: dict,
input_p: dict,
max_length: int,
pad_token_id: int,
model_main_input_name: str = "input_ids",
):
for i_r in input_r.values():
(
self.assertEqual(len(i_r), 2),
... | null | [
-0.009794850833714008,
-0.00773977767676115,
0.03248308598995209,
-0.010992529802024364,
-0.04957031086087227,
0.06374974548816681,
-0.03584638610482216,
-0.043491024523973465,
0.0012266478734090924,
0.02577916719019413,
-0.017888959497213364,
0.003975627478212118,
-0.04677196592092514,
0.... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | convert_batch_to_list_format | 591 | 597 | def convert_batch_to_list_format(batch_encode_plus_sequences):
# Switch from batch_encode_plus format: {'input_ids': [[...], [...]], ...}
# to the list of examples/ encode_plus format: [{'input_ids': [...], ...}, {'input_ids': [...], ...}]
return [
{value: batch_encode_plus_sequenc... | null | [
0.0014709841925650835,
0.020584210753440857,
0.0037935220170766115,
-0.005404146853834391,
-0.02238747850060463,
0.05697331950068474,
-0.037271514534950256,
-0.039855893701314926,
-0.03288872539997101,
0.03135988116264343,
-0.027412356808781624,
0.01832597330212593,
-0.04963507875800133,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_tokenize_special_tokens | 600 | 618 | def test_tokenize_special_tokens(self):
"""Test `tokenize` with special tokens."""
tokenizer = self.get_tokenizer(do_lower_case=True)
SPECIAL_TOKEN_1 = "[SPECIAL_TOKEN_1]"
SPECIAL_TOKEN_2 = "[SPECIAL_TOKEN_2]"
# Both methods should add the token to `_extra_special_tokens` and `... | Test `tokenize` with special tokens. | [
-0.009014342911541462,
0.008451954461634159,
0.015412219800055027,
-0.01353346835821867,
-0.03746822848916054,
0.04526522383093834,
-0.03444710001349449,
-0.05482099577784538,
-0.007541000377386808,
0.012326400727033615,
-0.04104940593242645,
-0.0068272496573626995,
-0.039670974016189575,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_model_input_names_signature | 620 | 629 | def test_model_input_names_signature(self):
accepted_model_main_input_names = [
"input_ids", # nlp models
"input_values", # speech models
]
tokenizer = self.get_tokenizer()
# first name of model_input_names has to correspond to main model input name
# t... | null | [
-0.019254643470048904,
-0.004837975371629,
0.025656769052147865,
-0.022821826860308647,
0.0013809655793011189,
0.056304238736629486,
-0.039381496608257294,
-0.05941055342555046,
0.010190118104219437,
0.017751628533005714,
-0.0031261814292520285,
0.009905735962092876,
-0.021164514124393463,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_tokenizer_store_full_signature | 631 | 645 | def test_tokenizer_store_full_signature(self):
signature = inspect.signature(self.tokenizer_class.__init__)
tokenizer = self.get_tokenizer()
for parameter_name, parameter in signature.parameters.items():
if parameter.default != inspect.Parameter.empty and parameter_name not in [
... | null | [
0.013932177796959877,
-0.021803298965096474,
0.03447393700480461,
-0.033662348985672,
-0.01626192405819893,
0.04322168976068497,
-0.0258609838783741,
-0.05132736638188362,
0.015009137801826,
0.029773496091365814,
-0.05409936606884003,
0.011854657903313637,
-0.02033715695142746,
0.047033406... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_tokenizers_common_properties | 647 | 677 | def test_tokenizers_common_properties(self):
tokenizer = self.get_tokenizer()
attributes_list = [
"bos_token",
"eos_token",
"unk_token",
"sep_token",
"pad_token",
"cls_token",
"mask_token",
]
for attr in... | null | [
0.0002530381316319108,
-0.0022641222458332777,
0.045255571603775024,
0.01266608014702797,
-0.021039418876171112,
0.05225303769111633,
-0.03201349079608917,
-0.030356204137206078,
0.008900116197764874,
0.04211484268307686,
-0.044609859585762024,
0.027223439887166023,
-0.028073625639081,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_tokenizers_common_ids_setters | 679 | 710 | def test_tokenizers_common_ids_setters(self):
tokenizer = self.get_tokenizer()
attributes_list = [
"bos_token",
"eos_token",
"unk_token",
"sep_token",
"pad_token",
"cls_token",
"mask_token",
]
vocab = to... | null | [
0.003994193393737078,
0.00887636560946703,
0.013165573589503765,
0.012345883063971996,
-0.02459961548447609,
0.047071583569049835,
-0.040047500282526016,
-0.027837958186864853,
0.01740064099431038,
0.025480441749095917,
-0.02845701389014721,
0.030388670042157173,
-0.033632323145866394,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_save_and_load_tokenizer | 712 | 795 | def test_save_and_load_tokenizer(self):
# safety check on max_len default value so we are sure the test works
tokenizer = self.get_tokenizer()
self.assertNotEqual(tokenizer.model_max_length, 42)
# Now let's start the test
tokenizer = self.get_tokenizer()
# Isolate this f... | null | [
-0.016925770789384842,
-0.01659909449517727,
0.026154080405831337,
0.051438938826322556,
0.0047571188770234585,
0.020129386335611343,
0.01622537337243557,
-0.019557006657123566,
-0.02828439138829708,
-0.00696435384452343,
-0.01361360028386116,
0.009473380632698536,
-0.023006731644272804,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | _run_integration_checks | 797 | 821 | def _run_integration_checks(self, tokenizer, tokenizer_type):
# Test 1: Tokens match expected
tokens = tokenizer.tokenize(self.integration_test_input_string)
self.maxDiff = None
self.assertListEqual(
tokens,
self.integration_expected_tokens,
f"Tokenize... | null | [
-0.017148341983556747,
0.011503319256007671,
0.0011771605350077152,
0.014004237949848175,
-0.03387615084648132,
0.017639538273215294,
-0.02012050151824951,
-0.051909416913986206,
0.009569757618010044,
0.02757943421602249,
-0.016668651252985,
0.007817795500159264,
-0.01693190634250641,
0.05... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_integration | 823 | 843 | def test_integration(self):
"""
Integration checks for the original tokenizer only.
"""
# Skip if no integration test data is provided
if not hasattr(self, "integration_test_input_string") or self.integration_test_input_string is None:
self.skipTest("No integration te... |
Integration checks for the original tokenizer only.
| [
-0.010828904807567596,
0.016477452591061592,
0.005130217410624027,
0.009555189870297909,
0.01243639923632145,
0.03836311399936676,
-0.002453346038237214,
-0.027144193649291992,
0.003357837675139308,
0.01837419904768467,
-0.06183740124106407,
0.02719969116151333,
-0.03892369568347931,
0.080... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_integration_from_extractor | 845 | 872 | def test_integration_from_extractor(self):
"""
Integration checks for a tokenizer built via TokenizersExtractor.
"""
# Skip if tokenizer-from-extractor path is not enabled for this class
if not getattr(self, "test_tokenizer_from_extractor", False):
self.skipTest("Toke... |
Integration checks for a tokenizer built via TokenizersExtractor.
| [
-0.005079876631498337,
0.02063084952533245,
0.005051499232649803,
0.03770099952816963,
0.0030511284712702036,
0.021630791947245598,
-0.009143154136836529,
-0.03659985587000847,
0.026581093668937683,
0.034541647881269455,
-0.07538661360740662,
0.025035835802555084,
-0.044307008385658264,
0.... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_internal_consistency | 874 | 888 | def test_internal_consistency(self):
tokenizer = self.get_tokenizer()
input_text, output_text = self.get_input_output_texts(tokenizer)
tokens = tokenizer.tokenize(input_text)
ids = tokenizer.convert_tokens_to_ids(tokens)
ids_2 = tokenizer.encode(input_text, add_special_tokens=Fa... | null | [
-0.0149846151471138,
0.024828054010868073,
0.023480098694562912,
-0.0028377303387969732,
-0.023916397243738174,
0.0394672192633152,
-0.007210747338831425,
-0.0324242003262043,
-0.005571760702878237,
0.022990496829152107,
-0.005506695248186588,
-0.006376426201313734,
0.0027839841786772013,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_mask_output | 890 | 896 | def test_mask_output(self):
tokenizer = self.get_tokenizer(do_lower_case=False)
seq_0 = "Test this method."
seq_1 = "With these inputs."
information = tokenizer(seq_0, seq_1, add_special_tokens=True, return_token_type_ids=True)
sequences, mask = information["input_ids"], informat... | null | [
0.0025844331830739975,
0.0075888196006417274,
0.0300510972738266,
-0.01662839949131012,
-0.016652004793286324,
0.04227287694811821,
-0.021257596090435982,
-0.03557509183883667,
-0.0080733522772789,
0.0360737182199955,
-0.003869076957926154,
-0.0025475623551756144,
-0.043358925729990005,
0.... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_token_type_ids | 898 | 907 | def test_token_type_ids(self):
tokenizer = self.get_tokenizer()
seq_0 = "Test this method."
# We want to have sequence 0 and sequence 1 are tagged
# respectively with 0 and 1 token_ids
# (regardless of whether the model use token type ids)
# We use this assumption in the... | null | [
0.0010486330138519406,
-0.02568577416241169,
-0.005942412652075291,
0.00003703857146319933,
-0.0014000455848872662,
0.06176847964525223,
-0.032091330736875534,
-0.03361425921320915,
0.012799210846424103,
0.01819816790521145,
-0.022145668044686317,
-0.004416199866682291,
-0.028942357748746872... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_sequence_ids | 909 | 930 | def test_sequence_ids(self):
tokenizer = self.get_tokenizer()
if tokenizer.backend != "tokenizers":
self.skipTest(reason="Tokenizers backend tokenizer")
seq_0 = "Test this method."
seq_1 = "With these inputs."
# We want to have sequence 0 and sequence 1 are tagged
... | null | [
-0.010415828786790371,
-0.007364413235336542,
-0.026720726862549782,
0.006598156876862049,
-0.021053308621048927,
0.043950315564870834,
-0.022300980985164642,
-0.023831551894545555,
0.016717009246349335,
0.033249516040086746,
-0.029943551868200302,
0.022427620366215706,
-0.01578555628657341,... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_chat_template | 933 | 993 | def test_chat_template(self):
dummy_template = "{% for message in messages %}{{message['role'] + message['content']}}{% endfor %}"
dummy_conversation = [
{"role": "system", "content": "system message"},
{"role": "user", "content": "user message"},
{"role": "assistant"... | null | [
0.0016056218883022666,
0.004812216851860285,
0.050564851611852646,
0.03916849568486214,
0.0038784246426075697,
0.03488166257739067,
0.005263540428131819,
-0.012674716301262379,
-0.02511957287788391,
0.007073219865560532,
0.0004774937988258898,
-0.00699048163369298,
-0.03327943757176399,
0.... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_chat_template_save_loading | 996 | 1,035 | def test_chat_template_save_loading(self):
tokenizer = self.get_tokenizer()
signature = inspect.signature(tokenizer.__init__)
if "chat_template" not in {*signature.parameters.keys()}:
self.skipTest("tokenizer doesn't accept chat templates at input")
tokenizer.chat_template = ... | null | [
0.019214730709791183,
-0.009016461670398712,
0.017236270010471344,
0.027189070358872414,
-0.015488780103623867,
0.028618520125746727,
-0.011814894154667854,
-0.0025148317217826843,
-0.01747090555727482,
0.03619322553277016,
-0.05502886697649956,
0.015415548346936703,
-0.008438406512141228,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_chat_template_batched | 1,038 | 1,069 | def test_chat_template_batched(self):
dummy_template = "{% for message in messages %}{{message['role'] + message['content']}}{% endfor %}"
dummy_conversations = [
[
{"role": "system", "content": "system message"},
{"role": "user", "content": "user message"},
... | null | [
-0.012857720255851746,
0.008160168305039406,
0.03619750216603279,
-0.00646487670019269,
-0.01631285808980465,
0.03125916048884392,
-0.012601437047123909,
-0.0015841793501749635,
-0.042405083775520325,
0.0024192649871110916,
0.004249178804457188,
-0.017518330365419388,
-0.034411124885082245,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_jinja_loopcontrols | 1,072 | 1,089 | def test_jinja_loopcontrols(self):
break_template = """
{%- for message in messages %}
{{- message.role + " " + message.content }}
{%- if loop.first %}
{%- break %}
{%- endif %}
{%- endfor %}""".strip()
dummy_conversation = [
... | null | [
0.011561168357729912,
0.005611424800008535,
0.03222671151161194,
-0.01746392622590065,
0.006793402601033449,
0.02639063261449337,
0.019413158297538757,
0.007121820468455553,
-0.006450815126299858,
-0.017771979793906212,
0.024886924773454666,
-0.004779742565006018,
0.005021520424634218,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_jinja_strftime | 1,092 | 1,108 | def test_jinja_strftime(self):
strftime_template = """{{- strftime_now("%Y-%m-%d") }}""".strip()
dummy_conversation = [
{"role": "system", "content": "1"},
{"role": "user", "content": "2"},
{"role": "assistant", "content": "3"},
]
tokenizer = self.ge... | null | [
-0.0015245439717546105,
-0.0095887565985322,
0.05360798165202141,
-0.029295112937688828,
-0.006465061567723751,
0.06128722429275513,
-0.010289727710187435,
0.015518919564783573,
-0.004321758635342121,
0.012328163720667362,
0.02312532253563404,
-0.015363980084657669,
-0.07149562984704971,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_chat_template_return_assistant_tokens_mask | 1,112 | 1,302 | def test_chat_template_return_assistant_tokens_mask(self):
dummy_template = (
"{% for message in messages %}"
"{% if (message['role'] != 'assistant') %}"
"{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}"
"{% elif (message['ro... | null | [
0.01580568589270115,
-0.0043252804316580296,
0.05052017793059349,
-0.029940875247120857,
0.02184401825070381,
0.051150862127542496,
-0.010402755811810493,
0.006019776687026024,
-0.02430766448378563,
0.0479186587035656,
-0.017878970131278038,
0.024629084393382072,
-0.04643283039331436,
0.04... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_chat_template_return_assistant_tokens_mask_truncated | 1,305 | 1,413 | def test_chat_template_return_assistant_tokens_mask_truncated(self):
dummy_template = (
"{% for message in messages %}"
"{% if (message['role'] != 'assistant') %}"
"{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}"
"{% elif (m... | null | [
0.012399278581142426,
-0.017291828989982605,
0.04090623930096626,
-0.01938331499695778,
0.017328709363937378,
0.04445566236972809,
-0.0052948035299777985,
-0.003936585504561663,
-0.02760087139904499,
0.04315916821360588,
-0.03887518495321274,
0.027189230546355247,
-0.0524609312415123,
0.04... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_continue_final_message | 1,416 | 1,441 | def test_continue_final_message(self):
dummy_template = """
{%- for message in messages %}
{{- "<|im_start|>" + message['role'] + "\n" + message['content'] + "<|im_end|>" + "\n"}}
{%- endfor %}"""
dummy_conversation = [
{"role": "system", "content": "system messag... | null | [
0.008238796144723892,
0.027375755831599236,
0.008530404418706894,
0.00568243395537138,
0.0298631489276886,
0.024542154744267464,
0.013865364715456963,
0.012711985036730766,
0.02045304700732231,
-0.0017687695799395442,
-0.011356532573699951,
0.0032573866192251444,
0.0013356460258364677,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_continue_final_message_with_trim | 1,444 | 1,471 | def test_continue_final_message_with_trim(self):
"""Regression test for chat templates with trimming: https://github.com/huggingface/transformers/pull/34214"""
dummy_template = """
{%- for message in messages %}
{{- "<|im_start|>" + message['role'] + "\n" + message['content'] | trim... | Regression test for chat templates with trimming: https://github.com/huggingface/transformers/pull/34214 | [
0.04444883018732071,
-0.016522206366062164,
0.007536343298852444,
0.03506217151880264,
-0.014819645322859287,
0.05309109389781952,
0.029420113191008568,
0.010331743396818638,
0.013556783087551594,
-0.007026167120784521,
-0.04257994517683983,
0.01065856497734785,
0.005981259513646364,
0.067... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_continue_final_message_with_decoy_earlier_message | 1,474 | 1,496 | def test_continue_final_message_with_decoy_earlier_message(self):
"""Regression test for chat templates where an earlier message has similar content to the final message
https://github.com/huggingface/transformers/issues/35433"""
dummy_template = """
{%- for message in messages %}
... | Regression test for chat templates where an earlier message has similar content to the final message
https://github.com/huggingface/transformers/issues/35433 | [
0.02870471589267254,
-0.012476631440222263,
0.025767577812075615,
0.007994595915079117,
-0.005457092076539993,
0.03878466412425041,
0.008374755270779133,
-0.006514072418212891,
0.026730112731456757,
-0.03172151744365692,
-0.022765768691897392,
-0.014569193124771118,
-0.0008665112545713782,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_chat_template_dict | 1,499 | 1,512 | def test_chat_template_dict(self):
dummy_template_1 = "{{'a'}}"
dummy_template_2 = "{{'b'}}"
dummy_conversation = [
{"role": "user", "content": "user message"},
]
tokenizer = self.get_tokenizer()
tokenizer.chat_template = {"template1": dummy_template_1, "templ... | null | [
-0.006095335818827152,
0.006242013536393642,
0.024022197350859642,
0.0015116807771846652,
-0.009148363955318928,
0.05671287700533867,
-0.03799780458211899,
0.006674192380160093,
-0.022634724155068398,
-0.008423220366239548,
-0.029922451823949814,
-0.004062140826135874,
-0.026474671438336372,... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_chat_template_dict_saving | 1,515 | 1,544 | def test_chat_template_dict_saving(self):
dummy_template_1 = "{{'a'}}"
dummy_template_2 = "{{'b'}}"
tokenizer = self.get_tokenizer()
for save_jinja_files in (True, False):
tokenizer.chat_template = {"default": dummy_template_1, "template2": dummy_template_2}
with ... | null | [
0.024753399193286896,
-0.00018211855785921216,
0.03739651292562485,
0.026545191183686256,
0.007314067799597979,
0.064740851521492,
-0.022867808118462563,
0.0053695025853812695,
-0.047698725014925,
-0.012781361117959023,
-0.02421741746366024,
0.007890647277235985,
-0.014554492197930813,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_chat_template_file_priority | 1,547 | 1,558 | def test_chat_template_file_priority(self):
dummy_template1 = "a"
dummy_template2 = "b"
tokenizer = self.get_tokenizer()
with tempfile.TemporaryDirectory() as tmp_dir_name:
tokenizer.chat_template = dummy_template1
tokenizer.save_pretrained(tmp_dir_name, save_jinj... | null | [
0.03580296039581299,
-0.035134781152009964,
0.05170399695634842,
0.055503103882074356,
-0.012511169537901878,
0.048260852694511414,
-0.033460505306720734,
-0.015833836048841476,
-0.033568937331438065,
-0.015249366872012615,
-0.028986886143684387,
0.024489739909768105,
-0.02985326573252678,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_number_of_added_tokens | 1,560 | 1,570 | def test_number_of_added_tokens(self):
tokenizer = self.get_tokenizer(do_lower_case=False)
seq_0 = "Test this method."
seq_1 = "With these inputs."
sequences = tokenizer.encode(seq_0, seq_1, add_special_tokens=False)
attached_sequences = tokenizer.encode(seq_0, seq_1, add_specia... | null | [
0.0035946050193160772,
-0.01116340234875679,
0.044444143772125244,
-0.038079749792814255,
-0.03896642103791237,
0.0371679812669754,
-0.03462601825594902,
-0.014737511985003948,
-0.01426698174327612,
0.029728276655077934,
-0.042744070291519165,
-0.0026697502471506596,
-0.030979614704847336,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_maximum_encoding_length_single_input | 1,572 | 1,665 | def test_maximum_encoding_length_single_input(self):
tokenizer = self.get_tokenizer(do_lower_case=False, model_max_length=100)
seq_0, ids = self.get_clean_sequence(tokenizer, max_length=20)
sequence = tokenizer.encode(seq_0, add_special_tokens=False)
total_length = len(sequence)
... | null | [
0.025554925203323364,
-0.01681658998131752,
0.010911590419709682,
-0.012981481850147247,
-0.01261843554675579,
0.0243087075650692,
0.002795575885102153,
-0.05314305052161217,
0.0031186717096716166,
0.01342171523720026,
-0.03472500294446945,
-0.011383384466171265,
-0.018728701397776604,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_maximum_encoding_length_pair_input | 1,667 | 1,921 | def test_maximum_encoding_length_pair_input(self):
tokenizer = self.get_tokenizer(do_lower_case=False, model_max_length=100)
# Build a sequence from our model's vocabulary
stride = 2
seq_0, ids = self.get_clean_sequence(tokenizer, max_length=20)
if len(ids) <= 2 + stride:
... | null | [
0.0026683073956519365,
-0.013364570215344429,
0.008974025957286358,
-0.026237620040774345,
-0.026245437562465668,
0.03182495757937431,
0.0002903310232795775,
-0.0682370588183403,
-0.01677471585571766,
0.023488830775022507,
-0.0490398183465004,
-0.016588613390922546,
-0.01265653409063816,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_special_tokens_mask | 1,923 | 1,938 | def test_special_tokens_mask(self):
tokenizer = self.get_tokenizer(do_lower_case=False)
sequence_0 = "Encode this."
# Testing single inputs
encoded_sequence = tokenizer.encode(sequence_0, add_special_tokens=False)
encoded_sequence_dict = tokenizer(
sequence_0,
... | null | [
0.02392694726586342,
0.013439417816698551,
0.04309113323688507,
0.008750799112021923,
-0.02938293293118477,
0.05309119448065758,
-0.01964821107685566,
-0.05585622414946556,
0.001953704049810767,
0.05520857498049736,
-0.02842608094215393,
0.016703814268112183,
-0.036243587732315063,
0.07953... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_special_tokens_mask_input_pairs | 1,940 | 1,961 | def test_special_tokens_mask_input_pairs(self):
tokenizer = self.get_tokenizer(do_lower_case=False)
sequence_0 = "Encode this."
sequence_1 = "This one too please."
encoded_sequence = tokenizer.encode(sequence_0, add_special_tokens=False)
encoded_sequence += tokenizer.encode(seque... | null | [
0.01665927655994892,
0.0187026709318161,
0.03501001372933388,
-0.0047075445763766766,
-0.0159140657633543,
0.049236394464969635,
-0.03182318061590195,
-0.058685045689344406,
0.0000375145573343616,
0.055906422436237335,
-0.043941862881183624,
0.018807271495461464,
-0.044176504015922546,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_padding_side_in_kwargs | 1,963 | 1,978 | def test_padding_side_in_kwargs(self):
for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
with self.subTest(f"{tokenizer.__class__.__name__} ({pretrained_name})"):
tokenizer_r = self.get_tokenizer(pretrained_name, padding_side="left", **kwargs)
self.asser... | null | [
-0.005165004637092352,
-0.0036350961308926344,
0.04118826985359192,
0.0009753332124091685,
-0.04582863673567772,
0.056223899126052856,
-0.054004620760679245,
-0.0825466439127922,
0.008396267890930176,
0.02061633951961994,
-0.028936615213751793,
-0.005624048877507448,
-0.0520700104534626,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_truncation_side_in_kwargs | 1,980 | 1,995 | def test_truncation_side_in_kwargs(self):
for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
with self.subTest(f"{tokenizer.__class__.__name__} ({pretrained_name})"):
tokenizer_r = self.get_tokenizer(pretrained_name, truncation_side="left", **kwargs)
self... | null | [
0.0014123694272711873,
-0.014413069002330303,
0.03226185590028763,
0.004251264035701752,
-0.04421427100896835,
0.04548746347427368,
-0.0665896087884903,
-0.07289712876081467,
-0.014257206581532955,
0.02834871970117092,
-0.026405351236462593,
-0.0042828889563679695,
-0.04168693348765373,
0.... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_encode_basic_padding | 1,997 | 2,024 | def test_encode_basic_padding(self):
"""Test basic left/right padding behavior using encode() method with max_length strategy."""
tokenizer = self.get_tokenizer(do_lower_case=False)
sequence = "Sequence"
padding_size = 10
# check correct behaviour if no pad_token_id exists and a... | Test basic left/right padding behavior using encode() method with max_length strategy. | [
0.019344760105013847,
-0.004286712966859341,
0.026727091521024704,
-0.005894746631383896,
0.0014617511769756675,
0.02704716846346855,
-0.020515404641628265,
-0.06908101588487625,
-0.00027519671129994094,
0.010306690819561481,
-0.040085576474666595,
-0.02013145387172699,
-0.03445038944482803,... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_right_and_left_truncation | 2,026 | 2,078 | def test_right_and_left_truncation(self):
tokenizer = self.get_tokenizer(do_lower_case=False)
sequence = "This is a test sequence"
# RIGHT PADDING - Check that it correctly pads when a maximum length is specified along with the padding flag set to True
truncation_size = 3
tokeni... | null | [
0.007248042616993189,
-0.011442634277045727,
0.0022430347744375467,
-0.018158113583922386,
0.0005065400036983192,
-0.003997557330876589,
-0.05820683762431145,
-0.03605983406305313,
0.007667662110179663,
0.02925705723464489,
-0.04122058302164078,
0.0032024718821048737,
-0.0036116130650043488,... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_padding_to_multiple_of | 2,080 | 2,110 | def test_padding_to_multiple_of(self):
tokenizer = self.get_tokenizer()
if tokenizer.pad_token is None:
self.skipTest(reason="No padding token.")
else:
empty_tokens = tokenizer("", padding=True, pad_to_multiple_of=8)
normal_tokens = tokenizer("This is a sample... | null | [
0.01787410117685795,
0.02482759580016136,
0.03318782150745392,
-0.06761390715837479,
-0.03039655275642872,
0.012214782647788525,
-0.0009201695793308318,
-0.03765010088682175,
-0.020523736253380775,
0.029863808304071426,
-0.03697684407234192,
-0.00297430413775146,
-0.03568641468882561,
0.04... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_padding_with_attention_mask | 2,112 | 2,127 | def test_padding_with_attention_mask(self):
tokenizer = self.get_tokenizer()
if tokenizer.pad_token is None:
self.skipTest(reason="No padding token.")
if "attention_mask" not in tokenizer.model_input_names:
self.skipTest(reason="This model does not use attention mask.")
... | null | [
-0.0025099487975239754,
-0.003685928648337722,
-0.000462017284007743,
-0.008615344762802124,
-0.047255922108888626,
0.03922273591160774,
-0.03906484320759773,
-0.04106011614203453,
0.008637698367238045,
0.018921121954917908,
-0.058483194559812546,
-0.007910185493528843,
-0.049412425607442856... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_encode_plus_with_padding | 2,130 | 2,239 | def test_encode_plus_with_padding(self, use_padding_as_call_kwarg: bool):
"""
This test checks that padding works as expected when tokenizing a sequence.
Padding is expected to have no effect when the input is a single sequence and
the padding-strategy is not `max_length`. Otherwise it p... |
This test checks that padding works as expected when tokenizing a sequence.
Padding is expected to have no effect when the input is a single sequence and
the padding-strategy is not `max_length`. Otherwise it pads to the specified max-length
using tokenizer classes `padding_side` attrib... | [
0.003381246468052268,
-0.0015893144300207496,
0.0425855852663517,
0.01224901620298624,
-0.02093769982457161,
-0.009346137754619122,
-0.007004336919635534,
-0.07550393790006638,
-0.005630080122500658,
0.008230045437812805,
-0.04147554188966751,
-0.021351739764213562,
-0.02198474295437336,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_get_vocab | 2,241 | 2,252 | def test_get_vocab(self):
tokenizer = self.get_tokenizer(do_lower_case=False)
vocab_dict = tokenizer.get_vocab()
self.assertIsInstance(vocab_dict, dict)
self.assertGreaterEqual(len(tokenizer), len(vocab_dict))
vocab = [tokenizer.convert_ids_to_tokens(i) for i in range(len(tokeni... | null | [
-0.008314065635204315,
-0.005068797618150711,
0.034564051777124405,
-0.016274532303214073,
-0.015025395900011063,
0.06671760231256485,
0.010734155774116516,
-0.05359805002808571,
-0.028064580634236336,
0.029556354507803917,
-0.013420394621789455,
0.01373409666121006,
-0.0453045479953289,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_conversion_reversible | 2,255 | 2,262 | def test_conversion_reversible(self):
tokenizer = self.get_tokenizer(do_lower_case=False)
vocab = tokenizer.get_vocab()
for word, ind in vocab.items():
if word == tokenizer.unk_token:
continue
self.assertEqual(tokenizer.convert_tokens_to_ids(word), ind)
... | null | [
-0.007109396625310183,
0.007631528191268444,
0.021621687337756157,
-0.018462102860212326,
0.0038874796591699123,
0.05368085950613022,
0.014660881832242012,
-0.05046038329601288,
0.003439966356381774,
0.023722928017377853,
-0.0005974259111098945,
0.02809322066605091,
-0.0006522065959870815,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_call | 2,264 | 2,291 | def test_call(self):
# Tests that all call wrap to encode_plus
tokenizer = self.get_tokenizer(do_lower_case=False)
sequences = [
"Testing batch encode plus",
"Testing batch encode plus with different sequence lengths",
"Testing batch encode plus with different... | null | [
-0.006014080252498388,
0.02988879568874836,
0.013162346556782722,
-0.01848311349749565,
-0.028995681554079056,
0.03333885595202446,
-0.03565960377454758,
-0.050210148096084595,
0.004744035191833973,
0.01409299299120903,
-0.027127090841531754,
-0.012164941988885403,
-0.041228823363780975,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_batch_encode_plus_batch_sequence_length | 2,293 | 2,339 | def test_batch_encode_plus_batch_sequence_length(self):
# Tests that all encoded values have the correct size
tokenizer = self.get_tokenizer(do_lower_case=False)
sequences = [
"Testing batch encode plus",
"Testing batch encode plus with different sequence lengths",
... | null | [
-0.004876326769590378,
0.02668583206832409,
0.026040999218821526,
0.01002373918890953,
-0.0007137154461815953,
0.013315446674823761,
-0.011744096875190735,
-0.05745315924286842,
-0.02915387973189354,
0.036076031625270844,
-0.04149312153458595,
-0.003173240227624774,
-0.026016846299171448,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_batch_encode_plus_padding | 2,341 | 2,385 | def test_batch_encode_plus_padding(self):
# Test that padded sequences are equivalent between batch and individual encoding
# Right padding tests
tokenizer = self.get_tokenizer(do_lower_case=False)
sequences = [
"Testing batch encode plus",
"Testing batch encode ... | null | [
0.005091612692922354,
0.024384213611483574,
0.009356552734971046,
0.009274138137698174,
-0.0024068935308605433,
0.0173113364726305,
-0.008867108263075352,
-0.06376030296087265,
-0.008762244135141373,
0.016633497551083565,
-0.023343458771705627,
-0.0017321116756647825,
-0.03403472155332565,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_pretokenized_inputs | 2,387 | 2,453 | def test_pretokenized_inputs(self):
# Test when inputs are pretokenized
# All methods (encode, encode_plus, __call__) go through the same code path,
# so we only test __call__
tokenizer = self.get_tokenizer(do_lower_case=False)
if hasattr(tokenizer, "add_prefix_space") and not t... | null | [
0.031811244785785675,
0.0113307423889637,
0.021213868632912636,
-0.011336419731378555,
-0.005035802256315947,
0.021333662793040276,
-0.021873561665415764,
-0.04671761393547058,
-0.0005187583738006651,
0.029516803100705147,
-0.037823259830474854,
-0.009592908434569836,
-0.025272900238633156,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | _check_no_pad_token_padding | 2,455 | 2,465 | def _check_no_pad_token_padding(self, tokenizer, sequences):
# if tokenizer does v have pad_token_id, an error should be thrown
if tokenizer.pad_token_id is None:
with self.assertRaises(ValueError):
if isinstance(sequences, list):
tokenizer(sequences, pad... | null | [
-0.0055964644998312,
-0.012782542034983635,
0.007282676640897989,
-0.024225473403930664,
-0.04309232905507088,
0.021922601386904716,
0.000811308971606195,
-0.05198945850133896,
-0.020579315721988678,
0.01016261987388134,
-0.0485059879720211,
-0.008797334507107735,
-0.01958155445754528,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_prepare_seq2seq_batch | 2,468 | 2,507 | def test_prepare_seq2seq_batch(self):
if not self.test_seq2seq:
self.skipTest(reason="test_seq2seq is set to False")
tokenizer = self.get_tokenizer()
# Longer text that will definitely require truncation.
src_text = [
" UN Chief Says There Is No Military Solution... | null | [
-0.024083919823169708,
-0.006253629922866821,
0.0017703892663121223,
0.00009389113256474957,
-0.03171868622303009,
0.02596966177225113,
-0.02455773390829563,
-0.006949085742235184,
-0.02499338798224926,
0.0026186981704086065,
-0.049885086715221405,
0.01028177235275507,
-0.01373686920851469,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_batch_encode_dynamic_overflowing | 2,509 | 2,570 | def test_batch_encode_dynamic_overflowing(self):
"""
When calling batch_encode with multiple sequence it can returns different number of
overflowing encoding for each sequence:
[
Sequence 1: [Encoding 1, Encoding 2],
Sequence 2: [Encoding 1],
Sequence 3: [En... |
When calling batch_encode with multiple sequence it can returns different number of
overflowing encoding for each sequence:
[
Sequence 1: [Encoding 1, Encoding 2],
Sequence 2: [Encoding 1],
Sequence 3: [Encoding 1, Encoding 2, ... Encoding N]
]
This... | [
-0.009068463928997517,
-0.019632136449217796,
0.03909437730908394,
-0.022964907810091972,
-0.043775610625743866,
0.05987904220819473,
-0.05717790126800537,
-0.022947195917367935,
-0.028907040134072304,
0.02080865204334259,
-0.06690292805433273,
-0.00866883434355259,
0.005354509223252535,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_added_tokens_serialization | 2,572 | 2,597 | def test_added_tokens_serialization(self):
new_eos = AddedToken("[NEW_EOS]", rstrip=False, lstrip=True, normalized=False, special=True)
for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
with self.subTest(f"{tokenizer.__class__.__name__} ({pretrained_name})"):
# ... | null | [
-0.0029894299805164337,
-0.012467418797314167,
0.0375436432659626,
0.0372113399207592,
-0.01690860465168953,
0.017295271158218384,
-0.053645793348550797,
-0.0272746030241251,
-0.018410274758934975,
0.028293950483202934,
-0.053164463490247726,
0.015029825270175934,
-0.03278270736336708,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_tokenizer_initialization_with_conflicting_key | 2,599 | 2,604 | def test_tokenizer_initialization_with_conflicting_key(self):
with self.assertRaises(AttributeError, msg="conflicts with the method"):
self.get_tokenizer(add_special_tokens=True)
with self.assertRaises(AttributeError, msg="conflicts with the method"):
self.get_tokenizer(get_voca... | null | [
-0.030647793784737587,
-0.006988128647208214,
0.027272341772913933,
-0.017713472247123718,
-0.023380465805530548,
0.04288395866751671,
-0.0025246182922273874,
-0.0369810089468956,
0.0018047656631097198,
0.02331613563001156,
-0.03793554753065109,
0.0008173593669198453,
-0.048069022595882416,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_empty_input_string | 2,606 | 2,632 | def test_empty_input_string(self):
empty_input_string = ""
tokenizer_return_type = []
output_tensor_type = []
if is_torch_available():
import numpy as np
import torch
tokenizer_return_type.append("pt")
output_tensor_type.append(torch.int6... | null | [
-0.00573358777910471,
-0.03670528903603554,
0.05675399675965309,
0.044165417551994324,
-0.028051303699612617,
0.03985925391316414,
-0.05170462280511856,
-0.03435470908880234,
-0.03723097965121269,
0.03395124524831772,
-0.06471187621355057,
0.006322669796645641,
-0.0057038008235394955,
0.03... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_pad_token_initialization | 2,634 | 2,665 | def test_pad_token_initialization(self):
"""Test that passing pad_token when creating a tokenizer works correctly."""
tokenizer = self.get_tokenizer(pad_token="[PAD]")
# Verify the pad_token was set correctly
self.assertEqual(tokenizer.pad_token, "[PAD]")
self.assertIsNotNone(tok... | Test that passing pad_token when creating a tokenizer works correctly. | [
0.014292224310338497,
0.009004680439829826,
-0.0031489203684031963,
-0.0073505244217813015,
-0.012975667603313923,
0.027301650494337082,
-0.023026639595627785,
-0.046360667794942856,
0.005507342517375946,
0.008991594426333904,
-0.05500045418739319,
-0.012025445699691772,
-0.04288988932967186... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_bos_token_with_add_bos_token_true | 2,667 | 2,682 | def test_bos_token_with_add_bos_token_true(self):
"""Test that passing bos_token with add_bos_token=True during initialization adds the BOS token."""
try:
tokenizer = self.get_tokenizer(bos_token="<BOS>", add_bos_token=True)
except TypeError:
# Some tokenizers might not s... | Test that passing bos_token with add_bos_token=True during initialization adds the BOS token. | [
0.010637504979968071,
0.00026676274137571454,
-0.024520449340343475,
-0.010490120388567448,
-0.0391126424074173,
0.002349638380110264,
-0.025584379211068153,
-0.004381363745778799,
-0.00242531206458807,
0.04607385769486427,
-0.02559022419154644,
-0.026365507394075394,
-0.03363332152366638,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_bos_token_with_add_bos_token_false | 2,684 | 2,699 | def test_bos_token_with_add_bos_token_false(self):
"""Test that passing bos_token with add_bos_token=False during initialization does not add the BOS token."""
try:
tokenizer = self.get_tokenizer(bos_token="<BOS>", add_bos_token=False)
except TypeError:
# Some tokenizers ... | Test that passing bos_token with add_bos_token=False during initialization does not add the BOS token. | [
0.014401442371308804,
0.008531002327799797,
-0.03592672571539879,
-0.008906281553208828,
-0.042139895260334015,
-0.001735476078465581,
-0.028995810076594353,
-0.008462523110210896,
-0.002004752168431878,
0.04830378666520119,
-0.030176158994436264,
-0.018557973206043243,
-0.041782572865486145... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_local_files_only | 2,701 | 2,722 | def test_local_files_only(self):
from transformers import AutoTokenizer
pretrained_list = getattr(self, "from_pretrained_id", []) or []
for pretrained_name in pretrained_list:
with self.subTest(f"AutoTokenizer ({pretrained_name})"):
# First cache the tokenizer files
... | null | [
0.03247283026576042,
-0.047046419233083725,
0.029550990089774132,
0.022667845711112022,
-0.06115037575364113,
0.06330309063196182,
-0.053136661648750305,
-0.06955625116825104,
0.02787015400826931,
0.028098072856664658,
-0.04725326970219612,
0.04432905837893486,
-0.023780809715390205,
0.070... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | class | TokenizersBackendCommonTest | 2,726 | 2,735 | class TokenizersBackendCommonTest(TokenizersBackendTesterMixin, unittest.TestCase):
"""
A single test class that runs all tokenizers-backend tests once.
Uses BertTokenizer as a representative tokenizer.
"""
tokenizer_class = BertTokenizer
rust_tokenizer_class = BertTokenizerFast
from_pretra... |
A single test class that runs all tokenizers-backend tests once.
Uses BertTokenizer as a representative tokenizer.
| [
-0.007458267267793417,
-0.02289198338985443,
0.01453864760696888,
-0.013143476098775864,
-0.04418113827705383,
0.05047856271266937,
-0.026521699503064156,
-0.01651999168097973,
-0.004890377167612314,
0.029971793293952942,
-0.03956717625260353,
-0.02410387620329857,
-0.021184077486395836,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | class | SentencePieceBackendCommonTest | 2,738 | 2,829 | class SentencePieceBackendCommonTest(unittest.TestCase, SentencePieceBackendTesterMixin):
"""
A single test class that runs all SentencePiece-backend tests once.
Uses T5Tokenizer as a representative SentencePiece tokenizer.
"""
tokenizer_class = T5Tokenizer
rust_tokenizer_class = T5TokenizerFas... |
A single test class that runs all SentencePiece-backend tests once.
Uses T5Tokenizer as a representative SentencePiece tokenizer.
| [
-0.00548621965572238,
-0.03671080619096756,
0.017827942967414856,
-0.024637026712298393,
-0.029488302767276764,
0.04850360378623009,
-0.006039968226104975,
-0.009504078887403011,
0.012708894908428192,
0.021506018936634064,
-0.0291446503251791,
-0.012785698287189007,
-0.02873607911169529,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_add_tokens | 2,751 | 2,768 | def test_add_tokens(self):
tokenizer_r = self.get_rust_tokenizer()
vocab_size = len(tokenizer_r)
self.assertEqual(tokenizer_r.add_tokens(""), 0)
self.assertEqual(tokenizer_r.add_tokens("testoken"), 1)
self.assertEqual(tokenizer_r.add_tokens(["testoken1", "testtoken2"]), 2)
... | null | [
-0.00876579713076353,
0.013598945923149586,
0.028417309746146202,
-0.023027250543236732,
-0.056980032473802567,
0.04133259132504463,
-0.03125908970832825,
0.005083470605313778,
0.007496029604226351,
0.017342835664749146,
-0.014642523601651192,
0.009982426650822163,
-0.04264729097485542,
0.... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_add_tokens_tokenizer | 2,770 | 2,803 | def test_add_tokens_tokenizer(self):
tokenizer = self.get_tokenizer(do_lower_case=False)
vocab_size = tokenizer.vocab_size
all_size = len(tokenizer)
new_toks = [
AddedToken("newtokenone", rstrip=False, lstrip=False),
AddedToken("newtokentwo", rstrip=False, lstrip... | null | [
0.0029531633481383324,
0.01018868200480938,
0.021278636530041695,
-0.00433363439515233,
-0.01279689185321331,
0.024744102731347084,
-0.027305541560053825,
-0.019949592649936676,
-0.016929227858781815,
0.014397029764950275,
-0.03485560044646263,
0.02072206512093544,
-0.031767215579748154,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_alignment_methods | 2,805 | 2,806 | def test_alignment_methods(self):
self.skipTest("SentencePiece fast tokenizers do not expose token alignment metadata.") | null | [
-0.005935900378972292,
0.0017356834141537547,
-0.002404979430139065,
-0.01130705513060093,
-0.030589116737246513,
0.0344524122774601,
-0.010365152731537819,
-0.030092425644397736,
-0.016849400475621223,
0.00501710269600153,
-0.04651866480708122,
-0.0007900980999693274,
-0.02131558023393154,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | function | test_local_files_only | 2,808 | 2,829 | def test_local_files_only(self):
from transformers import AutoTokenizer
pretrained_list = getattr(self, "from_pretrained_id", []) or []
for pretrained_name in pretrained_list:
with self.subTest(f"AutoTokenizer ({pretrained_name})"):
# First cache the tokenizer files
... | null | [
0.03279666602611542,
-0.04800257831811905,
0.02853299491107464,
0.022538356482982635,
-0.06052033230662346,
0.06362166255712509,
-0.05206340551376343,
-0.06987372040748596,
0.026890240609645844,
0.026791391894221306,
-0.04775241017341614,
0.045296065509319305,
-0.024702519178390503,
0.0687... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1-50 | 1 | 50 | # Copyright 2019 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | null | [
0.0023786553647369146,
-0.00142311817035079,
0.015156274661421776,
0.011872044764459133,
-0.005709671415388584,
0.05099658668041229,
-0.009118343703448772,
-0.02305981144309044,
-0.005984915886074305,
0.014431516639888287,
-0.07666093856096268,
-0.008329035714268684,
-0.030531734228134155,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_41-90 | 41 | 90 | is_mlx_available,
is_torch_available,
logging,
)
from transformers.testing_utils import (
get_tests_dir,
require_jinja,
require_tokenizers,
require_torch,
slow,
)
from transformers.tokenization_python import AddedToken
from .test_sentencepiece_backend_mixin import SentencePieceBackendTe... | null | [
0.002064137952402234,
-0.026215439662337303,
0.019498221576213837,
-0.028758220374584198,
0.005099073518067598,
0.03573786839842796,
-0.012182085774838924,
-0.0024778894148766994,
-0.013213750906288624,
0.02908613346517086,
-0.07518716901540756,
-0.003985727205872536,
0.008740903809666634,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_81-130 | 81 | 130 | import torch
if TYPE_CHECKING:
from transformers import PretrainedConfig, PreTrainedModel
def use_cache_if_possible(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
use_cache = kwargs.pop("use_cache", True)
underline_func = func
if "functools" in str(func):
... | null | [
0.010912492871284485,
-0.002935113152489066,
0.020070984959602356,
-0.011370955966413021,
-0.0019601809326559305,
0.015590849332511425,
-0.05394768342375755,
-0.025558538734912872,
-0.001667054952122271,
0.013125790283083916,
-0.06538192182779312,
0.0225713811814785,
-0.026203803718090057,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_121-170 | 121 | 170 | logger = logging.get_logger(__name__)
NON_ENGLISH_TAGS = ["chinese", "dutch", "french", "finnish", "german", "multilingual"]
def filter_non_english(_, pretrained_name: str):
"""Filter all the model for non-english language"""
return not any(lang in pretrained_name for lang in NON_ENGLISH_TAGS)
def filter_r... | null | [
0.008035825565457344,
0.0018742342945188284,
-0.02307853288948536,
-0.015171022154390812,
0.04706752672791481,
0.058899663388729095,
-0.02564092166721821,
-0.03677411749958992,
-0.004616249818354845,
0.006697751581668854,
-0.03870515525341034,
0.03945811837911606,
-0.05027781054377556,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_161-210 | 161 | 210 | def check_subword_sampling(
tokenizer: PreTrainedTokenizer,
text: str | None = None,
test_sentencepiece_ignore_case: bool = True,
) -> None:
"""
Check if the tokenizer generates different results when subword regularization is enabled.
Subword regularization augments training data with subword ... | null | [
-0.008444973267614841,
-0.048662006855010986,
-0.005831628106534481,
0.0013890266418457031,
-0.004102217499166727,
0.0720989778637886,
-0.020629124715924263,
-0.0652213841676712,
-0.02159103937447071,
0.010063366033136845,
-0.04511728137731552,
-0.006254889536648989,
-0.017393218353390694,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_201-250 | 201 | 250 |
class TokenizersExtractor:
"""
Extractor implementation for tokenizers library tokenizer.json files.
This class extracts vocab and merges from a tokenizer.json file, similar to
SentencePieceExtractor for .model files.
"""
def __init__(self, tokenizer_file: str):
"""
Initiali... | null | [
0.0008800940122455359,
-0.025016525760293007,
-0.014298687689006329,
-0.0026381341740489006,
-0.004431471694260836,
0.06205432862043381,
-0.016502870246767998,
-0.03053019568324089,
-0.01233005803078413,
0.024060767143964767,
-0.0502602718770504,
-0.00004079856080352329,
-0.05694731324911117... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_241-290 | 241 | 290 | ValueError: If the tokenizer type is not supported or vocab is missing
"""
# Extract vocabulary
if "vocab" not in self.model_data:
raise ValueError(f"Tokenizer model type '{self.model_type}' does not have a 'vocab' field")
vocab_field = self.model_data["vocab"]
... | null | [
-0.021592047065496445,
-0.033453892916440964,
0.008364368230104446,
-0.03579666465520859,
-0.013266611844301224,
0.08009669929742813,
-0.024267423897981644,
-0.03247607871890068,
-0.0013624436687678099,
-0.008428247645497322,
-0.027439352124929428,
0.014840091578662395,
-0.05059235170483589,... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_281-330 | 281 | 330 | logger.warning(f"Invalid merge format: '{merge_item}', skipping")
else:
logger.warning(f"Unknown merge type: {type(merge_item)}, skipping")
# Extract added_tokens from tokenizer.json
# These are tokens that should not be split by the tokenizat... | null | [
-0.008068786934018135,
-0.02118738181889057,
-0.020531611517071724,
-0.0011409481521695852,
-0.026618637144565582,
0.07142776995897293,
0.004769269376993179,
-0.0019472407875582576,
-0.008853127248585224,
0.02479729987680912,
-0.031118955463171005,
0.014280707575380802,
-0.05095260217785835,... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_321-370 | 321 | 370 | # set to True to ignore casing when testing a sentencepiece tokenizer
# test_sentencepiece must also be set to True
test_sentencepiece_ignore_case = False
# Integration test data - can be optionally set by subclasses
# Default comprehensive test string covering various edge cases
integration_te... | null | [
-0.01085937675088644,
0.016978813335299492,
-0.009950199164450169,
0.0107694361358881,
0.03384436294436455,
0.0926826074719429,
0.0025365843903273344,
-0.027955766767263412,
-0.0006799911498092115,
0.027227824553847313,
-0.0546136237680912,
-0.013831958174705505,
-0.046536970883607864,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_361-410 | 361 | 410 | for pretrained_id in cls.from_pretrained_id
]
with open(f"{get_tests_dir()}/fixtures/sample_text.txt", encoding="utf-8") as f_data:
cls._data = f_data.read().replace("\n\n", "\n").strip()
cls.tmpdirname = tempfile.mkdtemp()
# save the first pretrained to... | null | [
0.042471688240766525,
-0.0036083345767110586,
0.021649334579706192,
0.022155070677399635,
-0.019601602107286453,
0.0635010302066803,
-0.00987576600164175,
-0.043499357998371124,
-0.0035660695284605026,
0.03625102713704109,
-0.07506752014160156,
0.014078313484787941,
-0.026215918362140656,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_401-450 | 401 | 450 | if " " not in output_txt and len(toks_ids) > 1:
output_txt = (
tokenizer.decode([toks_ids[0]], clean_up_tokenization_spaces=False)
+ " "
+ tokenizer.decode(toks_ids[1:], clean_up_tokenization_spaces=False)
)
if with_prefix_space:
... | null | [
0.022203166037797928,
0.018486017361283302,
0.009249929338693619,
0.01700940914452076,
0.009803375229239464,
0.06071823835372925,
-0.01640913262963295,
-0.03155122697353363,
-0.005845248233526945,
0.02474343217909336,
-0.09252136200666428,
-0.004360783379524946,
-0.056214191019535065,
0.05... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_441-490 | 441 | 490 | if not os.path.exists(tokenizer_json_path):
return None
extractor = TokenizersExtractor(tokenizer_json_path)
vocab_ids, vocab_scores, merges, added_tokens_decoder = extractor.extract()
vocab = vocab_scores
if _type := getattr(self.tokenizer_class, "model", None):
... | null | [
-0.01273531373590231,
-0.00799502432346344,
-0.01777496002614498,
-0.009320036508142948,
-0.00991347897797823,
0.06512250006198883,
0.013282050378620625,
-0.01228394452482462,
-0.004877279046922922,
0.021912110969424248,
-0.07413230836391449,
0.03607623279094696,
-0.027337748557329178,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_481-530 | 481 | 530 | except (TypeError, Exception):
return None
def tokenizer_integration_test_util(
self,
expected_encoding: dict,
model_name: str,
revision: str | None = None,
sequences: list[str] | None = None,
decode_kwargs: dict[str, Any] | None = None,
p... | null | [
-0.017032712697982788,
-0.02994765155017376,
0.010972893796861172,
-0.006775788031518459,
-0.00511735025793314,
0.04164011403918266,
-0.022453436627984047,
-0.026560083031654358,
-0.017923451960086823,
0.04457264766097069,
-0.06792150437831879,
-0.011350395157933235,
-0.018347611650824547,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_521-570 | 521 | 570 | "Transformers (formerly known as pytorch-transformers and pytorch-pretrained-bert) provides "
"general-purpose architectures (BERT, GPT-2, RoBERTa, XLM, DistilBert, XLNet...) for Natural "
"Language Understanding (NLU) and Natural Language Generation (NLG) with over 32+ p... | null | [
0.0032332208938896656,
-0.03160889074206352,
0.02030041255056858,
-0.020280487835407257,
-0.013019678182899952,
0.039338368922472,
-0.03527062013745308,
-0.04030376672744751,
-0.025240812450647354,
0.025677800178527832,
-0.04387352243065834,
-0.00887976586818695,
-0.026392217725515366,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_561-610 | 561 | 610 | padded_tokens_p = list(takewhile(lambda i: i == pad_token_id, reversed(input_p)))
self.assertSequenceEqual(padded_tokens_r, padded_tokens_p)
def assert_batch_padded_input_match(
self,
input_r: dict,
input_p: dict,
max_length: int,
pad_token_id: int,
m... | null | [
-0.015891944989562035,
-0.0034800104331225157,
0.041770532727241516,
-0.026458386331796646,
-0.045450497418642044,
0.038416020572185516,
-0.029974088072776794,
-0.05325073003768921,
-0.01114556472748518,
0.032074715942144394,
-0.026182301342487335,
-0.0014295376604422927,
-0.0382424108684062... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_601-650 | 601 | 650 | """Test `tokenize` with special tokens."""
tokenizer = self.get_tokenizer(do_lower_case=True)
SPECIAL_TOKEN_1 = "[SPECIAL_TOKEN_1]"
SPECIAL_TOKEN_2 = "[SPECIAL_TOKEN_2]"
# Both methods should add the token to `_extra_special_tokens` and `added_tokens_decoder`
tokenizer.... | null | [
-0.02386465109884739,
0.003782025771215558,
0.015989061444997787,
-0.028025757521390915,
-0.017116934061050415,
0.06589660048484802,
-0.03474286198616028,
-0.04789414629340172,
-0.004503753501921892,
0.002524740295484662,
-0.031630635261535645,
-0.004373340401798487,
-0.022600138559937477,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_641-690 | 641 | 690 | "merges",
"legacy",
"additional_special_tokens", # V5: deprecated, converted to extra_special_tokens
]:
self.assertIn(parameter_name, tokenizer.init_kwargs)
def test_tokenizers_common_properties(self):
tokenizer = self.get_tokeniz... | null | [
-0.02157037891447544,
-0.009542632848024368,
0.04444616287946701,
-0.0048037339001894,
-0.02490966022014618,
0.04574010148644447,
-0.030734406784176826,
-0.033036842942237854,
0.012809035368263721,
0.027281995862722397,
-0.04306715354323387,
0.0046877171844244,
-0.025432083755731583,
0.043... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_681-730 | 681 | 730 | attributes_list = [
"bos_token",
"eos_token",
"unk_token",
"sep_token",
"pad_token",
"cls_token",
"mask_token",
]
vocab = tokenizer.get_vocab()
token_id_to_test_setters = next(iter(vocab.values()))
... | null | [
-0.006264863535761833,
-0.008334322832524776,
0.022635722532868385,
-0.0016118732746690512,
-0.02183535508811474,
0.041058093309402466,
-0.031269997358322144,
-0.035117194056510925,
-0.002363743493333459,
0.013939497992396355,
-0.03258279711008072,
0.028212813660502434,
-0.026962770149111748... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_721-770 | 721 | 770 |
sample_text = " He is very happy, UNwant\u00e9d,running"
before_tokens = tokenizer.encode(sample_text, add_special_tokens=False)
before_vocab = tokenizer.get_vocab()
tokenizer.save_pretrained(tmpdirname)
after_tokenizer = tokenizer.__class__.from_pretrained(tmpdirname)
... | null | [
-0.0242718867957592,
0.017197050154209137,
0.026420025154948235,
0.05333118140697479,
0.004343402571976185,
0.052346453070640564,
0.008319304324686527,
-0.0067811026237905025,
0.0013284311862662435,
-0.014166335575282574,
-0.020602885633707047,
0.006962510757148266,
-0.03253672644495964,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_761-810 | 761 | 810 | tokenizer = tokenizer.__class__.from_pretrained(tmpdirname, model_max_length=43)
self.assertEqual(tokenizer.model_max_length, 43)
shutil.rmtree(tmpdirname)
# Test that we can also use the non-legacy saving format for fast tokenizers
tokenizer = self.get_tokenizer(model_max_leng... | null | [
-0.008731869049370289,
-0.024251788854599,
0.03769379481673241,
0.055512525141239166,
-0.014008003287017345,
0.03921955078840256,
-0.007388109341263771,
-0.045104172080755234,
-0.03408552706241608,
-0.0036489362828433514,
-0.027429791167378426,
0.011762565933167934,
-0.030959365889430046,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_801-850 | 801 | 850 | self.assertListEqual(
tokens,
self.integration_expected_tokens,
f"Tokenized tokens don't match expected for {tokenizer.__class__.__name__} ({tokenizer_type})",
)
# Test 2: IDs from encode match expected (without special tokens)
ids_from_encode = token... | null | [
-0.01961502805352211,
0.019513892009854317,
0.004871805664151907,
0.028876369819045067,
-0.0212799571454525,
0.02246263064444065,
-0.020309004932641983,
-0.056692834943532944,
0.0016019417671486735,
0.010182109661400318,
-0.014277882874011993,
0.014459549449384212,
-0.025441883131861687,
0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_841-890 | 841 | 890 | **(self.from_pretrained_kwargs if self.from_pretrained_kwargs is not None else {}),
)
self._run_integration_checks(tokenizer_original, "original")
def test_integration_from_extractor(self):
"""
Integration checks for a tokenizer built via TokenizersExtractor.
"""... | null | [
-0.010550525970757008,
0.017874063923954964,
0.008998597972095013,
0.011949197389185429,
0.006742929574102163,
0.03800727427005768,
-0.013460214249789715,
-0.025807127356529236,
0.0076476153917610645,
0.036001432687044144,
-0.08459996432065964,
0.0301513634622097,
-0.03427314758300781,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_881-930 | 881 | 930 | self.assertListEqual(ids, ids_2)
tokens_2 = tokenizer.convert_ids_to_tokens(ids)
self.assertNotEqual(len(tokens_2), 0)
text_2 = tokenizer.decode(ids)
self.assertIsInstance(text_2, str)
self.assertEqual(text_2, output_text)
def test_mask_output(self):
tokeni... | null | [
-0.025266151875257492,
0.009142836555838585,
-0.006639786995947361,
0.004952337127178907,
-0.01148514449596405,
0.03190973773598671,
-0.03714311122894287,
-0.04401962086558342,
-0.0031175201293081045,
0.025972479954361916,
-0.018688218668103218,
0.012696893885731697,
-0.021975383162498474,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_921-970 | 921 | 970 | # We use this assumption in the QA pipeline among other place
output = tokenizer(seq_0)
self.assertIn(0, output.sequence_ids())
output = tokenizer(seq_0, seq_1)
self.assertIn(0, output.sequence_ids())
self.assertIn(1, output.sequence_ids())
if tokenizer.num_spec... | null | [
-0.02067280001938343,
0.009463219903409481,
-0.0029870641883462667,
-0.01244454924017191,
0.00006869865319458768,
0.05206248536705971,
0.002132448833435774,
0.006364520639181137,
-0.0029740736354142427,
0.018532920628786087,
-0.011802607215940952,
-0.003254975425079465,
-0.009081910364329815... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_961-1010 | 961 | 1,010 | self.assertEqual(output, expected_output) # Test chat_template attribute is used if no arg is passed
# Check that no error raised
tokenizer.apply_chat_template(dummy_conversation, tokenize=True, return_dict=False)
with tempfile.TemporaryDirectory() as tmp_dir_name:
save_fil... | null | [
-0.004139741882681847,
-0.03212849795818329,
0.05451813340187073,
0.04874897003173828,
0.008442733436822891,
0.02928800880908966,
-0.011950518004596233,
-0.025762205943465233,
-0.022462312132120132,
-0.0032491900492459536,
-0.015603252686560154,
0.023015668615698814,
-0.006309430114924908,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1001-1050 | 1,001 | 1,050 | tokenizer.chat_template = "test template"
with tempfile.TemporaryDirectory() as tmpdirname:
tokenizer.save_pretrained(tmpdirname)
self.assertTrue(Path(tmpdirname, "chat_template.jinja").is_file())
self.assertFalse(Path(tmpdirname, "chat_template.json").is_file())
... | null | [
0.033044394105672836,
-0.02598109468817711,
0.03755048289895058,
0.04510998725891113,
-0.010528680868446827,
0.025675784796476364,
-0.015188300982117653,
0.0002842495159711689,
-0.03262646496295929,
0.004638882353901863,
-0.022491155192255974,
0.015324241481721401,
-0.01820509508252144,
0.... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1041-1090 | 1,041 | 1,090 | [
{"role": "system", "content": "system message"},
{"role": "user", "content": "user message"},
{"role": "assistant", "content": "assistant message"},
],
[
{"role": "system", "content": "system message 2"},
... | null | [
-0.017409244552254677,
0.029482584446668625,
0.02219662442803383,
0.010284089483320713,
-0.010572501458227634,
0.041561875492334366,
-0.021899815648794174,
-0.014023677445948124,
-0.013837208971381187,
-0.01960744895040989,
0.0004136614443268627,
-0.0059212930500507355,
-0.030286893248558044... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1081-1130 | 1,081 | 1,130 | dummy_conversation = [
{"role": "system", "content": "1"},
{"role": "user", "content": "2"},
{"role": "assistant", "content": "3"},
]
tokenizer = self.get_tokenizer()
break_output = tokenizer.apply_chat_template(dummy_conversation, chat_template=break... | null | [
-0.00994222704321146,
0.021064987406134605,
0.041882019490003586,
-0.020457975566387177,
-0.011964885517954826,
0.038532912731170654,
-0.030641982331871986,
0.029863592237234116,
0.014077706262469292,
0.004029210656881332,
0.0009302861290052533,
-0.0036467062309384346,
-0.035742465406656265,... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1121-1170 | 1,121 | 1,170 | "{% endgeneration %}"
"{{'\n'}}"
"{% endif %}"
"{% endfor %}"
)
conversations = [
[
{"role": "system", "content": "system message"},
{"role": "user", "content": "user message"},
{"role": "assistan... | null | [
-0.007879607379436493,
0.0073585715144872665,
0.005599373951554298,
-0.048358649015426636,
0.008808620274066925,
0.08343634009361267,
-0.04622315987944603,
-0.0035147888120263815,
-0.01657400093972683,
0.012719415128231049,
-0.01504511572420597,
0.017227470874786377,
-0.04583532363176346,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1161-1210 | 1,161 | 1,210 | conversations,
chat_template=dummy_template,
tokenize=True,
return_assistant_tokens_mask=True,
return_dict=True,
)
output_pt = tokenizer_r.apply_chat_template(
convers... | null | [
0.01671164482831955,
0.025552015751600266,
0.036147989332675934,
-0.04279430955648422,
-0.03425163775682449,
0.047938376665115356,
-0.028010860085487366,
-0.006759083364158869,
0.005657533183693886,
-0.023930875584483147,
-0.039625123143196106,
0.013537121005356312,
-0.007205270696431398,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1201-1250 | 1,201 | 1,250 | or assistant_end is None
or assistant_start2 is None
or assistant_end2 is None
):
continue
# assert 1 in first assistant message
self.assertEqual(
... | null | [
-0.02711179293692112,
0.025647128000855446,
0.0108987707644701,
-0.045558374375104904,
0.01755485311150551,
0.04220244660973549,
-0.007781886029988527,
0.0054354979656636715,
0.018913831561803818,
-0.02489246428012848,
-0.01904304511845112,
-0.0011395717738196254,
-0.01700238324701786,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1241-1290 | 1,241 | 1,290 | tokenize=True,
return_assistant_tokens_mask=True,
return_dict=True,
)
output_pt = tokenizer_r.apply_chat_template(
conversations[0],
chat_template=dummy_template,
token... | null | [
0.004854558501392603,
0.03007505275309086,
0.05393538624048233,
-0.025163190439343452,
-0.04529506340622902,
0.04151599854230881,
-0.040434304624795914,
-0.0037187873385846615,
0.001757692196406424,
-0.02101358026266098,
-0.05354609712958336,
0.010852191597223282,
-0.017119983211159706,
0.... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1281-1330 | 1,281 | 1,330 | )
self.assertTrue(
(output_pt["assistant_masks"][assistant_start : assistant_end + 1] == 1).all(),
)
self.assertEqual(
output["assistant_masks"][assistant_start2 : assistant_end2 + 1],
[1] * (assi... | null | [
-0.010466261766850948,
0.015075132250785828,
0.07607326656579971,
-0.028220510110259056,
0.01606835052371025,
0.03783577308058739,
-0.01271825935691595,
-0.01626492105424404,
0.004566533025354147,
-0.007506482768803835,
0.01040181890130043,
-0.002203847747296095,
-0.023460792377591133,
0.0... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1321-1370 | 1,321 | 1,370 | {"role": "system", "content": "system message"},
{"role": "user", "content": "user message"},
{
"role": "assistant",
"content": (
"start turn assistant. long string to be truncated, long string to be truncate... | null | [
-0.014757037162780762,
-0.009566998109221458,
0.0016620215028524399,
-0.03784966468811035,
-0.00238848477602005,
0.034164465963840485,
-0.04508238658308983,
0.01842798851430416,
-0.04700123518705368,
0.004008789546787739,
-0.055807922035455704,
0.0035864547826349735,
-0.011925610713660717,
... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1361-1410 | 1,361 | 1,410 | conversations[0], tokenize=False, chat_template=dummy_template
)
truncation_position = full_encoding.char_to_token(chat_string.index(", long string to be truncated,"))
if truncation_position is None:
self.skipTest("char_to_token ret... | null | [
0.0012910279911011457,
-0.012022672221064568,
0.028452221304178238,
-0.037044525146484375,
-0.02079242467880249,
0.031460847705602646,
-0.0015479574212804437,
-0.013446767814457417,
-0.04432962089776993,
0.004562246613204479,
-0.0359225757420063,
-0.0026614961680024862,
-0.022734101861715317... | Snowflake/snowflake-arctic-embed-m |
test_tokenization_common.py | tests/test_tokenization_common.py | consecutive_lines | lines_1401-1450 | 1,401 | 1,450 | chat_string = tokenizer_r.apply_chat_template(
conversations[0], tokenize=False, chat_template=dummy_template
)
assistant_start = output.char_to_token(0, chat_string.index("start turn assistant"))
if assistant_start is None:
... | null | [
0.007685166783630848,
0.00470774807035923,
0.02287575602531433,
-0.021964145824313164,
0.0014955545775592327,
0.025880668312311172,
0.016540061682462692,
0.009859230369329453,
0.0026000726502388716,
0.0265871062874794,
-0.03319074213504791,
-0.0015947134234011173,
0.0015313240000978112,
0.... | Snowflake/snowflake-arctic-embed-m |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.