Skip to content

Update community notebooks to rapidfireai 0.16.1 (run-validated) - #289

Open
kamran-rapidfireAI wants to merge 20 commits into
mainfrom
fix/community-notebooks-rapidfireai-0.16.1
Open

Update community notebooks to rapidfireai 0.16.1 (run-validated)#289
kamran-rapidfireAI wants to merge 20 commits into
mainfrom
fix/community-notebooks-rapidfireai-0.16.1

Conversation

@kamran-rapidfireAI

@kamran-rapidfireAI kamran-rapidfireAI commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Changes

  • Updates all 8 community notebooks from rapidfireai==0.14.0 to rapidfireai==0.16.1 and fixes issues found while executing the notebooks end-to-end.
  • Keeps the change notebook-only: no library/runtime code is touched.
  • Adds outcome-aware SFT notebook waits after Colab background run_fit() execution so failed or incomplete training runs raise before downstream metric cells continue.

Changelog Content

Additions

  • community_notebooks: add a UCSB course-catalog dataset download cell because those files are not shipped by rapidfireai init.
  • community_notebooks: add a RapidFire services startup cell for rag-fiqa-context-optimization, required by the MLflow AI Gateway generator path.
  • community_notebooks: install FlagEmbedding in the QASPER setup cell because phase 2b imports it inside Ray actors.

Changes

  • community_notebooks: pin all 8 notebooks to rapidfireai==0.16.1.
  • community_notebooks: migrate the RAG notebooks to the 0.16 RFLangChainRagSpec cfg-dict API and switch FiQA generation to RFAPIModelConfig.
  • community_notebooks: pin transformers>=4.55.2,<5.0.0 in SFT installs to avoid Colab's transformers 5.x incompatibility with trl==0.21.0.
  • community_notebooks: wait for Colab background run_fit() completion in SFT notebooks, then validate experiment.get_runs_info() so only all-Completed runs are treated as successful.
  • community_notebooks: update TensorBoard log paths to tensorboard_logs/<experiment>/<run>.
  • community_notebooks: flatten nested 0.16 *_cfg knobs in RAG result analysis.

Fixes

  • community_notebooks: deduplicate chunk-level hits before NDCG in FiQA so duplicate chunks cannot inflate DCG above IDCG.
  • community_notebooks: remove FiQA's manual ray.init(num_cpus=2) restart, which can starve the 0.16 evals engine.
  • community_notebooks: use 2 shards for FiQA's 6-query demo evaluation.
  • community_notebooks: use a sqlite MLflow store for FiQA demo metrics instead of the retired filesystem backend path.
  • community_notebooks: fix PII "Run all" plot ordering and normalize its batch polling status names.
  • community_notebooks: make QASPER phase 2b summary, plot, and heatmap cells tolerate metrics that the phase does not persist.
  • community_notebooks: strip stale execution counts from NFCorpus.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this change manually
  • I have tested this change in the following environments:
    • Local development
    • Docker environment
    • Other: headless end-to-end execution of all 8 notebooks on GCP GPU VMs, plus lightweight local PR-review validation

Test methodology

Every notebook in this PR was executed top to bottom with papermill in a fresh Python 3.12 venv on GCP L4 GPU VMs configured to mirror Colab. The notebooks executed their own %pip install cells, /content and RapidFire state were wiped between runs, and failures were fixed forward until each notebook passed.

Validation for the latest review fix:

  • Notebook JSON/output state checked for all edited SFT notebooks.
  • Modified training cells parsed successfully.
  • Synthetic completed, failed, empty, and unfinished run-status cases passed.
  • git diff --check passed.
  • Cursor Bugbot passed on commit bfa6482c9cd69233e294ecc696f71973383b7564.
  • Actual Colab Enterprise T4 validation passed through the previously failing Experiment(...) initialization path on commit aabd819 (execution 5828237635323166720).

Per-notebook results:

Notebook Result Wall time Evidence
sft-ecommerce-retail-chatbot pass ~7 min 8 runs, eval_loss 2.0-2.6, metrics table, plots, artifact zip
sft-cybersecurity-qa pass ~25 min 4 runs plus baseline, 40 eval checkpoints, checkpoint eval table
sft-child-facing-chatbot pass ~2h20m 4 runs, BERTScore per checkpoint, 36 chunk-tasks
sft-pii-masking-redaction pass ~1h20m 8 gpt2 configs, plots, TensorBoard scalar summary
rag-nfcorpus-biomedical-qa pass ~30 min 4 configs, Precision 0.50-0.55, NDCG@5 0.29-0.31, MRR 0.55-0.65
rag-ucsb-course-catalog pass ~30 min 4 configs including new dataset download cell
rag-fiqa-context-optimization pass ~25 min 3 configs via gpt-4o-mini through MLflow AI Gateway, Precision up to 0.75, NDCG@5 0.68
rag-qasper-scientific-paper-qa pass ~5.5h cumulative 12 chunking, 5 embedding, and 3 hybrid configs validated via notebook CSV resume logic

Validation used an uncommitted google.colab shim for Colab-only affordances. OPENAI_API_KEY came from the environment and is not committed.

Screenshots (if applicable)

N/A - notebook-only changes; executed outputs are intentionally stripped per repo convention.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Performance Impact

None. This PR is notebook-only. The training-completion assertion only runs after notebook training waits finish and does not affect RapidFire library runtime behavior.

Related Issues

Related to #285, #286, #208


Note

Low Risk
Changes are confined to tutorial notebooks and documentation-style cells; they do not alter production library behavior or authentication/data paths in the repo.

Overview
Notebook-only refresh of all eight community_notebooks from rapidfireai 0.14.0 → 0.16.1, aligned with end-to-end Colab/GPU runs. No library or runtime code changes.

RAG notebooks move RFLangChainRagSpec to the 0.16 *_cfg dict API (embedding_cfg, vector_store_cfg, search_cfg, reranker_cfg). FiQA switches generation from RFOpenAIAPIModelConfig to RFAPIModelConfig with MLflow AI Gateway endpoint_config, adds MLflow/RapidFire service env vars, a services startup cell (ports 8851ΓÇô8853), dedupes document IDs in NDCG@k, drops manual ray.init(num_cpus=2), uses 2 shards for the small query set, and logs demo metrics to sqlite instead of filesystem mlruns. QASPER loads QASPER via parquet (datasets 3.x), adds FlagEmbedding, and makes phase 2b plots/heatmaps tolerate partial metric columns. NFCorpus/UCSB flatten nested *_cfg for plots/tables; UCSB adds dataset download, stricter install/init, optional Drive, Ray stop before evals, and Colab Enterprise iframe/save guards.

SFT notebooks pin transformers>=4.55.2,<5.0.0, wait on Colab background run_fit(), and _assert_training_completed via get_runs_info() so failed or incomplete runs error before metrics. TensorBoard paths move to tensorboard_logs/<experiment>/ (ecommerce artifact bundling updated). PII masking fixes batch polling statuses and best-config selection before eval-loss plots.

Reviewed by Cursor Bugbot for commit aabd819. Bugbot is set up for automated code reviews on this repo. Configure here.

kamran-rapidfireAI and others added 18 commits July 1, 2026 23:06
All 8 community notebooks pinned rapidfireai==0.14.0 (sft-ecommerce was
unpinned) while the latest stable release is 0.16.1, which the tutorial
notebooks already use. Pin all 8 to 0.16.1.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
rag-ucsb-course-catalog.ipynb loads queries.jsonl/qrels.tsv/corpus.jsonl
from tutorial_notebooks/rag-contexteng/datasets/ucsb_catalog/, but that
dataset is not shipped by 'rapidfireai init' and the notebook had no
download step, so it could never run from a fresh Colab. Fetch the three
files from the original competition author's repo
(nirscripts/RapidFire-AI-LLM-Experimentation) where they are hosted.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Four cells had non-null execution_count values left over from a past
run; community notebooks are committed with cleared execution state.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
rapidfireai 0.16.1 pins datasets==3.6.0, which no longer supports
script-based datasets, so load_dataset("allenai/qasper",
trust_remote_code=True) fails (and the notebook's datasets==2.21.0 pin
was overridden by the rapidfireai install anyway). Load the Hub's
auto-converted parquet branch instead and drop the conflicting pin.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…Config APIs

rapidfireai 0.15/0.16 replaced RFLangChainRagSpec's embedding_cls/
embedding_kwargs, vector_store, search_type/search_kwargs, and
reranker_cls/reranker_kwargs constructor args with embedding_cfg,
vector_store_cfg, search_cfg, and reranker_cfg dicts, and replaced
RFOpenAIAPIModelConfig with the gateway-based RFAPIModelConfig. All four
RAG community notebooks used the removed 0.14 APIs and failed at import
or construction time. Migrate them to the new style, mirroring the
already-updated tutorial notebooks; fiqa additionally gains a services
startup cell since RFAPIModelConfig provisions endpoints through the
MLflow AI Gateway.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
rapidfireai 0.16.1 pins trl==0.21.0 but leaves transformers unbounded
(>=4.55.2) on the fit path, and Colab now preinstalls transformers
5.12.1, which removed MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES; importing
trl.trainer then fails on every SFT notebook. Bound transformers to
<5.0.0 in the install cells (the evals path already carries this bound
via setup/evals/requirements-colab.txt, so the RAG notebooks are
unaffected).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Since the tensorboard-runs consolidation (#149), per-experiment event
files live at rapidfire_experiments/tensorboard_logs/<experiment>/<run>
instead of rapidfire_experiments/<experiment>/tensorboard_logs. The
ecommerce and PII notebooks still probed the old location, so their
post-training cells asserted 'No TensorBoard logs found' even after a
successful run_fit. Also exclude the shared tensorboard_logs dir from
the ecommerce artifact bundler's newest-experiment picker.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
On Colab, rapidfireai 0.15+ runs the fit Controller in a daemon
background thread and returns from run_fit() immediately to keep the
kernel responsive. The SFT notebooks assume the old blocking behavior,
so with 'Run all' every post-training cell (TensorBoard checks, metric
extraction, artifact bundling) races ahead of training, and the kernel
shutdown at notebook end kills the half-finished runs. Poll until the
background thread completes (a no-op in blocking/non-Colab mode). Also
fix the PII notebook's existing batch polling loop, which compared
against status names that don't exist (RUNNING/QUEUED/STARTING vs
New/Ongoing) and therefore never waited.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The eval-loss and token-accuracy plot cells reference best_config_name,
but it was only assigned in later summary cells, so 'Run all' fails with
a NameError. Derive it from all_metrics (lowest final eval loss) where
the plots need it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
run_evals' metrics dict now reports pipeline knobs as nested cfg dicts
(text_splitter_cfg, search_cfg, reranker_cfg) instead of flat
chunk_size/rag_k/top_n columns, so the nfcorpus and ucsb analysis cells
failed with KeyError after a successful evaluation. Derive the flat
columns from the cfg dicts before selecting them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The notebook restarted Ray with num_cpus=2 before run_evals (a 0.14-era
workaround to keep the OpenAI path off the GPU). rapidfireai 0.16
manages the Ray runtime itself and its evals engine needs more actor
slots than that budget allows: the two DocProcessingActors consume both
CPUs and every downstream actor pends forever, hanging run_evals.
Replace the restart with a status printout and let run_evals initialize
Ray with auto-detected resources.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
With num_shards=4 the 6-query sample produces size-1 shards, and the
online confidence-interval estimator's variance goes negative on them,
raising 'ValueError: math domain error' inside run_evals. Two shards of
three queries match the shard sizes the other RAG notebooks run with.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Chunk-level retrieval returns the same corpus_id several times, and the
ordered-list NDCG from #286 then counts a relevant document once per
chunk, letting DCG exceed IDCG (observed NDCG@5 = 1.05 on the demo
sample). The out-of-range value made rapidfireai's online CI estimator
raise 'math domain error' inside run_evals. Count each document once at
its best rank. The same latent inflation exists in the other RAG
notebooks' NDCG helpers, though their aggregate values stayed below 1
during validation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MLflow 3.x puts the filesystem tracking backend in maintenance mode and
set_tracking_uri('file:./mlruns') now raises MlflowException. Point the
demo-metrics cell at sqlite:///mlflow_demo.db and zip that file instead
of the mlruns directory.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Phase 2b's hybrid retrieval loads BGEM3FlagModel from FlagEmbedding
inside the Ray query actors, but the notebook never installed the
package, so every phase 2b config failed with ModuleNotFoundError and
the downstream analysis crashed on the missing result CSVs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The phase 2b loop persists just config and MRR per hybrid configuration,
but the final summary cell also selected Recall@10 and NDCG@10, raising
KeyError after all phases completed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Same mismatch as the summary cell: the plot assumed Recall@10/NDCG@10
columns that the phase 2b loop never persists. Chart whichever of the
metrics are present.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The cross-phase heatmap hard-indexed Recall@10/NDCG@10 on phase 2/2b
rows that only persist MRR. Use row.get() and drop all-missing columns
before plotting.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kamran-rapidfireAI
kamran-rapidfireAI marked this pull request as ready for review July 3, 2026 02:24
Comment thread community_notebooks/sft-ecommerce-retail-chatbot.ipynb
Co-authored-by: Cursor <cursoragent@cursor.com>

@david-rfai david-rfai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First notebook I tested rag-ucsb-course-catalog.ipynb failed on actual Colab. Some of these need to be actually tested on Colab as there is no way to directly replicate on a VM. Also, why were L4s used when Colab uses T4s?

Second notebook I tested also failed, sft-ecommerce-retail-chatbot.ipynb as it has the install process collapsed.

All notebooks should be using the pinned release that does not use transformers 5.0 so should not be needing: transformers>=4.55.2,<5.0.0

Image

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aabd819. Configure here.

" print(\"✅ rapidfireai already installed\")\n",
"except ImportError:\n",
" %pip install rapidfireai==0.14.0\n",
" %pip install rapidfireai==0.16.1 \"transformers>=4.55.2,<5.0.0\"\n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale rapidfireai skips upgrade

Medium Severity

Several notebooks only install rapidfireai==0.16.1 when the package is missing. If an older release (for example 0.14.0) is already importable, the install cell is skipped while later cells use the 0.16 *_cfg APIs and training-completion checks, which can fail at runtime on reused Colab or local environments.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit aabd819. Configure here.

"\n",
"if importlib.util.find_spec(\"rapidfireai\") is None:\n",
" pip_install([\"rapidfireai\"])\n",
" pip_install([\"rapidfireai==0.16.1\", \"transformers>=4.55.2,<5.0.0\"])\n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transformers pin not enforced

Medium Severity

The transformers>=4.55.2,<5.0.0 constraint is bundled with the rapidfireai install path only. When rapidfireai is already present (typical on Colab), transformers 5.x can remain installed and break trl==0.21.0 during training even though the PR intends to avoid that combination.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit aabd819. Configure here.

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.

2 participants