  In the internal shock model for gamma-ray bursts (GRBs), the synchrotron
spectrum from the fast cooling electrons in a homogeneous downstream magnetic
field (MF) is too soft to produce the low-energy slope of GRB spectra. However
the magnetic field may decay downstream with distance from the shock front.
Here we show that the synchrotron spectrum becomes harder if electrons undergo
synchrotron and inverse-Compton cooling in a decaying MF. To reconcile this
with the typical GRB spectrum with low energy slope $\nu F_\nu\propto\nu$, it
is required that the postshock MF decay time is comparable to the cooling time
of the bulk electrons (corresponding to a MF decaying length typically of
$\sim10^5$ skin depths); that the inverse-Compton cooling should dominate
synchrotron cooling after the MF decay time; and/or that the MF decays with
comoving time roughly as $B\propto t^{-1.5}$. An internal shock synchrotron
model with a decaying MF can account for the majority of GRBs with low energy
slopes not harder than $\nu^{4/3}$.
