MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / __init__

Method __init__

codegeex/mindspore/src/code_tokenizer.py:132–147  ·  view source on GitHub ↗
(
            self,
            tokenizer: GPT2TokenizerFast = None,
            start_extra_id: int = 10,
            max_len: int = 10,
            mode='13b',
            dict_file: str = None,
    )

Source from the content-addressed store, hash-verified

130
131class CodeTokenizer(object):
132 def __init__(
133 self,
134 tokenizer: GPT2TokenizerFast = None,
135 start_extra_id: int = 10,
136 max_len: int = 10,
137 mode='13b',
138 dict_file: str = None,
139 ):
140 self.tokenizer = tokenizer if tokenizer is not None else AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
141 if mode not in ['6b', '13b']:
142 raise ValueError(f"Invalid mode {mode}, choose from ['6b', '13b']")
143 self.start_extra_id = start_extra_id
144 self.max_len = max_len
145 self.mode = mode
146 self.code_dict = Code13BDictionary(dict_file, pad_to_vocab_size=51200) if self.mode == '13b' else None
147 self.eos_token_id = self.tokenizer.eos_token_id
148
149 def encode_code(self, code: str):
150 if self.mode == '6b':

Callers

nothing calls this directly

Calls 2

Code13BDictionaryClass · 0.85
from_pretrainedMethod · 0.80

Tested by

no test coverage detected