MCPcopy Create free account
hub / github.com/google-research/language / get_tf_tokenizer

Function get_tf_tokenizer

language/orqa/utils/bert_utils.py:37–56  ·  view source on GitHub ↗

Creates a preprocessing function.

(module_handle)

Source from the content-addressed store, hash-verified

35
36
37def get_tf_tokenizer(module_handle):
38 """Creates a preprocessing function."""
39 tokenization_info = get_tokenization_info(module_handle)
40
41 table_initializer = tf.lookup.TextFileInitializer(
42 filename=tokenization_info["vocab_file"],
43 key_dtype=tf.string,
44 key_index=tf.lookup.TextFileIndex.WHOLE_LINE,
45 value_dtype=tf.int64,
46 value_index=tf.lookup.TextFileIndex.LINE_NUMBER)
47 vocab_lookup_table = tf.lookup.StaticVocabularyTable(
48 initializer=table_initializer,
49 num_oov_buckets=1,
50 lookup_key_dtype=tf.string)
51
52 tokenizer = tf_text.BertTokenizer(
53 vocab_lookup_table=vocab_lookup_table,
54 lower_case=tokenization_info["do_lower_case"])
55
56 return tokenizer, vocab_lookup_table
57
58
59def tokenize_with_original_mapping(text_input, tokenizer):

Callers

nothing calls this directly

Calls 1

get_tokenization_infoFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…