(self, **kwargs)
| 32 | self.eos_token_id = meta_template['eos_token_id'] |
| 33 | |
| 34 | def _load_model(self, **kwargs): |
| 35 | import sys |
| 36 | sys.path.insert(0, self.pkg_root) |
| 37 | from argparse import Namespace |
| 38 | |
| 39 | from evaluation.model import ModelForEvaluation, batch_filling_sequence |
| 40 | from generate import get_masks_and_position_ids |
| 41 | from generation import BaseStrategy, BeamSearchStrategy |
| 42 | from initialize import initialize_model_and_tokenizer |
| 43 | from SwissArmyTransformer import get_args |
| 44 | |
| 45 | self.get_masks_and_position_ids = get_masks_and_position_ids |
| 46 | self.batch_filling_sequence = batch_filling_sequence |
| 47 | |
| 48 | kwargs = { |
| 49 | 'bminf': False, |
| 50 | 'bminf_memory_limit': 20, |
| 51 | 'quantization_bit_width': None, |
| 52 | 'from_quantized_checkpoint': False, |
| 53 | 'sequential_initialization': False, |
| 54 | 'sampling_strategy': 'BaseStrategy', |
| 55 | 'min_gen_length': 0, |
| 56 | 'print_all_beams': False, |
| 57 | **kwargs, |
| 58 | } |
| 59 | |
| 60 | args_list = [ |
| 61 | ['--seed', '1234'], |
| 62 | ['--mode', 'inference'], |
| 63 | ['--out-seq-length', '256'], |
| 64 | ['--num-beams', '4'], |
| 65 | ['--length-penalty', '1.0'], |
| 66 | ['--no-repeat-ngram-size', '3'], |
| 67 | ['--temperature', '1.0'], |
| 68 | ['--top_k', '0'], |
| 69 | ['--top_p', '0'], |
| 70 | ['--output-path', 'samples'], |
| 71 | ['--model-parallel-size', '8'], |
| 72 | ['--num-layers', '70'], |
| 73 | ['--hidden-size', '12288'], |
| 74 | ['--inner-hidden-size', '32768'], |
| 75 | ['--vocab-size', '150528'], |
| 76 | ['--num-attention-heads', '96'], |
| 77 | ['--max-sequence-length', '2048'], |
| 78 | ['--tokenizer-type', 'icetk-glm-130B'], # gitleaks:allow |
| 79 | ['--layernorm-order', 'post'], |
| 80 | ['--load', self.ckpt_path], |
| 81 | ['--skip-init'], |
| 82 | ['--fp16'], |
| 83 | ['--input-source', 'interactive'], |
| 84 | ] # Come from the default initialize arguments of official repo |
| 85 | args = get_args(sum(args_list, [])) |
| 86 | args = Namespace(**vars(args), **kwargs) |
| 87 | args.do_train = False |
| 88 | self.args = args |
| 89 | |
| 90 | model, tokenizer = initialize_model_and_tokenizer(args) |
| 91 | self.model = model |
no test coverage detected