I have an implementation and I want it to be as close as the repo implementation
- User
I have an implementation and I want it to be as close as the repo implementation
Assistant
I'll help you understand the key components of the repository's implementation. From the provided files, I can see this is a chemical reaction prediction model using T5-based architecture. Here are the main components and their implementation details:
- Model Architecture (ChemT5)
pythonclass ChemT5(nn.Module): def __init__(self, config=None): super(ChemT5, self).__init__() if config == None: config = { "name": "ChemT5", "ckpt": "" } self.config = config self.config.ckpt = "" self.main_model = T5ForConditionalGeneration.from_pretrained(self.config.ckpt) self.tokenizer = T5Tokenizer.from_pretrained(self.config.ckpt) if "stop_grad" in config: for k, v in self.main_model.named_parameters(): v.requires_grad = False self.hidden_size = self.main_model.config.hidden_size self.output_dim = self.hidden_size- Dataset Implementation (MolDataset)
pythonclass MolDataset(Dataset): def __init__(self, split=None, tokenizer_org=None, args=None): # Load data from file (json, csv, pkl, txt) self.split = split self.reaction_type = args.reaction_type self.tokenizer_org = tokenizer_org self.task = args.task self._load_data() def __getitem__(self, i): mol_rc_data = {} # Process instruction, input, output mol_rc_data['instruction'] = self.tokenizer_org(self.instruction[i], return_tensors="pt") mol_rc_data['input'] = self.tokenizer_org(self.input[i], return_tensors="pt") mol_rc_data['output'] = self.tokenizer_org(self.output[i], return_tensors="pt") if self.split in ['valid', 'test']: mol_rc_data['task'] = self.task[i] mol_rc_data['truth'] = self.output[i] return mol_rc_data
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.