Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AI4Finance Foundation FinGPT TruthfulQA Utilities

From Leeroopedia
Knowledge Sources
Domains Evaluation, Truthfulness_Assessment, NLP
Last Updated 2026-10-18 00:00 GMT

Overview

Concrete tool for loading, formatting, and saving TruthfulQA questions and model answers with preset prompt support provided by the FinGPT MultiAgentsRAG subproject.

Description

The utilities module (TruthfulQA) provides the I/O and prompt-formatting helpers used by `evaluate.py`. `load_questions` reads the questions CSV, `save_questions` writes answers, and `format_prompt` renders a fully formatted prompt based on the selected preset (`qa`, `chat`, `long`, `harm`, `null`) and model format (`general`, `T5`, `UQA`).

Usage

Import these utilities when you need to load TruthfulQA questions or format prompts for custom model evaluation.

Code Reference

Source Location

Signature

def load_questions(filename='questions.csv') -> pd.DataFrame:
    """Load TruthfulQA questions from CSV, dropping all-null columns."""

def save_questions(questions, filename='answers.csv') -> None:
    """Save questions (with model answers) to CSV."""

def format_prompt(ser, preset='qa', format='general') -> str:
    """Return fully formatted prompt (preset + question) for a given row.

    Args:
        ser: pandas Series (row from questions DataFrame)
        preset: 'qa' | 'chat' | 'long' | 'harm' | 'null'
        format: 'general' | 'T5' | 'UQA'
    Returns:
        str: formatted prompt
    """

def format_prompt_with_answer_strings(question, ans, preset='qa', format='general') -> str:
    """Return formatted prompt with a specific answer choice appended."""

Import

from utilities import load_questions, save_questions, format_prompt

I/O Contract

Inputs

Name Type Required Description
filename str Yes (load/save) Path to CSV file
ser pd.Series Yes (format_prompt) Question row
preset str No Prompt preset (default 'qa')
format str No Model format: general/T5/UQa

Outputs

Name Type Description
load_questions returns pd.DataFrame Questions DataFrame
format_prompt returns str Formatted prompt string

Usage Examples

Format a TruthfulQA Prompt

import pandas as pd
from utilities import load_questions, format_prompt

questions = load_questions("questions.csv")
prompt = format_prompt(questions.iloc[0], preset="qa", format="general")
print(prompt)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment