2025-11-24: BERTrend has been integrated into the Netminer 5 data analysis tool !
The code in this repository is part of the work described in the paper: BERTrend: Neural Topic Modeling for Emerging Trends Detection.
BERTrend is a novel framework for detecting and monitoring weak signals in large, evolving text corpora. It uses neural topic modeling, specifically BERTopic, in an online learning setting to identify and track topic evolution over time.
BERTrend classifies topics as noise, weak signals, or strong signals based on their popularity trends, using a metric that considers both the number of documents and update frequency. This method allows for real-time monitoring and analysis of emerging trends while filtering out noise.
The BERTrend repository provides a set of metrics, methods, and visualization tools to support the analysis of dynamic topic modeling in large text corpora. The tools are designed to help users detect, analyze, and visualize emerging topics and trends over time.
The code base is illustrated via three main demos:
- bertrend/demos/topic_analysis: Focuses on dynamic topic modeling analysis using:
- Dedicated metrics, called TEMPTopic:
- Stability Evaluation: Measures the stability of topics over time, evaluating how consistent and coherent topics remain.
- Volatility Assessment: Analyzes the volatility of topics, identifying how much topics change over different time periods.
- Two Perspectives:
- Temporal Topic Embedding Stability: Evaluates the stability of topic embeddings over time.
- Temporal Topic Representation Stability: Assesses the stability of topic representations over time.
- Visualization tools to easily assess the results.
- Dedicated metrics, called TEMPTopic:
TEMPTopic.mp4
- Data management: selection of single/multiple datasets, filter by time, filter by size, split long documents by paragraphs
- Customization of BERTopic parameters
- Exploration of topics by source, generate topic summaries using specific sources
- Generate and customize newsletters by applying LLMs on BERTopic's output topics
- Visualize and explore topics via different types of interactive figures (topics treemap, data maps)
- Explore the evolution of topics in a temporal semantic space
- Explore the stability of topics measured by TEMPTopic
- bertrend/demos/weak_signals: Identifies and analyzes emerging trends and signals
BERTrend_compressed.mp4
- Exploration of signals in real time at any given timestamp
- Categorization of signals into three different dataframes: noise, weak and strong signals (each dataframe contains useful information about the signals)
- Interpretation of these signals using LLMs
- Inspection of the topic merging process using Sankey diagram
- bertrend/bertrend_apps/prospective_demo: A comprehensive "Prospective Analysis Demo" application for monitoring, analysis, and trend detection in real time (works with live data).
(Coming soon)
- Data flow configuration and collection status monitoring
- Model status and monitoring by information source
- Real-time signal analysis and trend exploration
- Detailed topic analysis and interpretation
- Automated report and newsletter generation
- Comparative analysis between different periods
BERTrend now supports configuration via a repository-level .env file. On import, the package attempts to load
environment variables automatically using python-dotenv.
Recommended steps:
- Create and fill your
.envat the repo root (a template is provided):- Copy
.envand set your values (do not commit secrets). - Common keys:
BERTREND_BASE_DIR: base directory for BERTrend data/models/logs- OpenAI/LLM:
OPENAI_API_KEYOPENAI_BASE_URL(optional for OpenAI-compatible providers such as LiteLLM and Azure)OPENAI_DEFAULT_MODEL
- Providers (optional):
SEMANTIC_SCHOLAR_API_KEY,NEWSCATCHER_API_KEY,DBPEDIA_REST_API_URL - Embedding service security (optional):
BERTREND_SECRET_KEY,DEFAULT_RATE_LIMIT,DEFAULT_RATE_WINDOW,CLIENT_REGISTRY_FILE - Email (optional):
BERTREND_EMAIL_BACKEND,GMAIL_*,SMTP_*,SENDGRID_API_KEY - Misc:
CUDA_VISIBLE_DEVICES
- Copy
- Use a virtual environment and install dependencies inside it:
uv venv --python 3.13 source .venv/bin/activate # Windows: .venv\\Scripts\\activate uv pip install . uv pip install python-dotenv # ensures .env is auto-loaded
- Notes
- If
python-dotenvisn’t installed,.envwon’t be auto-loaded; you can either install it or export variables via your shell/runner. - Scheduled jobs created from the apps use the exact interpreter of your active environment (
sys.executable), ensuring.venv/bin/pythonis used. Keep your venv path stable on the machine running cron. - Cron entries source your shell profile and pass through any required variables. You can also rely on
.envfor most settings.
- If
- Recommended: at least one GPU with 16GB RAM for faster processing
- Python >= 3.13 is required
BERTrend can be run using Docker, which provides an easy way to run the application without installing dependencies directly on your system.
For detailed instructions on using BERTrend with Docker, see the Docker documentation.
-
(Recommended): create a new python environment using
uv:uv venv --python 3.13 -
Installation from pypi
uv pip install bertrend -
Install using pip or poetry in the BERTrend home directory:
# Basic installation with core dependencies uv pip install .
-
(Use
uv pip install -e .for a local installation)
NB. Due to the number of dependencies, the installation may take some time on an empty environment.
BERTrend's dependencies are organized into logical groups for easier management:
- Core dependencies: Essential packages for topic modeling and analysis
- NLP and text processing: Libraries for natural language processing tasks
- LLM integration: Components for working with large language models
- Visualization and UI: Tools for data visualization and user interfaces
- Utilities: General utility libraries
This organization simplifies installation and maintenance, allowing users to install only the dependencies they need for their specific use case.
To verify that your installation is working correctly, you can run the installation verification script:
python -m bertrend.tests.test_installationThis script will check that all dependencies are installed correctly and provide a summary of the installation status. If any dependencies are missing, the script will provide instructions on how to install them.
BERTrend can work with various text datasets such as:
- Scientific publications
- News articles
- Social media publications
Recommended public datasets:
- New York Times dataset: https://www.kaggle.com/datasets/aryansingh0909/nyt-articles-21m-2000-present
- Arxiv dataset: https://www.kaggle.com/datasets/Cornell-University/arxiv
For custom dataset creation, please refer to the documentation page about data providers.
For email configuration and newsletter sending (optional), please refer to the mail configuration guide.
In order to use the provided demos, datasets :
- can be stored on the server in:
$BERTREND_BASE_DIR/data/bertrend/ - or can be uploaded from the client device on which are displayed the Streamlit apps.
Required columns:
texttimestamp
Supported formats:
- csv
- xlsx
- parquet
- json/jsonl
cd bertrend/demos/topic_analysis
CUDA_VISIBLE_DEVICES=<gpu_number> streamlit run app.pyParameters: Include all BERTopic parameters. Choose the embedding model carefully based on your data language. The embedding model can run locally (a GPU is recommended); it is also possible to use a remote embedding service.
We recommend using a remote embedding service (this is now the default config) as it simplifies the computing.
The change of configuration can be done in: services_default_config.toml.
An example of a very simple implementation to deploy a separate embedding service can be found here:
bertrend/services/embedding_server
Please refer to the BERTopic documentation for parameter details.
The application is split into several pages:
Data loading & model training: Allows to- Select a dataset
- Select the range of timestamps
- Split paragraphs if needed
- Train a topic model
-
Topic exploration -
Topic visualization: Several visualization types available:Overall Results: Standard information such as inter-topic distance mapTopics Treemap: Block view of topics and their relative importanceData Map: Easy topic and data search interface
-
Temporal Visualization: Focus on dynamic topic modeling:- 3D visualization of temporal topic evolution
- Metrics to assess topic stability over time
- Overall topic stability, temporal topic stability, and temporal representation stability
-
Generate Newsletters- This is an example of an application combining topic analysis and LLMs
- Generates newsletters based on prominent topics
- Uses LLMs to generate topic descriptions and summarize representative documents
Weak signals refer to early, small indicators of larger, important trends (like disruptive technologies or public health issues).
Identifying weak signals early is critical for decision-making across domains such as politics, healthcare, and innovation
Key Features of the demonstrator:
- Dynamic Topic Modeling in an online learning setting
- Popularity-based Signal Classification
- based on their popularity trends: noise, weak signals, and strong signals
- new popularity metric considers both the number of documents within a topic and the frequency of updates
cd bertrend/demos/weak_signals
CUDA_VISIBLE_DEVICES=<gpu_number> streamlit run app.py- Select the
Model Trainingtab - Choose time granularity (in days)
- Click
Train Modelsto generate topic models per time slice - Click
Merge Modelsfor the aggregated model
Provides various statistics about topics:
- Number of topics detected
- Topic size evolution
- Topic popularity evolution
- Overall popularity evolution
- Lists of noise, weak, and strong signals
- As topics are hard to interprete by humans, we showcase how it can be done using LLMs.
- Choose a specific topic and click on the button to generate an interpretation
- LLM-based in-depth signal analysis is done using predefined templates, for example:
- describe what's happened since the last timestamp (summary of main events)
- present through a multi-faceted description info about key developments, foreseen changes, potential impact, etc.
For service setup and API details, see:
docs/services/article_scoring_service.md.
Please use the 'Issues' section to report and discuss any problems with BERTrend.
We welcome contributions. For major changes, please open an issue first to discuss your proposal.
To contribute:
- Fork the repository at https://github.com/rte-france/BERTrend
- Sync your fork with the latest development branch
- Implement your changes
- Add tests and documentation if applicable
- Sync with the latest development branch again
- Submit a pull request targeting the appropriate branch
See AUTHORS for the full list of contributors.
Copyright 2023–2025 RTE France RTE: http://www.rte-france.com
This Source Code is subject to the terms of the Mozilla Public License (MPL) v2 also available here: https://www.mozilla.org/en-US/MPL/2.0/
If you use BERTrend in your work, please cite:
@inproceedings{boutaleb-etal-2024-bertrend,
title = "{BERT}rend: Neural Topic Modeling for Emerging Trends Detection",
author = "Boutaleb, Allaa and
Picault, Jerome and
Grosjean, Guillaume",
editor = "Tetreault, Joel and
Nguyen, Thien Huu and
Lamba, Hemank and
Hughes, Amanda",
booktitle = "Proceedings of the Workshop on the Future of Event Detection (FuturED)",
month = nov,
year = "2024",
address = "Miami, Florida, USA",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.futured-1.1",
pages = "1--17",
}









