MCPcopy Index your code
hub / github.com/zai-org/CodeGeeX / encode_code

Method encode_code

codegeex/mindspore/src/code_tokenizer.py:149–159  ·  view source on GitHub ↗
(self, code: str)

Source from the content-addressed store, hash-verified

147 self.eos_token_id = self.tokenizer.eos_token_id
148
149 def encode_code(self, code: str):
150 if self.mode == '6b':
151 code = encode_whitespaces(code, self.start_extra_id, self.max_len)
152 input_ids = self.tokenizer(code).input_ids
153
154 elif self.mode == '13b':
155 code = encode_whitespaces(code, self.start_extra_id, self.max_len)
156 input_ids = self.code_dict.map_tokens(self.tokenizer.encode(code))
157 input_ids = np.array(input_ids, dtype=np.int64).reshape(1, -1)
158
159 return input_ids
160
161 def decode_code(self, input_ids):
162 if self.mode == '6b':

Callers 6

run_predictFunction · 0.95
run_predictFunction · 0.95
run_predictFunction · 0.95
run_predictFunction · 0.95
run_predictFunction · 0.95
run_predictFunction · 0.95

Calls 3

map_tokensMethod · 0.80
encode_whitespacesFunction · 0.70
encodeMethod · 0.45

Tested by

no test coverage detected