Skip to main content

AutoEconSentiment

Python License

auto-econ-sentiment is a reproducible pipeline for measuring economic sentiment in central bank and financial text.

What It Does

  • Load: CSV, Excel, Parquet or a directory of .txt and Markdown files, with dates parsed from filenames
  • Clean: normalize economic text, tokenize, stem, split into sentences or paragraphs
  • Score: six central bank and financial dictionaries, plus optional transformer and LLM scoring with explicit label mappings
  • Compare: every _net column lies in $[-1, 1]$ with zero as neutral, so methods share one scale
  • Export: cleaned text, matched words, counts, probabilities and sentiment scores
  • Audit: dictionary and model disagreement stays visible for research workflows

Table of Contents

Documentation

  • Architecture
    • pipeline stages and components
    • config-driven design, tests, directory tree
  • Data and Outputs
    • input formats, directory loader
    • output files, column names, score scales
  • Examples
    • YAML and Python runs
    • segmentation, method comparison, transformer setup
  • LLM Scoring
    • Ollama and OpenAI-compatible providers
    • polarity x confidence, prompts, output columns
  • Roadmap
    • v1.0.2 scope, planned features
    • release and tagging steps
  • Transformer notebook
    • walkthrough of transformer scoring

Quick Start

Install from PyPI, adding the extras you need:

pip install auto-econ-sentiment                 # lexical dictionaries only
pip install 'auto-econ-sentiment[transformers]' # + Hugging Face classifiers
pip install 'auto-econ-sentiment[llm]'          # + Ollama / OpenAI-compatible LLMs

Or, working from a clone of this repository:

uv sync

Run the default YAML-configured pipeline:

uv run python -m src.auto_econ_sentiment.pipeline

Or call the Python API:

from auto_econ_sentiment.pipeline import AutoEconSentiment

analyzer = AutoEconSentiment(
    import_file_path="data/raw/basic_tests/monetary_policy_statement.parquet.gzip",
    text_column="text",
    date_column="date",
    export_path="data/sentiment/basic_tests/",
)

analyzer.run(
    clean_config={"tokenize": True, "stem": True},
    dictionaries={"unstemmed": ["correa", "hubert", "lm", "hiv"], "stemmed": ["ap", "bn"]},
    aggregation_methods=["posneg", "allwords"],
    export_results=True,
)

Transformer Quick Start

Transformer support is optional so lexical users do not need to install torch or download Hugging Face models.

uv sync --extra transformers

Then enable transformer models in params.yaml:

transformer:
  enabled: true
  text_column_transformer: text_clean
  aggregation_methods: [bysentence]
  output_schema: shares
  min_sentence_chars: 20
  sentence_probability_cutoff: 0.7
  models:
    - name: gtfintechlab/FOMC-RoBERTa
      short_name: fomc
      num_labels: 3
      # FOMC-RoBERTa classifies stance: LABEL_0 dovish, LABEL_1 hawkish,
      # LABEL_2 neutral. Hawkish maps to +1.
      label_mapping:
        LABEL_0: negative
        LABEL_1: positive
        LABEL_2: neutral
      sentiment_values:
        positive: 1
        negative: -1
        neutral: 0

The transformer examples in params.yaml show the supported model-list format, including each model's label mapping.

Transformer runs export sentiment_transformer.parquet.gzip and, for sentence-level aggregation, sentiment_transformer_sentence_probabilities.parquet.gzip, which carries each sentence's number and text next to its class probabilities.

LLM Quick Start

uv sync --extra llm

Set llm.enabled: true in params.yaml and point it at a local Ollama model or any OpenAI-compatible API. See LLM Scoring for providers, prompting and output columns.

CBS Speeches Demo

Download the CBS central bank speeches dataset and run the sentiment pipeline:

uv run python -m src.data.cb_speeches_download
uv run python -m src.data.cb_speeches_clean

Then open notebooks/demo_cb_speechs.ipynb to explore the outputs.

Citations

To cite auto-econ-sentiment itself, use the Cite this repository button on GitHub, which reads CITATION.cff. Contributions are welcome; see CONTRIBUTING.

Dataset:

  • Campiglio, E., Deyris, J., Romelli, D., & Scalisi, G. (2025). Warning words in a warming world: Central bank communication and climate change. European Economic Review, 105101.

Lexical dictionaries:

  • Loughran, T. and B. McDonald (2011). When Is a Liability Not a Liability? Textual Analysis, Dictionaries, and 10-Ks. The Journal of Finance 66, 35-65.
  • Correa, R., K. Garud, J. Londono, and N. Mislang (2017). Sentiment in Central Bank as Financial Stability Reports. International Finance Discussion Paper 1203.
  • Hubert, P. and F. Labondance (2021). The signaling effects of central bank tone. European Economic Review 133, 103684.
  • Stone, P. J., D. C. Dunphy, and M. S. Smith (1966). The General Inquirer: A Computer Approach to Content Analysis.
  • Apel, M. and M. Blix Grimaldi (2014). How Informative Are Central Bank Minutes? Review of Economics 65(1), 53-76.
  • Bennani, H. and M. Neuenkirch (2017). The (Home) Bias of European Central Bankers. Applied Economics 49(11), 1114-1131.

Transformer models:

  • Pfeifer, M. and V. P. Marohl (2023). CentralBankRoBERTa: A fine-tuned large language model for central bank communications. The Journal of Finance and Data Science 9, 100114.
  • Shah, A., S. Paturi, and S. Chava (2023). Trillion Dollar Words: A New Financial Dataset, Task & Market Analysis. Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics, 6664-6679.
  • Araci, D. (2019). FinBERT: Financial Sentiment Analysis with Pre-trained Language Models. arXiv:1908.10063.
  • Huang, A. H., H. Wang, and Y. Yang (2023). FinBERT: A Large Language Model for Extracting Information from Financial Text. Contemporary Accounting Research 40(2), 806-841.

Metadata

Release files for auto-econ-sentiment 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for auto-econ-sentiment 1.0.2
File Size Uploaded Provenance Actions
auto_econ_sentiment-1.0.2.tar.gz 69.8 kB With provenance Details for auto_econ_sentiment-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for auto-econ-sentiment 1.0.2
File Interpreter ABI Platform Actions
auto_econ_sentiment-1.0.2-py3-none-any.whl Python 3 none any Details for auto_econ_sentiment-1.0.2-py3-none-any.whl

Total release size: 140.0 kB

Release files / auto_econ_sentiment-1.0.2.tar.gz

Download URL auto_econ_sentiment-1.0.2.tar.gz
Size 69.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3cbe5950b1ca196e56629667ab2ffff00d5534389f5589be76d388eb1c14922d
BLAKE2b-256 checksum
How to use checksums
cd3e35ea24c710dc584658b0e18765e8f6adac012040baf50651fb8e72a10359
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release files / auto_econ_sentiment-1.0.2-py3-none-any.whl

Download URL auto_econ_sentiment-1.0.2-py3-none-any.whl
Size 70.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17f4e9e30d2ef676b63f459e8a66944f9825cb0175369d8d9680b02760126b92
BLAKE2b-256 checksum
How to use checksums
3a7c5b9f576e79bda9e97f556d6a269d337824f1f89f5209b967f39e3761cc96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Security for auto-econ-sentiment 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for auto_econ_sentiment-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page