Short rate models
In a short rate model, we suppose that the short rate $r(t)$ evoloves according to a predefined SDE. What might be surprising is that once we set a model for the short rate, then the knowledge of the value of the short rate at a time $t$ allows us to fully reconstruct the yield curve. To be convinced of this, let's recall that the bond prices might be obtained, using no arbitrage pricing, as follows
\begin{equation}\label{eq:bond}
P(t,T) = \mathbf{E}_t^Q\left(e^{-\int_t^Tr(u)du}\right)
\end{equation}
There are several short-rate models used in practice. Here we'll just focus on the simplest ones.
Ho-Lee Model
This is probably the simplest model for the short rate, and it is just a simple diffusion model
\begin{equation}\label{eq:holee}
dr(t) = \sigma dW(t)
\end{equation}
where $W(t)$ is the usual Brownian motion. We will now find a closed expression for bond prices in the Ho-Lee model. Integrating from $t$ to $u$ yields
\begin{equation}\label{eq:cc}
r(u) = r(t) + \sigma\int_u^tdW(s)
\end{equation}
Pluggin \ref{eq:cc} in \ref{eq:bond} yields
\[
P(t,T) = \mathbf{E}_t^Q\left(e^{-r(t)(T-t)-\int_t^T\int_t^udW(s)du}\right)
\]
The double integral can be addressed using Fubini's theorem. Exchanging the order of integration between $u$ and $s$ we have
\[
\int_t^T\int_t^u dW(s)du=\int_t^T\int_s^T du dW(s) = \int_t^T (T-s)dW(s)
\]
This implies that $-\int_t^Tr(u)du$ is normally distributed with mean $-r(t)(T-t)$ and variance
\[
\frac{1}{3}\sigma^2(T-t)^3
\]
This implies that $e^{-\int_t^Tr(u)du}$ is log-normal. Since the expectation of a log-normal variable is $e^{\mu+\frac{1}{2}\sigma^2}$, we can say that
\begin{equation}\label{eq:holeebond}
P(t,T)=\text{exp}\left(-r(t)(T-t)+\frac{1}{6}\sigma^2(T-t)^3\right)
\end{equation}
We can now derive the expression for the continuos yield, which is simply
\[
y(t,T)=-\frac{\text{ln}P(t,T)}{T-t}=r(t)-\frac{1}{6}\sigma^2(T-t)^2
\]
In the simple form \ref{eq:holee} it's clearly impossible to fit the term structure of discount bonds, since we only have two parameters to play with, $r(0)$ and $\sigma$. Let's now make the model more flexible by adding a deterministic function of time to the model
\begin{equation}\label{eq:hl1}
r(t) = r(0) + a(t) + \sigma W(t)
\end{equation}
The question now becomes: is it possible with this extended model to fit the initial term structure of discount bonds? And if so, what functional form $a(t)$ should have?
If we assume the short rate follows \ref{eq:hl1}, that is, that the short rate process follows the SDE
\begin{equation}\label{eq:hl2}
dr(t) = a'(t)dt + \sigma dW(t)
\end{equation}
then following the same reasoning that led us to \ref{eq:holeebond}, will give us the expression for the bond prices at time $0$ in this new set-up, which is the same except for an additional factor
\[
P_m(0,t)=\text{exp}\left(-r(0)t+\frac{1}{6}\sigma^2 t^3\right) \text{exp}\left(-\int_0^ta(u)du\right)
\]
where we have added the subscript $m$ to emphasize that these are the bond prices implied by the model, to distinguish it from the market observable bond prices $P(0,t)$. If we want to find the expression for $a(t)$ such that $P_m(0,t)=P(0,t)$ then we get, by taking the log of both sides of the equation we have
\[
-\int_0^t a(u)du = r(0)t - \frac{1}{6}\sigma^2t^3 + \text{ln}P(0,t)
\]
Taking the derivative of both sides yields
\[
a(t)=-\frac{\partial \text{ln}P(0,t)}{\partial t} - r(0) + \frac{1}{2}\sigma^2 t^2=f(0,t)-r(0)+\frac{1}{2}\sigma^2t^2
\]