We present a data-driven method to estimate absolute magnitudes for O-and B-type stars from the LAMOST spectra, which we combine with Gaia parallaxes to infer distance and binarity. The method applies a neural network model trained on stars with precise Gaia parallax to the spectra and predicts K s -band absolute magnitudes M Ks with a precision of 0.25 mag, which corresponds to a precision of 12% in spectroscopic distance. For distant stars (e.g. > 5 kpc), the inclusion of constraints from spectroscopic M Ks significantly improves the distance estimates compared to inferences from Gaia parallax alone. Our method accommodates for emission line stars by first identifying them via PCA reconstructions and then treating them separately for the M Ks estimation. We also take into account unresolved binary/multiple stars, which we identify through deviations in the spectroscopic M Ks from the geometric M Ks inferred from Gaia parallax. This method of binary identification is particularly efficient for unresolved binaries with near equalmass components and thus provides an useful supplementary way to identify unresolved binary or multiple-star systems. We present a catalog of spectroscopic M Ks , extinction, distance, flags for emission lines, and binary classification for 16,002 OB stars from LAMOST DR5. As an illustration of the method, we determine the M Ks and distance to the enigmatic LB-1 system, where Liu et al. (2019a) had argued for the presence of a black hole and incorrect parallax measurement, and we do not find evidence for errorneous Gaia parallax.