transformers-bio-nlp
HuggingFace Transformers with biomedical LMs (BioBERT, PubMedBERT, BioGPT, BioMedLM) for scientific NLP: NER (genes, diseases, chemicals), relation extraction, QA, text classification, abstract summarization. Covers loading, biomedical tokenization, inference pipelines, fine-tuning. Alternatives: spaCy en_core_sci_lg (rule-based NER), Stanza (biomedical models), NLTK.
npx skills add BioTender-max/awesome-bio-agent-skills --skill transformers-bio-nlp --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Guides the agent to perform biomedical NLP tasks using HuggingFace Transformers with models like BioBERT, PubMedBERT, BioGPT, and BioMedLM. It covers NER, relation extraction, QA, text classification, text generation, and sentence embeddings, including loading models, tokenization specifics, and fine-tuning on task data.
How it works
- Utilizes the pipeline() abstraction to run tasks such as NER, text classification, and QA, often with aggregation_strategy to merge subword tokens into words.
- Demonstrates manual tokenization plus inference for batch processing using AutoTokenizer and AutoModelForTokenClassification, and showcases specific model suggestions per task.
- Provides code samples for:
- NER with pre-trained biomedical models (e.g., d4data/biomedical-ner-all) and handling subword tokens via aggregation_strategy.
- Text classification including zero-shot classification with facebook/bart-large-mnli and fine-tuned PubMedBERT-based classifiers.
- Biomedical QA using a QA pipeline with a biomedical model (e.g., sultan/BioM-ELECTRA-Large-SQuAD2).
- BioGPT-based text generation from a biomedical prompt.
- Sentence embeddings using PubMedBERT-derived models for semantic search, with mean pooling and cosine similarity.
- Fine-tuning on custom NER data using a BiomedBERT variant, including setup for TrainingArguments and a Trainer, with placeholders for trainer invocation.
- Explains common tokenization issues in biomedical text and BIO labeling, including handling subwords during evaluation and fine-tuning.
When to use it
- For extracting biomedical entities (genes, diseases, chemicals) from abstracts; for classification of abstracts by topic or outcomes; for extractive QA over biomedical passages; for generation of hypotheses or summaries; and for embedding sentences for search.
- Recommends using domain-specific models over general BERT, and to verify licenses for models like BioGPT or BioMedLM.
- Advises using aggregation_strategy="simple" for word-level NER output and to split long inputs at sentence boundaries for encoding.
What it can touch
- Includes commands and code snippets using:
pipeline,AutoTokenizer,AutoModelForTokenClassification,BioGptForCausalLM,AutoModel,AutoTokenizer,TrainingArguments,Trainer, andDataCollatorForTokenClassification. - References models and file-like interactions within Python scripts: e.g., model names such as "d4data/biomedical-ner-all", "allenai/scibert_scivocab_cased", "sultan/BioM-ELECTRA-Large-SQuAD2", "microsoft/biogpt", and "microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext".
- Demonstrates data handling for NER, QA, and embedding workflows, including tokenization, pooling, and similarity calculations.
Caveats
- license: NOASSERTION; license checks advised before production use.
- Some models have research-only licenses; verify model cards prior to deployment.
- The fine-tuning example includes placeholder trainer invocation (commented-out trainer.train()), indicating a need to instantiate and run Trainer with a proper dataset for actual use.
# Transformers for Biomedical NLP ## Overview HuggingFace Transformers provides a unified API to load, run, and fine-tune 500+ biomedical language models. The key biomedical models — BioBERT (trained on PubMed abstracts + PMC full text), PubMedBERT (trained from scratch on PubMed), BioGPT (generative, trained on PubMed), and BioMedLM — significantly outperform general-purpose BERT on biomedical NER, relation extraction, and question answering. The `pipeline()` abstraction handles tokenization, inference, and postprocessing in one call. Fine-tuning on task-specific labeled data (e.g., BC5CDR for chemical/disease NER) takes under an hour on a single GPU. The `datasets` library provides direct access to standard biomedical benchmarks. ## When to Use - Extracting gene names, disease mentions, drug names, or chemical entities from biomedical abstracts (NER) - Classifying abstracts by topic, sentiment of clinical outcomes, or PICO elements for systematic reviews - Answering specific questions from biomedical literature using extractive QA (BioASQ format) - Generating hypotheses or summaries from biomedical text using BioGPT or BioMedLM - Fine-tuning a pre-trained biomedical model on a cu
- Overview
- When to Use
- Prerequisites
- Quick Start
- Core API
- Module 1: Named Entity Recognition (NER)
- Module 2: Text Classification
- Module 3: Biomedical Question Answering
- Module 4: Text Generation with BioGPT
- Module 5: Sentence Embeddings for Semantic Search
- Module 6: Fine-Tuning on Custom Data
- Key Concepts
- Tokenization of Biomedical Text
- BIO Labeling Scheme
pip install transformers torch datasets accelerate sentencepiece For GPU (CUDA 11.8) pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
What does the transformers-bio-nlp skill do?
HuggingFace Transformers with biomedical LMs (BioBERT, PubMedBERT, BioGPT, BioMedLM) for scientific NLP: NER (genes, diseases, chemicals), relation extraction, QA, text classification, abstract summarization. Covers loading, biomedical tokenization, inference pipelines, fine-tuning. Alternatives: spaCy en_core_sci_lg (rule-based NER), Stanza (biomedical models), NLTK.
How do I install it?
Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill transformers-bio-nlp --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From BioTender-max/awesome-bio-agent-skills, a repository with 135 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
