MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / inference

Function inference

NLP/Text2SQL-BASELINE/script/text2sql_main.py:137–167  ·  view source on GitHub ↗

Args: config (TYPE): NULL Returns: TODO Raises: NULL

(config)

Source from the content-addressed store, hash-verified

135
136
137def inference(config):
138 """
139
140 Args:
141 config (TYPE): NULL
142
143 Returns: TODO
144
145 Raises: NULL
146 """
147 if config.model.init_model_params is None:
148 raise RuntimeError("config.init_model_params should be a valid model path")
149
150 dataset_config = {'db_file': config.data.db,
151 'input_encoder': g_input_encoder,
152 'label_encoder': g_label_encoder,
153 'is_cached': True}
154 test_set = DatasetClass(name='test', data_file=config.data.test_set, **dataset_config)
155 # batch_size 恒为 1
156 test_reader = DataLoaderClass(config, test_set, batch_size=1, shuffle=False)
157
158 model = ModelClass(config.model, g_label_encoder)
159 logging.info("loading model param from %s", config.model.init_model_params)
160 state_dict = paddle.load(config.model.init_model_params)
161 model.set_state_dict(state_dict)
162
163 logging.info("start of inference...")
164 launch.infer.inference(model, test_reader, config.data.output,
165 beam_size=config.general.beam_size,
166 model_name=config.model.model_name)
167 logging.info("end of inference...")
168
169
170def evaluate(config):

Callers 1

text2sql_main.pyFile · 0.70

Calls 2

inferenceMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected