2. Define the length of the interval $\left[x_{1}, x_{2}\right]\left(x_{1}<x_{2}\right)$ as $x_{2}-x_{1}$. Given that the domain of the function $y=\left|\log _{\frac{1}{2}} x\right|$ is $[a, b]$, and the range is $[0,2]$. Then the difference between the maximum and minimum values of the length of the interval $[a, b]$ is
2. 3 .

The graphs of the functions $y=\left|\log _{\frac{1}{2}} x\right|$ and $y=2$ are shown in Figure 3. From $y=0$, we get $x=1$; from $y=2$, we get $x=\frac{1}{4}$ or $x=4$. When $a=\frac{1}{4}, b=1$, $b-a$ reaches its minimum value $\frac{3}{4}$; when $a=\frac{1}{4}, b=4$, $b-a$ reaches its maximum value $\frac{15}{4}$. Therefore, $(b-a)_{\max }-(b-a)_{\min }=3$.