SIGNIFICANCE: Diffuse optical modalities such as broadband near-infrared spectroscopy (bNIRS) and hyperspectral imaging (HSI) represent a promising alternative for low-cost, non-invasive, and fast monitoring of living tissue. Particularly, the possibility of extracting the molecular composition of the tissue from the optical spectra deems the spectroscopy techniques as a unique diagnostic tool. AIM: No established method exists to streamline the inference of the biochemical composition from the optical spectrum for real-time applications such as surgical monitoring. We analyze a machine learning technique for inference of changes in the molecular composition of brain tissue. APPROACH: We propose modifications to the existing learnable methodology based on the Beer-Lambert law. We evaluate the method's applicability to linear and nonlinear formulations of this physical law. The approach is tested on data obtained from the bNIRS- and HSI-based monitoring of brain tissue. RESULTS: The results demonstrate that the proposed method enables real-time molecular composition inference while maintaining the accuracy of traditional methods. Preliminary findings show that Beer-Lambert law-based spectral unmixing allows contrasting brain anatomy semantics such as the vessel tree and tumor area. CONCLUSION: We present a data-driven technique for inferring molecular composition change from diffuse spectroscopy of brain tissue, potentially enabling intra-operative monitoring.