def __call__()

in src/engine/step4/model_dev/t5_inference.py [0:0]


    def __call__(self, input_text):
        """Maps a general NLQ (with placeholders) to a general SQL query (with placeholders)

        Args:
            input_text (str): General Natural Language question text.

        Returns:
            str: Generic SQL Query.
        """
        input_text = "translate English to SQL: %s" % input_text

        features = self.tokenizer.batch_encode_plus(
            [input_text],
            max_length=self.model.hparams.max_input_length,
            padding="max_length",
            truncation=True,
            return_tensors="pt",
        )

        output = self.model.model.generate(
            input_ids=features["input_ids"],
            attention_mask=features["attention_mask"],
            max_length=self.model.hparams.max_output_length,
            num_beams=2,
            repetition_penalty=2.5,
            length_penalty=1.0,
        )

        output = self.tokenizer.decode(output[0])

        # generic sql post-processing
        output = re.sub(PAD_P, "", output)
        output = output.replace("[", "<").replace("]", ">").strip()

        return output