code: def annotate(prediction_set, caption_files, output_dir):
      """
      Evaluates question and answer pairs using GPT-3
      Returns a score for correctness.
      """
      for file in caption_files:
          key = file[:-5]  # Strip file extension
          qa_set = prediction_set[key]
          question = qa_set["q"]
          answer = qa_set["a"]
          pred = qa_set["pred"]
          try:
              print(key, "query")
              # Compute the correctness score
              completion = openai.ChatCompletion.create(
                  model="gpt-3.5-turbo",
                  messages=[
                      {
                          "role": "system",
                          "content": "You are an intelligent chatbot designed for evaluating the factual accuracy of generative outputs for video-based question-answer pairs. "
                          "Your task is to compare the predicted answer with the correct answer and determine if they are factually consistent. Here's how you can accomplish the task:"
                          "------"
                          "##INSTRUCTIONS: "
                          "- Focus on the factual consistency between the predicted answer and the correct answer. The predicted answer should not contain any misinterpretations or misinformation.\n"
                          "- The predicted answer must be factually accurate and align with the video content.\n"
                          "- Consider synonyms or paraphrases as valid matches.\n"
                          "- Evaluate the factual accuracy of the prediction compared to the answer.",
                      },
                      {
                          "role": "user",
                          "content": "Please evaluate the following video-based question-answer pair:\n\n"
                          f"Question: {question}\n"
                          f"Correct Answer: {answer}\n"
                          f"Predicted Answer: {pred}\n\n"
                          "Provide your evaluation only as a factual accuracy score where the factual accuracy score is an integer value between 0 and 5, with 5 indicating the highest level of factual consistency. "
                          "Please generate the response in the form of a Python dictionary string with keys 'score', where its value is the factual accuracy score in INTEGER, not STRING."
                          "DO NOT PROVIDE ANY OTHER OUTPUT TEXT OR EXPLANATION. Only provide the Python dictionary string. "
                          "For example, your response should look like this: {''score': 4.8}.",
                      },
                  ],
              )
              # Convert response to a Python dictionary.
              response_message = completion["choices"][0]["message"][
                  "content"
              ]
              response_dict = ast.literal_eval(response_message)
              result_qa_pair = [response_dict, qa_set]
  
              print(key, "done")
  
              # Save the question-answer pairs to a json file.
              with open(f"{output_dir}/{key}.json", "w") as f:
                  json.dump(result_qa_pair, f, indent=4)
  
          except Exception as e:
              print(f"Error processing file '{key}': {e}")
  
file_path: llama-vid/llamavid/eval/evaluate_benchmark_1_correctness.py
imports: import openai
  import os
  import argparse
  import json
  import ast
  from multiprocessing.pool import Pool
label_desc: Use image node_id 2 for calling a global function with example usage: annotate(prediction_set, caption_files, output_dir) without return types