Towards Understanding Sycophancy in Language Models