docstr: Evaluate the generation model, given the retrieval results df
docstr_tok: ["Evaluate","the","generation","model",",","given","the","retrieval","results","df"]
code: def evaluate_generation(self, df: pd.DataFrame):
      """Evaluate the generation model, given the retrieval results df"""
  
      prompts = self.get_evaluation_prompts(df)
  
      raw_generated_answers = [
          self.rag.llm(prompt) for prompt in prompts
      ]
  
      generated_answers = self.extract_generated_texts(
          raw_generated_answers
      )
      reference_answers = self.extract_reference_answers(df)
  
      df["generated_answers"] = generated_answers
      df["reference_answers"] = reference_answers
  
      # tokenize generated and reference answers
      df["tokenized_generated_answers"] = df.apply(
          lambda x: self._tokenize(x["generated_answers"]), axis=1
      )
      df["tokenized_reference_answers"] = df.apply(
          lambda x: self._tokenize(x["reference_answers"]), axis=1
      )
  
      # embed generated answers and reference answers
      generated_answer_embeddings = self.embed_texts(generated_answers)
  
      reference_answer_embeddings = self.embed_texts(reference_answers)
  
      df = self.calculate_generation_metrics(
          df, generated_answer_embeddings, reference_answer_embeddings
      )
  
      return df
  
imports: import ast
  from collections import defaultdict
  from typing import List
  import nltk
  import pandas
  from nltk import word_tokenize
  from nltk.translate.bleu_score import sentence_bleu
  from nltk.translate.meteor_score import meteor_score
  from rouge_score import rouge_scorer
  from scipy.spatial import distance
  from mindsdb.integrations.handlers.writer_handler.settings import WriterHandlerParameters
  from mindsdb.utilities import log
label_desc: Use image node_id 22 for calling the WriterEvaluator obj's underlying member method code with example usage: obj.evaluate_generation(df) and returns: df