add perplexity calculation