Skip to main content

A Python package to detect AI-generated text in financial documents using the msperlin/finbert-ai-detector model.

Project description

FinBERT AI Detector

This is an easy-to-use Python package for the msperlin/finbert-ai-detector model.

The model is designed specifically to detect AI-generated text in financial documents, such as corporate annual reports (e.g., 10-K filings). It is fine-tuned from yiyanghkust/finbert-pretrain.

The model is used in the working paper:

Perlin, M. S., Foguesatto, C. R., Galanos, A. K., & Affonso, F. (2026). The use of AI in 10-K filings: An empirical analysis. Finance Research Letters.

Features

  • GPU automatically supported: CUDA and Apple Silicon (MPS) are fully supported if available.
  • Easy Interface: Detect AI-generated text with a single method call.
  • Batched Inference: Run predictions efficiently on huge datasets using batched inputs.

Installation

Install using pip:

pip install finbert-ai-detector

Quick Start

from finbert_ai_detector import FinbertAIDetector

# Initialize the detector (downloads the model if not cached)
detector = FinbertAIDetector()

# Example text
text = "The Tax Cuts and Jobs Act enacted in 2017 in the United States, significantly changed the tax rules applicable to U.S.-domiciled corporations. Changes such as lower corporate tax rates, full expensing for qualified property, taxation of offshore earnings, limitations on interest expense deductions, and changes to the municipal bond tax exemption may impact demand for our products and services."

# Predict a single text
result = detector.predict(text)
print(f"Prediction: {result['label']}")
print(f"AI Probability: {result['ai_probability']:.2%}")

Batched Prediction

For analyzing multiple documents or sentences quickly, use batched inference:

from finbert_ai_detector import FinbertAIDetector

detector = FinbertAIDetector()

texts = [
    "Company revenue grew by 15% due to increased demand in the European market.",
    "A machine learning model generated this text based on recent financial statements."
]

results = detector.predict_batch(texts)
for result in results:
    print(f"Text: {result['text']}")
    print(f"AI Probability: {result['ai_probability']:.2%}")
    print("---")

Intended Use & Limitations

  • Intended Usage: Analyzing formal financial reports, press releases, corporate filings, and similar structured financial disclosures.
  • Limitations: The model is optimized specifically for the formal, complex tone of financial documents. Its accuracy may be lower when applied to texts outside the financial domain, such as social media posts, casual emails, news articles, or creative text.
  • Length Constraint: The underlying standard FinBERT architecture implies a maximum sequence length of 512 tokens. Texts longer than this will be truncated prior to sequence prediction.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finbert_ai_detector-0.1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finbert_ai_detector-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file finbert_ai_detector-0.1.1.tar.gz.

File metadata

  • Download URL: finbert_ai_detector-0.1.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for finbert_ai_detector-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a1ea8ff13c9b5161ec5e3418e0d5ee4ac351d0a5a2fc434c8e86d6a157dccf36
MD5 61fe35452a5a3714815dc1dccbe21970
BLAKE2b-256 13d414bac7c7f95a59af8d160dd68a85fe07d44af2fc2d84584bd7380fdcc551

See more details on using hashes here.

File details

Details for the file finbert_ai_detector-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for finbert_ai_detector-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ac2b1b3217a8dcd8e26c846ef876eb754a0c4129d80695640d6bd57e153427d
MD5 9f3cfefb7c61fb70d3b1f41c58fc726d
BLAKE2b-256 1f49f4d7d6f482d2849045a2b63bef62010930b7f4d3dda3d3ffee922ff7adc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page