Measurements of the cross section for producing b quarks in the reaction pp→bb[over ¯]X are reported in 7 and 13TeV collisions at the LHC as a function of the pseudorapidity η in the range 2<η<5 covered by the acceptance of the LHCb experiment. The measurements are done using semileptonic decays of b-flavored hadrons decaying into a ground-state charmed hadron in association with a muon. The cross sections in the covered η range are 72.0±0.3±6.8 and 154.3±1.5±14.3 μb for 7 and 13TeV. The ratio is 2.14±0.02±0.13, where the quoted uncertainties are statistical and systematic, respectively. The agreement with theoretical expectation is good at 7TeV, but differs somewhat at 13TeV. The measured ratio of cross sections is larger at lower η than the model prediction.