Initially the spring is un-deformed. Now the force 'F' is applied to 'B' as shown in the figure, When the displacement of 'B' with respect to 'A' is 'x' towards right in some time then the relative acceleration of 'B' with respect to 'A' at that moment is:
Initially in the starting the block B will accelerate faster as the x elongation in the spring is very small and will increase with time.
This is also on block A
Since its smaller than (F - kx) so A will have a different acceleration
For B
F - kx = mab
ab = F−kxm
For A
kx = aa
⇒aa=kxm
aba=ab−aa=F−kxm−kxm
= F−2kxm