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 test fiqa

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

Overview

Concrete tool for evaluating financial LLMs on the FiQA sentiment classification benchmark provided by the FinGPT Benchmark harness.

Description

The test_fiqa function evaluates a fine-tuned model on the FiQA dataset, which contains financial statements and headlines with sentiment labels. It loads the dataset from disk, applies an instruction formatter (`add_instructions` adds domain-specific context to the instruction), generates predictions in batches, normalizes outputs via `change_target`, and computes accuracy and F1 metrics.

The multi-template variant test_fiqa_mlt evaluates across multiple sentiment prompt templates and ensembles via `vote_output`.

Usage

Import this function when you need to evaluate model performance on the FiQA benchmark:

  • Benchmark evaluation: Standard FiQA sentiment accuracy and F1.
  • Multi-template evaluation: Template ensemble via `test_fiqa_mlt`.

Code Reference

Source Location

  • Repository: FinGPT
  • File: fingpt/FinGPT_Benchmark/benchmarks/fiqa.py
  • Lines: L59-113 (test_fiqa), L113-176 (test_fiqa_mlt)

Signature

def test_fiqa(
    args: Namespace,
    model: PeftModel,
    tokenizer: AutoTokenizer,
    prompt_fun: Callable = add_instructions,
) -> pd.DataFrame

def test_fiqa_mlt(
    args: Namespace,
    model: PeftModel,
    tokenizer: AutoTokenizer,
) -> pd.DataFrame

Import

from fiqa import test_fiqa, test_fiqa_mlt

I/O Contract

Inputs

Name Type Required Description
args Namespace Yes Contains batch_size, max_length, instruct_template
model PeftModel Yes Fine-tuned model in eval mode
tokenizer AutoTokenizer Yes Model tokenizer
prompt_fun Callable No Custom instruction formatter (default: add_instructions)

Outputs

Name Type Description
return value pd.DataFrame DataFrame with predictions and targets
metrics printed Accuracy, F1 macro, F1 micro, F1 weighted

Usage Examples

FiQA Evaluation

from fiqa import test_fiqa

results = test_fiqa(args, model, tokenizer)
# Prints accuracy and F1 scores

Related Pages

Implements Principle

Uses Heuristic

Requires Environment

Page Connections

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