chapter eight

8 Summarization and more effective metric functions

 

This chapter covers

  • Using DSPy for text summarization
  • Creating more sophisticated metric functions
  • Lexical and semantic similarity
  • LLM as a judge evaluation

To evaluate or optimize any DSPy programs we create, we must have metric functions that can reliably evaluate the output they produce. So far we’ve worked primarily with classification problems, which allow for fairly straight-forward metric functions. Many other tasks required when working with LMs also require simple metric functions similar to these. For example, with entailment, as we saw in chapter 2, we test if one piece of text follows logically from another. If the LM returns only a boolean value indicating if there's logical entailment or not, the metric function can be very simple, just indicating if the LM’s response is correct or not. This is often true as well for question answering, at least when working strictly with questions that have short answers, for example, “What is the capital of France?” But, for many other LM-based tasks that we'll likely need to handle, much more complicated metric functions will be necessary.

8.1 Summarization

8.1.1 Types of summarization

8.1.2 Evaluating summarization

8.2 The DialogueSum dataset

8.3 Baseline summarizer

8.4 Evaluation by lexical similarity

8.4.1 Precision and recall

8.4.2 The F1 score

8.5 Evaluation using embeddings

8.6 Evaluation using LLM as a Judge

8.6.1 Metrics used with LLM as a Judge

8.6.2 Metric functions using LLM as a Judge

8.6.3 The volume of LM calls using LLM as a Judge

8.6.4 Using LLM as a Judge with DSPy

8.6.5 Creating the datasets for the judge programs

8.6.6 Groundedness

8.6.7 Completeness

8.6.8 Testing both groundedness and completeness

8.6.9 Evaluation By Q&A

8.6.10 An example creating and using a judge

8.7 Summary