6. In tetrahedron $ABCD$, $\triangle ABD$ is an equilateral triangle, $\angle BCD=90^{\circ}, BC=CD=1, AC=\sqrt{3}, E$ and $F$ are the midpoints of $BD$ and $AC$ respectively. Then the cosine of the angle formed by line $AE$ and $BF$ is $\qquad$
6. $\frac{\sqrt{2}}{3}$.
$$
\begin{array}{l}
\text { Given } \angle B C D=90^{\circ}, B C=C D=1 \\
\Rightarrow B D=B A=A D=\sqrt{2} \\
\Rightarrow \angle A B C=\angle A D C=90^{\circ} .
\end{array}
$$

Thus, $\overrightarrow{A E}=\frac{1}{2}(\overrightarrow{A B}+\overrightarrow{A D}), \overrightarrow{B F}=\frac{1}{2} \overrightarrow{A C}-\overrightarrow{A B}$
$$
\begin{aligned}
\Rightarrow & \overrightarrow{A E} \cdot \overrightarrow{B F}=\frac{1}{2}(\overrightarrow{A B}+\overrightarrow{A D}) \cdot\left(\frac{1}{2} \overrightarrow{A C}-\overrightarrow{A B}\right) \\
= & \frac{1}{4} \overrightarrow{A B} \cdot \overrightarrow{A C}-\frac{1}{2} \overrightarrow{A B}^{2}+ \\
& \frac{1}{4} \overrightarrow{A D} \cdot \overrightarrow{A C}-\frac{1}{2} \overrightarrow{A D} \cdot \overrightarrow{A B} \\
& =-\frac{1}{2}
\end{aligned}
$$
$$
\Rightarrow \cos \langle\overrightarrow{A E}, \overrightarrow{B F}\rangle=\frac{\overrightarrow{A E} \cdot \overrightarrow{B F}}{|\overrightarrow{A E}||\overrightarrow{B F}|}=-\frac{\sqrt{2}}{3} \text {. }
$$

Therefore, the required answer is $\frac{\sqrt{2}}{3}$.