5. $\frac{9}{56}$

Analysis: As shown in the right figure, take the midpoint $F$ of $C D$, and connect $A F, B F$, $E F$, and connect $C E, D E$. It is easy to know that $C D \perp$ plane $A B F$, so $\angle A F E$ is the plane angle $\theta$ of the dihedral angle $E-C D-A$. Also, $A F=B F=\sqrt{3}=A B$, then $\angle A F B=\frac{\pi}{3}$, hence $\frac{f(A)}{f(B)}=\frac{|A E|}{|B E|}=\frac{\sin \angle A F E}{\sin \angle B F E}=\frac{\sin \theta}{\sin \left(\frac{\pi}{3}-\theta\right)}$. When $\theta>\frac{\pi}{4}$, $\frac{f(A)}{f(B)}>\frac{\sin \frac{\pi}{4}}{\sin \frac{\pi}{12}}=\sqrt{3}+1$. When $f(B)=1$, $f(A)$ can be $3,4,5,6,7,8$; when $f(B)=2$, $f(A)$ can be $6,7,8$; when $f(B)=3$, $f(A) \geq 9$, which does not exist. Therefore, the probability $P=\frac{9}{56}$.
5、In the tetrahedron $A-BCD$, $\triangle BCD$ and $\triangle ACD$ are both equilateral triangles with side length 2, and $\triangle BCD$ lies in plane $\boldsymbol{\alpha}$. The side edge $AB=\sqrt{3}$. Now, four of the eight labels numbered 1 to 8 are randomly attached to its four vertices, and the corresponding labels are denoted as $\boldsymbol{f}(\boldsymbol{\eta}),(\boldsymbol{\eta}$ taking values $A, B, C, D)$. $E$ is a point on the side edge $AB$. If $|BE|:|EA|=f(B): f(A)$, then the probability that the dihedral angle $E-CD-A$ is greater than $\frac{\pi}{4}$ is $\qquad$