| 64 | """Class for encoder-decoder model""" |
| 65 | |
| 66 | def __init__(self, config): |
| 67 | super().__init__(config) |
| 68 | model_config = AutoConfig.from_pretrained(self.model_path) |
| 69 | arch = model_config.architectures[0].lower() |
| 70 | if "t5" in arch or 'fusionindecoder' in arch: |
| 71 | if self.fid: |
| 72 | from flashrag.generator.fid import FiDT5 |
| 73 | self.model = FiDT5.from_pretrained(self.model_path) |
| 74 | else: |
| 75 | self.model = T5ForConditionalGeneration.from_pretrained(self.model_path) |
| 76 | else: |
| 77 | if self.fid: |
| 78 | assert False, "FiD only support T5" |
| 79 | self.model = BartForConditionalGeneration.from_pretrained(self.model_path) |
| 80 | self.model.cuda() |
| 81 | self.model.eval() |
| 82 | self.tokenizer = AutoTokenizer.from_pretrained(self.model_path) |
| 83 | def update_additional_setting(self): |
| 84 | self.fid = self._config["use_fid"] |
| 85 | |