Implementation:AI4Finance Foundation FinGPT vote output
| Knowledge Sources | |
|---|---|
| Domains | NLP, Evaluation, Ensemble_Methods |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
Concrete tool for ensembling sentiment predictions across multiple prompt templates via majority voting provided by the FinGPT Benchmark FPB module.
Description
The vote_output function implements template ensemble voting for the multi-template sentiment evaluation variants (`test_fpb_mlt`, `test_fiqa_mlt`). For each input, the model is prompted with multiple sentiment instruction templates (from `sentiment_templates.txt`), producing one prediction per template. `vote_output` normalizes each prediction via `change_target`, counts votes for positive/negative/neutral, and returns the majority label (positive if positive > negative, negative if negative > positive, else neutral).
Usage
Import this function when you need to ensemble sentiment predictions across prompt templates:
- Multi-template evaluation: Ensembling `_mlt` benchmark variants.
- Prompt robustness: Reducing sensitivity to instruction phrasing.
Code Reference
Source Location
- Repository: FinGPT
- File: fingpt/FinGPT_Benchmark/benchmarks/fpb.py
- Lines: L41-51
Signature
def vote_output(
x: pd.Series,
) -> str
Import
from fpb import vote_output
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| x | pd.Series | Yes | Row with out_text_0, out_text_1, ... columns (one per template) |
Outputs
| Name | Type | Description |
|---|---|---|
| return value | str | Majority-voted sentiment: 'positive', 'negative', or 'neutral' |
Usage Examples
Ensemble Voting
from fpb import vote_output
# Row with predictions from 5 templates
row = pd.Series({
'out_text_0': 'positive',
'out_text_1': 'positive',
'out_text_2': 'neutral',
'out_text_3': 'positive',
'out_text_4': 'negative',
})
result = vote_output(row)
# 'positive' (3 positive > 1 negative)
Related Pages
Implements Principle
- Principle:AI4Finance_Foundation_FinGPT_Benchmark_Evaluation
- Principle:AI4Finance_Foundation_FinGPT_Metric_Computation
Uses Heuristic
- Heuristic:AI4Finance_Foundation_FinGPT_Output_Normalization
- Heuristic:AI4Finance_Foundation_FinGPT_Template_Ensemble_Voting