save_generated_texts

Description

The save_generated_texts function saves the generated texts along with their corresponding prompts to a pandas pickle file. The output columns are X for generated text and P for the original prompt.

Arguments

  • generated_texts (list of str): The texts generated by the model.

  • prompts (list of str): The list of prompts corresponding to the generated texts.

  • save_name (str): The path without extension. The function appends .pkl but does not create the parent directory.

Returns

  • None: Saves the texts to a file named <save_name>.pkl and does not return a value.

The two sequences must have compatible lengths for construction of the pandas DataFrame. Saving errors are logged and re-raised.

Example Usage

from gpi_pack.llm import save_generated_texts

generated_texts = ["Text generated from prompt 1", "Text generated from prompt 2"]
prompts = ["Prompt 1", "Prompt 2"]

# Save the texts into "output.pkl"
save_generated_texts(generated_texts, prompts, "output")