A molecule is a set of atoms connected by bonds, and that connectivity is what determines its chemistry. To feed a molecule to a model, we keep the connectivity but change the format. Two representations dominate.
The first is a graph: atoms become nodes, bonds become edges. Each node carries a small list of features — element type, charge, whether it sits in a ring — and each edge carries bond order and type. A graph is a natural fit because most molecular properties depend on which atoms are near which, not on any absolute position in space.
The second is a line notation, most commonly SMILES. Here the same structure is written as a string of characters, for example \(\text{CCO}\) for ethanol: a carbon, bonded to another carbon, bonded to an oxygen. Branching uses parentheses and rings use paired digits, so a fairly complex molecule can be written as one line of text.
Both forms are lossy in the same way: they describe connectivity but not the molecule's actual three-dimensional shape. That is usually acceptable for property prediction, and it is a real limitation for anything that depends on shape.