Skip to content

Add examples for all HuggingFace models (#2102)#2247

Merged
AlexCatarino merged 6 commits intoQuantConnect:masterfrom
AlexCatarino:bug-2102-add-huggingface-examples
Mar 18, 2026
Merged

Add examples for all HuggingFace models (#2102)#2247
AlexCatarino merged 6 commits intoQuantConnect:masterfrom
AlexCatarino:bug-2102-add-huggingface-examples

Conversation

@AlexCatarino
Copy link
Member

@AlexCatarino AlexCatarino commented Mar 17, 2026

Summary

  • Add examples for Sentiment Analysis (06), Fill-Mask (07), Text Generation (08), and Chronos-Bolt (12) HuggingFace model categories
  • All 4 new example algorithms passed cloud backtesting
  • Add example links in Resources/machine-learning/hugging-face-table.html for the newly covered models
  • Remove Moirai, MOMENT, and Granite TTM sections — they require uni2ts, momentfm, and tsfm_public packages that are not available in QC Cloud (tracked in [Library Upgrade] uni2ts, momentfm, tsfm_public (Moirai, MOMENT, Granite TTM) Lean#9340)

Note: This PR does not resolve #2102. The remaining models (Moirai, MOMENT, Granite TTM) depend on QuantConnect/Lean#9340 to add their required packages to QC Cloud. Examples for those models will be added in a follow-up PR once the packages are available.

Model Backtest Results

Each example supports multiple interchangeable models. Results below use the same algorithm with different models swapped in. Period: Sep 1 – Dec 31, 2024.

skip-test marks examples whose placeholder model backtest exceeded 5 minutes on QC Cloud.

Sentiment Analysis (skip-test — placeholder >5 min)

Model Net Profit Drawdown Sharpe Ratio
mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis 8.187% 29.000% 0.591
ahmedrachid/FinancialBERT-Sentiment-Analysis 29.430% 29.000% 1.586
AventIQ-AI/sentiment-analysis-for-stock-market-sentiment -9.417% 16.700% -1.296
bardsai/finance-sentiment-fr-base 29.430% 29.000% 1.586
cardiffnlp/twitter-roberta-base-sentiment-latest 29.430% 29.000% 1.586
nickmuchi/deberta-v3-base-finetuned-finance-text-classification N/A — model not pre-cached in QC Cloud
nickmuchi/distilroberta-finetuned-financial-text-classification -9.417% 16.700% -1.296
nickmuchi/sec-bert-finetuned-finance-classification -9.417% 16.700% -1.296
StephanAkkerman/FinTwitBERT-sentiment -9.417% 16.700% -1.296

Fill-Mask (testable — placeholder 228s)

Model Net Profit Drawdown Sharpe Ratio
distilbert/distilbert-base-uncased 29.430% 29.000% 1.586
FacebookAI/roberta-base -9.417% 16.700% -1.296
google-bert/bert-base-uncased -9.417% 16.700% -1.296
microsoft/deberta-base -31.280% 31.600% -1.296

Text Generation (testable — placeholder 178s)

Model Net Profit Drawdown Sharpe Ratio
openai-community/gpt2 19.558% 9.900% 1.952
google/gemma-7b N/A — timeout (7B model exceeds QC Cloud time limit)
deepseek-ai/DeepSeek-R1-Distill-Llama-70B N/A — model not pre-cached in QC Cloud

Chronos-Bolt (testable — 38s)

Model Net Profit Drawdown Sharpe Ratio
autogluon/chronos-bolt-base 7.246% 6.100% 0.686

⭐ = example placeholder model

Test plan

  • Sentiment Analysis example backtested on QC Cloud — PASS (marked skip-test, placeholder >5 min)
  • Fill-Mask example backtested on QC Cloud — PASS (testable, 228s)
  • Text Generation example backtested on QC Cloud — PASS (testable, 178s)
  • Chronos-Bolt example backtested on QC Cloud — PASS (testable, 38s)
  • Verify the pages render correctly on quantconnect.com/docs
  • Check all links resolve

AlexCatarino and others added 2 commits March 17, 2026 19:31
Add documentation sections with algorithm examples for all HuggingFace
models in the popular models table that were missing examples:

- Sentiment Analysis: covers 8 text classification models
- Fill-Mask: covers BERT, DistilBERT, RoBERTa, DeBERTa
- Text Generation: covers GPT-2, Gemma, DeepSeek
- Moirai: time series forecasting (small/base/large)
- MOMENT: time series foundation model
- Granite TTM: IBM lightweight time series forecasting
- Chronos-Bolt: efficient Chronos variant

Update the model table to link every model to its example page.
Fix AventIQ-AI model category from Time Series Forecasting to
Text Classification.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ntConnect#2102)

- Change all example blocks from skip-test to testable
- Fix Chronos-Bolt to use predict() instead of predict_quantiles()
  to match the same pattern as Chronos-T5
- Rewrite Moirai, MOMENT, and Granite TTM examples to use their
  correct package APIs (uni2ts, momentfm, tsfm_public)

Sentiment Analysis, Fill-Mask, Text Generation, and Chronos-Bolt
examples pass cloud backtesting. Moirai, MOMENT, and Granite TTM
require uni2ts, momentfm, and tsfm_public packages respectively,
which need to be pre-installed in the cloud environment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AlexCatarino and others added 4 commits March 17, 2026 22:12
… entry (QuantConnect#2102)

- Delete 09 Moirai, 10 MOMENT, 11 Granite TTM sections (require uni2ts/momentfm/tsfm_public,
  not available in QC Cloud; tracked in QuantConnect/Lean#9340)
- Fix 00.json: correct Chronos-Bolt folder key from "09" to "12"
- Remove example links for Moirai, MOMENT, Granite TTM rows in hugging-face-table.html

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ct#2102)

Add EXAMPLES entries for sentiment-analysis, fill-mask, text-generation,
and chronos-bolt pages; regenerate the HTML table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…onnect#2102)

The mrm8488/distilroberta placeholder model takes >10 minutes to backtest
on QC Cloud due to model size and repeated inference over 4 months of data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gic (QuantConnect#2102)

- Increase BACKTEST_TIMEOUT to 1800s to handle large models
- Add REUSE_PROJECT_ID to avoid daily project creation limit
- Auto-mark example as skip-test when placeholder backtest exceeds 5 min
- Add SKIP_CATEGORIES to resume partial runs
- Add traceback output for better error diagnosis

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AlexCatarino AlexCatarino merged commit f7b9a28 into QuantConnect:master Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Examples to All HuggingFace Models

1 participant