compute cosine scores