Based on my understanding, both the doc ranking task and text similarity task take sentence pairs as model input. We use different loss to get better result for each of them.
There are many approaches for calculating loss for text similarity like Weighted similarity loss, Weighted cross-entropy loss, Soft label loss etc. Similarity loss forces the model to produce high probabilities for words that are relevant (close) to the target word. In Weighted cross-entropy loss, the optimization function can be defined as the “weighted” cross-entropy, every ground-truth token is represented with similarities to other words in the vocabulary. Soft label loss function can be interpreted as cross-entropy with soft targets.