  We present a data-driven method to estimate absolute magnitudes for O- and
B-type stars from the LAMOST spectra, which we combine with {\it Gaia}
parallaxes to infer distance and binarity. The method applies a neural network
model trained on stars with precise {\it Gaia} parallax to the spectra and
predicts $K_{\rm 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 {\it 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 {\it Gaia}
parallax. This method of binary identification is particularly efficient for
unresolved binaries with near equal-mass 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. (2019) had argued for the presence of a
black hole and incorrect parallax measurement, and we do not find evidence for
errorneous {\it Gaia} parallax.
