# Language Models for Predicting Organic Synthesis Procedures
## 4 The Data
### Dataset Preparation  
The _PRP-931k_ dataset has been prepared by utilizing a larger EPO/USPTO dataset [48] of chemical reactions and their related procedures. The dataset undergoes several stages of refinement to make it appropriate for our task. For input, we combine reactants and products from the EPO/USPTO dataset, which provides reactants in SMILES format. We created a curated list of 252 undesirable compounds, including inorganic substances, organic solvents, acids, bases, and complexes, to filter out ancillary substances from the input. This list, available in our project repository, enhances the dataset beyond the initial removals in the EPO/USPTO reactant column. Importantly, these filtered compounds are not eliminated from the reaction but are included in the output procedure text. This approach simulates real-world scenarios where scientists lack complete knowledge of required solvents and agents when synthesizing novel chemicals. By creating this learning environment, we aim to mirror the challenges researchers face, making the work more difficult but ultimately more beneficial by offering additional valuable information. We used RDKit to standardize SMILES notation for all compounds. Reactants and products are concatenated into a single line, using \"\(\mid\)\" to separate compounds and \"\(>>\)\" between reactants and products. While similar tasks often use a dot (\".\") for separation, we opted for the bar symbol to avoid confusion, as dots can represent disconnected compounds in SMILES notation (\"[Li+]. [OH-]\" for lithium hydroxide). We removed duplicate input instances, including variations where the reactant order was swapped. Instances with less than five total atoms were discarded and validated as incorrectly mapped reactions. We also identified cases with missing reactants by calculating the average atom count ratio between reactants and products. Ratios of 2.5 or higher typically indicate missing compounds. An expert-determined threshold of 2.3 was used to remove 20,000 instances, resulting in a cleaner dataset despite the removal of some correct instances. This approach is effective only when ancillary substances are absent from the reaction notation. In the first stage of output processing, we performed common checks and initial cleaning. Quantities of added compounds were removed, as they are typically calculated separately. Valid procedures must meet specific requirements: they cannot contain actions like _FollowOtherProcedure_, _OtherLanguage_, or _InvalidAction_. Some actions (e.g., Concentrate, Filter) may appear without parameters, while others require them. The action names were designed during the procedure formalization to accurately represent the original natural language procedure. We aimed to maintain the original framework without altering procedure actions, either removing instances entirely or leaving actions unchanged. Our approach prioritizes retaining the formalized output format, removing instances with mistakes rather than modifying procedures. This decision is supported by limited research in the field and allows for the future tracking of conceptual changes in action name inference, definitions, and syntax. Reactants and products need to be tokenized. To avoid the need for complex IUPAC or SMILES notation in the output, which would require accurate generation each time, we denote reactants as $_R1S_, $_R2S_,..., $_RNS_, and products as $_SP1S_, $_SP2S_,..., $_SPNS_. Only compounds related to the input are tokenized. The mapping between SMILES and IUPAC naming is accomplished by the same process which allows the dataset to have two formats in the first place. A vocabulary of IUPAC to SMILES names is available alongside the EPO/USPTO dataset mentioned earlier. The tokenization does not necessitate copying the reaction compounds to the resulting procedure and, most importantly, avoids potential errors in the notation. There are generally four types of parameters: compounds, solvents, duration, and temperature.