Skip to content

Add DNABERT-2 promoter finetuning tutorial notebook#5

Open
Gonza10V wants to merge 1 commit into
refactoredfrom
codex/create-example-notebook-for-dnabert2-finetuning
Open

Add DNABERT-2 promoter finetuning tutorial notebook#5
Gonza10V wants to merge 1 commit into
refactoredfrom
codex/create-example-notebook-for-dnabert2-finetuning

Conversation

@Gonza10V
Copy link
Copy Markdown
Owner

Motivation

  • Provide an end-to-end example showing how to finetune DNABERT-2 for binary promoter classification using Hugging Face Transformers and the Trainer API.
  • Make it easy to reproduce and try locally by including dependency hints and a synthetic fallback dataset when a local CSV is not available.

Description

  • Add a new tutorial notebook at notebooks/tutorials/06_dnabert2_promoter_finetuning.ipynb containing setup, data loading, preprocessing, tokenization, training, evaluation, and inference sections.
  • Include a dependency-install cell and reproducibility seed plus model configuration targeting zhihan1996/DNABERT-2-117M with trust_remote_code=True for tokenizer and model loading.
  • Implement robust data handling with required-column validation, sequence sanitization ([^ACGTN] -> N), a DatasetDict train/validation/test split, and a DataCollatorWithPadding-based data pipeline.
  • Add compute_metrics (accuracy, F1, precision, recall), TrainingArguments tuned for finetuning, a Trainer instantiation, and example inference code for new sequences.

Testing

  • Validated the notebook JSON structure with python -m json.tool notebooks/tutorials/06_dnabert2_promoter_finetuning.ipynb, which completed successfully.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d3b648021d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

" temp_df,\n",
" test_size=0.5,\n",
" random_state=42,\n",
" stratify=temp_df[\"label\"] if temp_df[\"label\"].nunique() > 1 else None,\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.

P1 Badge Guard second split from invalid stratification

This split can raise a ValueError when temp_df has only one sample per class (which happens with the notebook’s built-in 6-row fallback dataset after the first 70/30 split), because train_test_split(..., stratify=...) requires at least 2 members per class. In that case the tutorial stops before training, so users without data/data_DNABERT/promoter_classification.csv cannot run the notebook end-to-end.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant