[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73K2V1J8MRZF044B74VENQE":3,"skill-same:01M73K2V1J8MRZF044B74VENQE":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M73K2V1J8MRZF044B74VENQE","transformers-bio-nlp",null,"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.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Ftransformers-bio-nlp\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: \"transformers-bio-nlp\"\ndescription: \"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.\"\nlicense: \"Apache-2.0\"\n---\n\n# Transformers for Biomedical NLP\n\n## Overview\n\nHuggingFace 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\u002Fdisease NER) takes under an hour on a single GPU. The `datasets` library provides direct access to standard biomedical benchmarks.\n\n## When to Use\n\n- Extracting gene names, disease mentions, drug names, or chemical entities from biomedical abstracts (NER)\n- Classifying abstracts by topic, sentiment of clinical outcomes, or PICO elements for systematic reviews\n- Answering specific questions from biomedical literature using extractive QA (BioASQ format)\n- Generating hypotheses or summaries from biomedical text using BioGPT or BioMedLM\n- Fine-tuning a pre-trained biomedical model on a custom labeled dataset (e.g., your lab's annotations)\n- Embedding biomedical sentences for semantic similarity search across literature\n- Use spaCy + en_core_sci_lg for fast rule-augmented NER; use Stanza for dependency parsing\n\n## Prerequisites\n\n- **Python packages**: `transformers`, `torch`, `datasets`, `accelerate`, `sentencepiece`\n- **GPU**: Strongly recommended for fine-tuning; inference on CPU is viable for single texts\n- **Data requirements**: plain text biomedical strings; for fine-tuning, annotated data in BIO\u002FIOB format\n\n```bash\npip install transformers torch datasets accelerate sentencepiece\n# For GPU (CUDA 11.8)\npip install torch torchvision --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\n```\n\n## Quick Start\n\n```python\nfrom transformers import pipeline\n\n# Named entity recognition with BioBERT\nner = pipeline(\"ner\", model=\"allenai\u002Fscibert_scivocab_cased\",\n               aggregation_strategy=\"simple\")\n\ntext = \"BRCA1 mutations are associated with increased risk of breast cancer and ovarian cancer.\"\nentities = ner(text)\nfor ent in entities:\n    print(f\"  {ent['word']:20s} {ent['entity_group']:10s} score={ent['score']:.3f}\")\n```\n\n## Core API\n\n### Module 1: Named Entity Recognition (NER)\n\nExtract biomedical entities using pre-trained NER models.\n\n```python\nfrom transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification\n\n# BioBERT fine-tuned for NER (genes, diseases, chemicals)\n# Common choices:\n#   \"allenai\u002Fscibert_scivocab_cased\"  — scientific NER\n#   \"d4data\u002Fbiomedical-ner-all\"       — multi-entity biomedical NER\n#   \"pruas\u002FBENT-PubMedBERT-NER-Gene\"  — gene-specific NER\nner_pipe = pipeline(\n    \"ner\",\n    model=\"d4data\u002Fbiomedical-ner-all\",\n    aggregation_strategy=\"simple\",  # merge subword tokens into words\n    device=-1  # -1=CPU, 0=GPU\n)\n\nabstracts = [\n    \"Imatinib inhibits the BCR-ABL1 tyrosine kinase and is first-line treatment for CML.\",\n    \"EGFR mutations in non-small cell lung cancer predict response to erlotinib.\",\n]\n\nfor text in abstracts:\n    entities = ner_pipe(text)\n    print(f\"\\nText: {text[:60]}...\")\n    for e in entities:\n        print(f\"  [{e['entity_group']}] '{e['word']}' (score={e['score']:.2f})\")\n```\n\n```python\n# Manual tokenization + inference for batch processing\nfrom transformers import AutoTokenizer, AutoModelForTokenClassification\nimport torch\n\nmodel_name = \"allenai\u002Fscibert_scivocab_cased\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModelForTokenClassification.from_pretrained(model_name)\nmodel.eval()\n\ntext = \"Metformin activates AMPK and reduces hepatic glucose production in type 2 diabetes.\"\ninputs = tokenizer(text, return_tensors=\"pt\", truncation=True, max_length=512)\n\nwith torch.no_grad():\n    outputs = model(**inputs)\n\nlogits = outputs.logits  # shape: (1, seq_len, n_labels)\npredictions = logits.argmax(dim=-1)[0]\ntokens = tokenizer.convert_ids_to_tokens(inputs[\"input_ids\"][0])\nlabels = [model.config.id2label[p.item()] for p in predictions]\n\nfor token, label in zip(tokens[1:-1], labels[1:-1]):  # skip [CLS] and [SEP]\n    if label != \"O\":\n        print(f\"  {token:20s} {label}\")\n```\n\n### Module 2: Text Classification\n\nClassify biomedical abstracts or sentences.\n\n```python\nfrom transformers import pipeline\n\n# Zero-shot classification — no fine-tuning needed\nzs_clf = pipeline(\"zero-shot-classification\",\n                  model=\"facebook\u002Fbart-large-mnli\",\n                  device=-1)\n\nabstract = \"\"\"\nThis randomized controlled trial evaluated the efficacy of pembrolizumab versus\nchemotherapy in patients with advanced non-small-cell lung cancer. Overall survival\nwas significantly improved in the pembrolizumab arm (HR=0.60, 95% CI 0.41-0.89).\n\"\"\"\n\ncandidate_labels = [\"clinical trial\", \"basic research\", \"meta-analysis\", \"review\"]\nresult = zs_clf(abstract, candidate_labels)\nprint(\"Zero-shot classification:\")\nfor label, score in zip(result[\"labels\"], result[\"scores\"]):\n    print(f\"  {label:20s}: {score:.3f}\")\n```\n\n```python\n# Fine-tuned sentiment\u002Foutcome classification\nfrom transformers import pipeline\n\n# Example: classify clinical outcome sentiment\nclf = pipeline(\"text-classification\",\n               model=\"pruas\u002FBENT-PubMedBERT-NER-Gene\",  # use appropriate task-specific model\n               device=-1)\n\nsentences = [\n    \"Treatment significantly improved overall survival (p\u003C0.001).\",\n    \"No statistically significant difference was observed between groups.\",\n]\nresults = clf(sentences)\nfor sent, result in zip(sentences, results):\n    print(f\"  [{result['label']} | {result['score']:.2f}] {sent[:50]}...\")\n```\n\n### Module 3: Biomedical Question Answering\n\nExtract answers from biomedical text passages.\n\n```python\nfrom transformers import pipeline\n\n# Extractive QA: find answer span within context\nqa_pipe = pipeline(\n    \"question-answering\",\n    model=\"sultan\u002FBioM-ELECTRA-Large-SQuAD2\",  # biomedical QA model\n    device=-1\n)\n\ncontext = \"\"\"\nBRCA1 is a tumor suppressor gene located on chromosome 17q21. Pathogenic variants\nin BRCA1 confer a lifetime breast cancer risk of 50-72% and ovarian cancer risk\nof 44-46%. BRCA1 protein functions in DNA double-strand break repair via\nhomologous recombination.\n\"\"\"\n\nquestions = [\n    \"What chromosome is BRCA1 located on?\",\n    \"What is the lifetime breast cancer risk from BRCA1 variants?\",\n    \"What DNA repair pathway does BRCA1 participate in?\",\n]\n\nfor q in questions:\n    result = qa_pipe(question=q, context=context)\n    print(f\"Q: {q}\")\n    print(f\"A: {result['answer']} (score={result['score']:.3f})\\n\")\n```\n\n### Module 4: Text Generation with BioGPT\n\nGenerate biomedical text, hypotheses, and summaries.\n\n```python\nfrom transformers import AutoTokenizer, BioGptForCausalLM\nimport torch\n\nmodel_name = \"microsoft\u002Fbiogpt\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = BioGptForCausalLM.from_pretrained(model_name)\nmodel.eval()\n\nprompt = \"The role of VEGF in tumor angiogenesis\"\ninputs = tokenizer(prompt, return_tensors=\"pt\")\n\nwith torch.no_grad():\n    outputs = model.generate(\n        **inputs,\n        max_new_tokens=100,\n        num_beams=5,\n        early_stopping=True,\n        no_repeat_ngram_size=3,\n        pad_token_id=tokenizer.eos_token_id,\n    )\n\ngenerated = tokenizer.decode(outputs[0], skip_special_tokens=True)\nprint(f\"Generated:\\n{generated}\")\n```\n\n### Module 5: Sentence Embeddings for Semantic Search\n\nEmbed biomedical text for similarity search and clustering.\n\n```python\nfrom transformers import AutoTokenizer, AutoModel\nimport torch\nimport numpy as np\n\ndef mean_pooling(model_output, attention_mask):\n    \"\"\"Mean pooling across token embeddings.\"\"\"\n    token_embeddings = model_output.last_hidden_state\n    input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()\n    return (token_embeddings * input_mask_expanded).sum(1) \u002F input_mask_expanded.sum(1)\n\n# PubMedBERT for biomedical sentence embeddings\nmodel_name = \"microsoft\u002FBiomedNLP-BiomedBERT-base-uncased-abstract-fulltext\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModel.from_pretrained(model_name)\nmodel.eval()\n\nsentences = [\n    \"BRCA1 is involved in DNA double-strand break repair.\",\n    \"Homologous recombination requires BRCA1 and BRCA2.\",\n    \"Metformin inhibits hepatic gluconeogenesis via AMPK.\",\n]\n\ninputs = tokenizer(sentences, padding=True, truncation=True,\n                   max_length=512, return_tensors=\"pt\")\nwith torch.no_grad():\n    outputs = model(**inputs)\n\nembeddings = mean_pooling(outputs, inputs[\"attention_mask\"])\nembeddings = torch.nn.functional.normalize(embeddings, p=2, dim=1).numpy()\n\n# Compute cosine similarity\nfrom numpy.linalg import norm\nsim_01 = np.dot(embeddings[0], embeddings[1])\nsim_02 = np.dot(embeddings[0], embeddings[2])\nprint(f\"Similarity (BRCA1 repair vs. HR): {sim_01:.3f}\")\nprint(f\"Similarity (BRCA1 repair vs. Metformin): {sim_02:.3f}\")\n```\n\n### Module 6: Fine-Tuning on Custom Data\n\nFine-tune a biomedical model on a labeled NER dataset.\n\n```python\nfrom transformers import (AutoTokenizer, AutoModelForTokenClassification,\n                           TrainingArguments, Trainer, DataCollatorForTokenClassification)\nfrom datasets import Dataset\nimport numpy as np\n\n# Example: minimal NER fine-tuning setup\nmodel_name = \"microsoft\u002FBiomedNLP-BiomedBERT-base-uncased-abstract\"\nlabel_list = [\"O\", \"B-GENE\", \"I-GENE\", \"B-DISEASE\", \"I-DISEASE\"]\nid2label = {i: l for i, l in enumerate(label_list)}\nlabel2id = {l: i for i, l in enumerate(label_list)}\n\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModelForTokenClassification.from_pretrained(\n    model_name, num_labels=len(label_list), id2label=id2label, label2id=label2id\n)\n\n# Training arguments\ntraining_args = TrainingArguments(\n    output_dir=\".\u002Fbiomed_ner_finetuned\",\n    num_train_epochs=3,\n    per_device_train_batch_size=16,\n    per_device_eval_batch_size=32,\n    warmup_steps=100,\n    weight_decay=0.01,\n    logging_dir=\".\u002Flogs\",\n    evaluation_strategy=\"epoch\",\n    save_strategy=\"epoch\",\n    load_best_model_at_end=True,\n)\n\nprint(f\"Model ready for fine-tuning: {model_name}\")\nprint(f\"Labels: {label_list}\")\n# trainer = Trainer(model=model, args=training_args, ...)\n# trainer.train()\n```\n\n## Key Concepts\n\n### Tokenization of Biomedical Text\n\nBiomedical text contains special tokens (gene symbols, drug names, chemical SMILES, numeric values) that WordPiece and BPE tokenizers split unexpectedly. For example, \"BRCA1\" → `[\"BR\", \"##CA\", \"##1\"]`. This subword splitting does not affect classification tasks but does affect NER — use `aggregation_strategy=\"simple\"` or `\"first\"` in `pipeline()` to merge subword predictions back to word level.\n\n### BIO Labeling Scheme\n\nNER uses BIO (Begin-Inside-Outside) tagging: `B-GENE` marks the first token of a gene name, `I-GENE` marks continuation tokens, `O` marks non-entity tokens. During fine-tuning, align labels to subword tokens by setting non-first subword labels to `-100` (ignored by the loss function).\n\n## Common Workflows\n\n### Workflow 1: Batch Abstract NER and Entity Aggregation\n\n```python\nfrom transformers import pipeline\nimport pandas as pd\n\nner_pipe = pipeline(\"ner\", model=\"d4data\u002Fbiomedical-ner-all\",\n                    aggregation_strategy=\"simple\", device=-1)\n\nabstracts = [\n    \"Pembrolizumab combined with chemotherapy significantly improved progression-free survival in HER2-positive breast cancer.\",\n    \"Inhibition of EGFR by gefitinib is effective in patients with activating EGFR mutations in exons 19 and 21.\",\n    \"CRISPR-Cas9 editing of the PCSK9 gene in hepatocytes reduces LDL cholesterol in murine models.\",\n]\n\nrecords = []\nfor i, text in enumerate(abstracts):\n    entities = ner_pipe(text)\n    for e in entities:\n        records.append({\n            \"abstract_id\": i,\n            \"entity\": e[\"word\"],\n            \"type\": e[\"entity_group\"],\n            \"score\": round(e[\"score\"], 3),\n        })\n\ndf = pd.DataFrame(records)\nprint(df.groupby(\"type\")[\"entity\"].apply(list).to_string())\ndf.to_csv(\"extracted_entities.csv\", index=False)\nprint(f\"\\nExtracted {len(df)} entity mentions across {len(abstracts)} abstracts\")\n```\n\n### Workflow 2: Semantic Similarity Ranking for Literature Retrieval\n\n```python\nfrom transformers import AutoTokenizer, AutoModel\nimport torch\nimport numpy as np\n\nmodel_name = \"microsoft\u002FBiomedNLP-BiomedBERT-base-uncased-abstract-fulltext\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModel.from_pretrained(model_name)\nmodel.eval()\n\ndef embed(texts):\n    enc = tokenizer(texts, padding=True, truncation=True,\n                    max_length=512, return_tensors=\"pt\")\n    with torch.no_grad():\n        out = model(**enc)\n    vecs = out.last_hidden_state[:, 0, :]  # [CLS] token\n    return torch.nn.functional.normalize(vecs, dim=1).numpy()\n\nquery = \"CRISPR base editing for correction of point mutations in genetic disease\"\ncorpus = [\n    \"Base editing enables precise single-base changes in genomic DNA without double-strand breaks.\",\n    \"CAR-T cell therapy targets CD19 in B-cell acute lymphoblastic leukemia.\",\n    \"Prime editing uses reverse transcriptase to install targeted edits at specific loci.\",\n    \"RNA interference silences gene expression via RISC-mediated mRNA cleavage.\",\n]\n\nq_emb = embed([query])\nc_emb = embed(corpus)\nscores = (q_emb @ c_emb.T).flatten()\nranked = sorted(zip(scores, corpus), reverse=True)\n\nprint(\"Top results:\")\nfor score, text in ranked:\n    print(f\"  [{score:.3f}] {text[:70]}...\")\n```\n\n## Key Parameters\n\n| Parameter | Module\u002FFunction | Default | Range \u002F Options | Effect |\n|-----------|----------------|---------|-----------------|--------|\n| `model` | `pipeline()` | — | HuggingFace model ID string | Pre-trained model to load; must match task |\n| `aggregation_strategy` | NER `pipeline` | `\"none\"` | `\"none\"`, `\"simple\"`, `\"first\"`, `\"average\"` | Merge subword NER predictions; use `\"simple\"` for word-level output |\n| `device` | `pipeline()` | -1 | -1 (CPU), 0 (GPU 0), 1 (GPU 1) | Inference device |\n| `max_length` | tokenizer | 512 | 128–2048 (model-dependent) | Max token length; truncates longer inputs |\n| `max_new_tokens` | `model.generate()` | 20 | 1–1000 | Tokens to generate for text generation models |\n| `num_beams` | `model.generate()` | 1 | 1–10 | Beam search width; larger = better quality, slower |\n| `num_train_epochs` | `TrainingArguments` | 3 | 1–10 | Fine-tuning epochs |\n| `per_device_train_batch_size` | `TrainingArguments` | 8 | 4–32 | Batch size per GPU; reduce if OOM |\n| `weight_decay` | `TrainingArguments` | 0.0 | 0.01–0.1 | L2 regularization for fine-tuning |\n\n## Best Practices\n\n1. **Use domain-specific models, not general BERT**: PubMedBERT trained from scratch on PubMed outperforms BERT-base by 5–15% on biomedical NER. Always start with biomedical pre-training before fine-tuning on task-specific data.\n\n2. **Verify model licenses before production use**: Some models (BioGPT, BioMedLM) have research-only licenses. Check the HuggingFace model card's license field before deploying in commercial applications.\n\n3. **Use `aggregation_strategy=\"simple\"` for word-level NER output**: The default `\"none\"` returns subword tokens, making post-processing difficult. `\"simple\"` merges subword tokens using the first-token strategy.\n\n4. **Truncate at sentence boundaries, not mid-sentence**: Long biomedical abstracts that exceed 512 tokens should be split at sentence boundaries before encoding. Mid-sentence truncation degrades NER accuracy for entities near the cutoff.\n\n## Common Recipes\n\n### Recipe: Extract Drug-Disease Pairs from PubMed Abstracts\n\n```python\nfrom transformers import pipeline\nfrom itertools import product\n\nner = pipeline(\"ner\", model=\"d4data\u002Fbiomedical-ner-all\",\n               aggregation_strategy=\"simple\", device=-1)\n\ndef extract_drug_disease_pairs(text):\n    entities = ner(text)\n    drugs    = [e[\"word\"] for e in entities if e[\"entity_group\"] in (\"DRUG\", \"CHEMICAL\")]\n    diseases = [e[\"word\"] for e in entities if e[\"entity_group\"] in (\"DISEASE\", \"CONDITION\")]\n    return list(product(drugs, diseases))\n\ntext = \"Imatinib and nilotinib both target BCR-ABL1 in chronic myeloid leukemia and Philadelphia chromosome-positive ALL.\"\npairs = extract_drug_disease_pairs(text)\nprint(\"Drug-Disease pairs:\")\nfor drug, disease in pairs:\n    print(f\"  {drug} → {disease}\")\n```\n\n### Recipe: Sentence-Level Abstract Filtering\n\n```python\nfrom transformers import pipeline\n\nclf = pipeline(\"zero-shot-classification\",\n               model=\"facebook\u002Fbart-large-mnli\", device=-1)\n\nabstracts = [\n    \"We present a phase 3 randomized controlled trial of semaglutide in type 2 diabetes.\",\n    \"Structural analysis of the SARS-CoV-2 spike protein RBD domain by cryo-EM.\",\n    \"A retrospective cohort study of 1,200 ICU patients during the COVID-19 pandemic.\",\n]\n\nlabel_options = [\"randomized controlled trial\", \"observational study\", \"structural biology\", \"computational study\"]\n\nfor abstract in abstracts:\n    result = clf(abstract, label_options)\n    print(f\"Type: {result['labels'][0]} ({result['scores'][0]:.2f})\")\n    print(f\"  {abstract[:70]}...\\n\")\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `CUDA out of memory` during inference | Batch too large for GPU VRAM | Reduce batch size; use `device=-1` for CPU; use `model.half()` for FP16 |\n| NER returns subword tokens (`##CA`) | `aggregation_strategy` not set | Set `aggregation_strategy=\"simple\"` in `pipeline()` |\n| Model download times out | Large model files (1–10 GB); slow connection | Set `HF_HUB_OFFLINE=1` and download manually with `huggingface-cli download` |\n| NER misses entities at end of long abstracts | Input truncated at 512 tokens | Split abstracts into sentences; process each separately |\n| Fine-tuning loss is `NaN` | Learning rate too high or gradient explosion | Reduce `learning_rate` to 2e-5; enable gradient clipping `max_grad_norm=1.0` |\n| Wrong entities for specialized domain | Generic biomedical model not suited to subdomain | Fine-tune on domain-labeled data; use more specific model (e.g., gene-only NER) |\n| BioGPT generates repetitive text | `no_repeat_ngram_size` too small | Set `no_repeat_ngram_size=3` or `4`; increase `num_beams` |\n\n## Related Skills\n\n- `pubmed-database` — retrieve PubMed abstracts that serve as input to biomedical NLP pipelines\n- `biorxiv-database` — retrieve preprints for NLP analysis before peer review\n- `scientific-critical-thinking` — evaluate quality of NLP-extracted evidence before using for research conclusions\n\n## References\n\n- [HuggingFace Transformers docs](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Ftransformers\u002F) — pipeline, tokenizer, and training API\n- [BioBERT paper: Lee et al. (2020), Bioinformatics](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fbioinformatics\u002Fbtz682) — pre-training on PubMed and PMC\n- [PubMedBERT paper: Gu et al. (2021), ACL](https:\u002F\u002Fdoi.org\u002F10.1145\u002F3458754) — from-scratch pre-training on PubMed\n- [BioGPT paper: Luo et al. (2022), Briefings in Bioinformatics](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fbib\u002Fbbac409) — generative biomedical language model\n- [BioCreative benchmarks](https:\u002F\u002Fbiocreative.bioinformatics.udel.edu\u002F) — standard NER and relation extraction datasets\n","# Transformers for Biomedical NLP\n\n## Overview\n\nHuggingFace 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\u002Fdisease NER) takes under an hour on a single GPU. The `datasets` library provides direct access to standard biomedical benchmarks.\n\n## When to Use\n\n- Extracting gene names, disease mentions, drug names, or chemical entities from biomedical abstracts (NER)\n- Classifying abstracts by topic, sentiment of clinical outcomes, or PICO elements for systematic reviews\n- Answering specific questions from biomedical literature using extractive QA (BioASQ format)\n- Generating hypotheses or summaries from biomedical text using BioGPT or BioMedLM\n- Fine-tuning a pre-trained biomedical model on a custom labeled dataset (e.g., your lab's annotations)\n- Embedding biomedical sentences for semantic similarity search across literature\n- Use spaCy + en_core_sci_lg for fast rule-augmented NER; use Stanza for dependency parsing\n\n## Prerequisites\n\n- **Python packages**: `transformers`, `torch`, `datasets`, `accelerate`, `sentencepiece`\n- **GPU**: Strongly recommended for fine-tuning; inference on CPU is viable for single texts\n- **Data requirements**: plain text biomedical strings; for fine-tuning, annotated data in BIO\u002FIOB format\n\n```bash\npip install transformers torch datasets accelerate sentencepiece\n# For GPU (CUDA 11.8)\npip install torch torchvision --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\n```\n\n## Quick Start\n\n```python\nfrom transformers import pipeline\n\n# Named entity recognition with BioBERT\nner = pipeline(\"ner\", model=\"allenai\u002Fscibert_scivocab_cased\",\n               aggregation_strategy=\"simple\")\n\ntext = \"BRCA1 mutations are associated with increased risk of breast cancer and ovarian cancer.\"\nentities = ner(text)\nfor ent in entities:\n    print(f\"  {ent['word']:20s} {ent['entity_group']:10s} score={ent['score']:.3f}\")\n```\n\n## Core API\n\n### Module 1: Named Entity Recognition (NER)\n\nExtract biomedical entities using pre-trained NER models.\n\n```python\nfrom transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification\n\n# BioBERT fine-tuned for NER (genes, diseases, chemicals)\n# Common choices:\n#   \"allenai\u002Fscibert_scivocab_cased\"  — scientific NER\n#   \"d4data\u002Fbiomedical-ner-all\"       — multi-entity biomedical NER\n#   \"pruas\u002FBENT-PubMedBERT-NER-Gene\"  — gene-specific NER\nner_pipe = pipeline(\n    \"ner\",\n    model=\"d4data\u002Fbiomedical-ner-all\",\n    aggregation_strategy=\"simple\",  # merge subword tokens into words\n    device=-1  # -1=CPU, 0=GPU\n)\n\nabstracts = [\n    \"Imatinib inhibits the BCR-ABL1 tyrosine kinase and is first-line treatment for CML.\",\n    \"EGFR mutations in non-small cell lung cancer predict response to erlotinib.\",\n]\n\nfor text in abstracts:\n    entities = ner_pipe(text)\n    print(f\"\\nText: {text[:60]}...\")\n    for e in entities:\n        print(f\"  [{e['entity_group']}] '{e['word']}' (score={e['score']:.2f})\")\n```\n\n```python\n# Manual tokenization + inference for batch processing\nfrom transformers import AutoTokenizer, AutoModelForTokenClassification\nimport torch\n\nmodel_name = \"allenai\u002Fscibert_scivocab_cased\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModelForTokenClassification.from_pretrained(model_name)\nmodel.eval()\n\ntext = \"Metformin activates AMPK and reduces hepatic glucose production in type 2 diabetes.\"\ninputs = tokenizer(text, return_tensors=\"pt\", truncation=True, max_length=512)\n\nwith torch.no_grad():\n    outputs = model(**inputs)\n\nlogits = outputs.logits  # shape: (1, seq_len, n_labels)\npredictions = logits.argmax(dim=-1)[0]\ntokens = tokenizer.convert_ids_to_tokens(inputs[\"input_ids\"][0])\nlabels = [model.config.id2label[p.item()] for p in predictions]\n\nfor token, label in zip(tokens[1:-1], labels[1:-1]):  # skip [CLS] and [SEP]\n    if label != \"O\":\n        print(f\"  {token:20s} {label}\")\n```\n\n### Module 2: Text Classification\n\nClassify biomedical abstracts or sentences.\n\n```python\nfrom transformers import pipeline\n\n# Zero-shot classification — no fine-tuning needed\nzs_clf = pipeline(\"zero-shot-classification\",\n                  model=\"facebook\u002Fbart-large-mnli\",\n                  device=-1)\n\nabstract = \"\"\"\nThis randomized controlled trial evaluated the efficacy of pembrolizumab versus\nchemotherapy in patients with advanced non-small-cell lung cancer. Overall survival\nwas significantly improved in the pembrolizumab arm (HR=0.60, 95% CI 0.41-0.89).\n\"\"\"\n\ncandidate_labels = [\"clinical trial\", \"basic research\", \"meta-analysis\", \"review\"]\nresult = zs_clf(abstract, candidate_labels)\nprint(\"Zero-shot classification:\")\nfor label, score in zip(result[\"labels\"], result[\"scores\"]):\n    print(f\"  {label:20s}: {score:.3f}\")\n```\n\n```python\n# Fine-tuned sentiment\u002Foutcome classification\nfrom transformers import pipeline\n\n# Example: classify clinical outcome sentiment\nclf = pipeline(\"text-classification\",\n               model=\"pruas\u002FBENT-PubMedBERT-NER-Gene\",  # use appropriate task-specific model\n               device=-1)\n\nsentences = [\n    \"Treatment significantly improved overall survival (p\u003C0.001).\",\n    \"No statistically significant difference was observed between groups.\",\n]\nresults = clf(sentences)\nfor sent, result in zip(sentences, results):\n    print(f\"  [{result['label']} | {result['score']:.2f}] {sent[:50]}...\")\n```\n\n### Module 3: Biomedical Question Answering\n\nExtract answers from biomedical text passages.\n\n```python\nfrom transformers import pipeline\n\n# Extractive QA: find answer span within context\nqa_pipe = pipeline(\n    \"question-answering\",\n    model=\"sultan\u002FBioM-ELECTRA-Large-SQuAD2\",  # biomedical QA model\n    device=-1\n)\n\ncontext = \"\"\"\nBRCA1 is a tumor suppressor gene located on chromosome 17q21. Pathogenic variants\nin BRCA1 confer a lifetime breast cancer risk of 50-72% and ovarian cancer risk\nof 44-46%. BRCA1 protein functions in DNA double-strand break repair via\nhomologous recombination.\n\"\"\"\n\nquestions = [\n    \"What chromosome is BRCA1 located on?\",\n    \"What is the lifetime breast cancer risk from BRCA1 variants?\",\n    \"What DNA repair pathway does BRCA1 participate in?\",\n]\n\nfor q in questions:\n    result = qa_pipe(question=q, context=context)\n    print(f\"Q: {q}\")\n    print(f\"A: {result['answer']} (score={result['score']:.3f})\\n\")\n```\n\n### Module 4: Text Generation with BioGPT\n\nGenerate biomedical text, hypotheses, and summaries.\n\n```python\nfrom transformers import AutoTokenizer, BioGptForCausalLM\nimport torch\n\nmodel_name = \"microsoft\u002Fbiogpt\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = BioGptForCausalLM.from_pretrained(model_name)\nmodel.eval()\n\nprompt = \"The role of VEGF in tumor angiogenesis\"\ninputs = tokenizer(prompt, return_tensors=\"pt\")\n\nwith torch.no_grad():\n    outputs = model.generate(\n        **inputs,\n        max_new_tokens=100,\n        num_beams=5,\n        early_stopping=True,\n        no_repeat_ngram_size=3,\n        pad_token_id=tokenizer.eos_token_id,\n    )\n\ngenerated = tokenizer.decode(outputs[0], skip_special_tokens=True)\nprint(f\"Generated:\\n{generated}\")\n```\n\n### Module 5: Sentence Embeddings for Semantic Search\n\nEmbed biomedical text for similarity search and clustering.\n\n```python\nfrom transformers import AutoTokenizer, AutoModel\nimport torch\nimport numpy as np\n\ndef mean_pooling(model_output, attention_mask):\n    \"\"\"Mean pooling across token embeddings.\"\"\"\n    token_embeddings = model_output.last_hidden_state\n    input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()\n    return (token_embeddings * input_mask_expanded).sum(1) \u002F input_mask_expanded.sum(1)\n\n# PubMedBERT for biomedical sentence embeddings\nmodel_name = \"microsoft\u002FBiomedNLP-BiomedBERT-base-uncased-abstract-fulltext\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModel.from_pretrained(model_name)\nmodel.eval()\n\nsentences = [\n    \"BRCA1 is involved in DNA double-strand break repair.\",\n    \"Homologous recombination requires BRCA1 and BRCA2.\",\n    \"Metformin inhibits hepatic gluconeogenesis via AMPK.\",\n]\n\ninputs = tokenizer(sentences, padding=True, truncation=True,\n                   max_length=512, return_tensors=\"pt\")\nwith torch.no_grad():\n    outputs = model(**inputs)\n\nembeddings = mean_pooling(outputs, inputs[\"attention_mask\"])\nembeddings = torch.nn.functional.normalize(embeddings, p=2, dim=1).numpy()\n\n# Compute cosine similarity\nfrom numpy.linalg import norm\nsim_01 = np.dot(embeddings[0], embeddings[1])\nsim_02 = np.dot(embeddings[0], embeddings[2])\nprint(f\"Similarity (BRCA1 repair vs. HR): {sim_01:.3f}\")\nprint(f\"Similarity (BRCA1 repair vs. Metformin): {sim_02:.3f}\")\n```\n\n### Module 6: Fine-Tuning on Custom Data\n\nFine-tune a biomedical model on a labeled NER dataset.\n\n```python\nfrom transformers import (AutoTokenizer, AutoModelForTokenClassification,\n                           TrainingArguments, Trainer, DataCollatorForTokenClassification)\nfrom datasets import Dataset\nimport numpy as np\n\n# Example: minimal NER fine-tuning setup\nmodel_name = \"microsoft\u002FBiomedNLP-BiomedBERT-base-uncased-abstract\"\nlabel_list = [\"O\", \"B-GENE\", \"I-GENE\", \"B-DISEASE\", \"I-DISEASE\"]\nid2label = {i: l for i, l in enumerate(label_list)}\nlabel2id = {l: i for i, l in enumerate(label_list)}\n\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModelForTokenClassification.from_pretrained(\n    model_name, num_labels=len(label_list), id2label=id2label, label2id=label2id\n)\n\n# Training arguments\ntraining_args = TrainingArguments(\n    output_dir=\".\u002Fbiomed_ner_finetuned\",\n    num_train_epochs=3,\n    per_device_train_batch_size=16,\n    per_device_eval_batch_size=32,\n    warmup_steps=100,\n    weight_decay=0.01,\n    logging_dir=\".\u002Flogs\",\n    evaluation_strategy=\"epoch\",\n    save_strategy=\"epoch\",\n    load_best_model_at_end=True,\n)\n\nprint(f\"Model ready for fine-tuning: {model_name}\")\nprint(f\"Labels: {label_list}\")\n# trainer = Trainer(model=model, args=training_args, ...)\n# trainer.train()\n```\n\n## Key Concepts\n\n### Tokenization of Biomedical Text\n\nBiomedical text contains special tokens (gene symbols, drug names, chemical SMILES, numeric values) that WordPiece and BPE tokenizers split unexpectedly. For example, \"BRCA1\" → `[\"BR\", \"##CA\", \"##1\"]`. This subword splitting does not affect classification tasks but does affect NER — use `aggregation_strategy=\"simple\"` or `\"first\"` in `pipeline()` to merge subword predictions back to word level.\n\n### BIO Labeling Scheme\n\nNER uses BIO (Begin-Inside-Outside) tagging: `B-GENE` marks the first token of a gene name, `I-GENE` marks continuation tokens, `O` marks non-entity tokens. During fine-tuning, align labels to subword tokens by setting non-first subword labels to `-100` (ignored by the loss function).\n\n## Common Workflows\n\n### Workflow 1: Batch Abstract NER and Entity Aggregation\n\n```python\nfrom transformers import pipeline\nimport pandas as pd\n\nner_pipe = pipeline(\"ner\", model=\"d4data\u002Fbiomedical-ner-all\",\n                    aggregation_strategy=\"simple\", device=-1)\n\nabstracts = [\n    \"Pembrolizumab combined with chemotherapy significantly improved progression-free survival in HER2-positive breast cancer.\",\n    \"Inhibition of EGFR by gefitinib is effective in patients with activating EGFR mutations in exons 19 and 21.\",\n    \"CRISPR-Cas9 editing of the PCSK9 gene in hepatocytes reduces LDL cholesterol in murine models.\",\n]\n\nrecords = []\nfor i, text in enumerate(abstracts):\n    entities = ner_pipe(text)\n    for e in entities:\n        records.append({\n            \"abstract_id\": i,\n            \"entity\": e[\"word\"],\n            \"type\": e[\"entity_group\"],\n            \"score\": round(e[\"score\"], 3),\n        })\n\ndf = pd.DataFrame(records)\nprint(df.groupby(\"type\")[\"entity\"].apply(list).to_string())\ndf.to_csv(\"extracted_entities.csv\", index=False)\nprint(f\"\\nExtracted {len(df)} entity mentions across {len(abstracts)} abstracts\")\n```\n\n### Workflow 2: Semantic Similarity Ranking for Literature Retrieval\n\n```python\nfrom transformers import AutoTokenizer, AutoModel\nimport torch\nimport numpy as np\n\nmodel_name = \"microsoft\u002FBiomedNLP-BiomedBERT-base-uncased-abstract-fulltext\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModel.from_pretrained(model_name)\nmodel.eval()\n\ndef embed(texts):\n    enc = tokenizer(texts, padding=True, truncation=True,\n                    max_length=512, return_tensors=\"pt\")\n    with torch.no_grad():\n        out = model(**enc)\n    vecs = out.last_hidden_state[:, 0, :]  # [CLS] token\n    return torch.nn.functional.normalize(vecs, dim=1).numpy()\n\nquery = \"CRISPR base editing for correction of point mutations in genetic disease\"\ncorpus = [\n    \"Base editing enables precise single-base changes in genomic DNA without double-strand breaks.\",\n    \"CAR-T cell therapy targets CD19 in B-cell acute lymphoblastic leukemia.\",\n    \"Prime editing uses reverse transcriptase to install targeted edits at specific loci.\",\n    \"RNA interference silences gene expression via RISC-mediated mRNA cleavage.\",\n]\n\nq_emb = embed([query])\nc_emb = embed(corpus)\nscores = (q_emb @ c_emb.T).flatten()\nranked = sorted(zip(scores, corpus), reverse=True)\n\nprint(\"Top results:\")\nfor score, text in ranked:\n    print(f\"  [{score:.3f}] {text[:70]}...\")\n```\n\n## Key Parameters\n\n| Parameter | Module\u002FFunction | Default | Range \u002F Options | Effect |\n|-----------|----------------|---------|-----------------|--------|\n| `model` | `pipeline()` | — | HuggingFace model ID string | Pre-trained model to load; must match task |\n| `aggregation_strategy` | NER `pipeline` | `\"none\"` | `\"none\"`, `\"simple\"`, `\"first\"`, `\"average\"` | Merge subword NER predictions; use `\"simple\"` for word-level output |\n| `device` | `pipeline()` | -1 | -1 (CPU), 0 (GPU 0), 1 (GPU 1) | Inference device |\n| `max_length` | tokenizer | 512 | 128–2048 (model-dependent) | Max token length; truncates longer inputs |\n| `max_new_tokens` | `model.generate()` | 20 | 1–1000 | Tokens to generate for text generation models |\n| `num_beams` | `model.generate()` | 1 | 1–10 | Beam search width; larger = better quality, slower |\n| `num_train_epochs` | `TrainingArguments` | 3 | 1–10 | Fine-tuning epochs |\n| `per_device_train_batch_size` | `TrainingArguments` | 8 | 4–32 | Batch size per GPU; reduce if OOM |\n| `weight_decay` | `TrainingArguments` | 0.0 | 0.01–0.1 | L2 regularization for fine-tuning |\n\n## Best Practices\n\n1. **Use domain-specific models, not general BERT**: PubMedBERT trained from scratch on PubMed outperforms BERT-base by 5–15% on biomedical NER. Always start with biomedical pre-training before fine-tuning on task-specific data.\n\n2. **Verify model licenses before production use**: Some models (BioGPT, BioMedLM) have research-only licenses. Check the HuggingFace model card's license field before deploying in commercial applications.\n\n3. **Use `aggregation_strategy=\"simple\"` for word-level NER output**: The default `\"none\"` returns subword tokens, making post-processing difficult. `\"simple\"` merges subword tokens using the first-token strategy.\n\n4. **Truncate at sentence boundaries, not mid-sentence**: Long biomedical abstracts that exceed 512 tokens should be split at sentence boundaries before encoding. Mid-sentence truncation degrades NER accuracy for entities near the cutoff.\n\n## Common Recipes\n\n### Recipe: Extract Drug-Disease Pairs from PubMed Abstracts\n\n```python\nfrom transformers import pipeline\nfrom itertools import product\n\nner = pipeline(\"ner\", model=\"d4data\u002Fbiomedical-ner-all\",\n               aggregation_strategy=\"simple\", device=-1)\n\ndef extract_drug_disease_pairs(text):\n    entities = ner(text)\n    drugs    = [e[\"word\"] for e in entities if e[\"entity_group\"] in (\"DRUG\", \"CHEMICAL\")]\n    diseases = [e[\"word\"] for e in entities if e[\"entity_group\"] in (\"DISEASE\", \"CONDITION\")]\n    return list(product(drugs, diseases))\n\ntext = \"Imatinib and nilotinib both target BCR-ABL1 in chronic myeloid leukemia and Philadelphia chromosome-positive ALL.\"\npairs = extract_drug_disease_pairs(text)\nprint(\"Drug-Disease pairs:\")\nfor drug, disease in pairs:\n    print(f\"  {drug} → {disease}\")\n```\n\n### Recipe: Sentence-Level Abstract Filtering\n\n```python\nfrom transformers import pipeline\n\nclf = pipeline(\"zero-shot-classification\",\n               model=\"facebook\u002Fbart-large-mnli\", device=-1)\n\nabstracts = [\n    \"We present a phase 3 randomized controlled trial of semaglutide in type 2 diabetes.\",\n    \"Structural analysis of the SARS-CoV-2 spike protein RBD domain by cryo-EM.\",\n    \"A retrospective cohort study of 1,200 ICU patients during the COVID-19 pandemic.\",\n]\n\nlabel_options = [\"randomized controlled trial\", \"observational study\", \"structural biology\", \"computational study\"]\n\nfor abstract in abstracts:\n    result = clf(abstract, label_options)\n    print(f\"Type: {result['labels'][0]} ({result['scores'][0]:.2f})\")\n    print(f\"  {abstract[:70]}...\\n\")\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `CUDA out of memory` during inference | Batch too large for GPU VRAM | Reduce batch size; use `device=-1` for CPU; use `model.half()` for FP16 |\n| NER returns subword tokens (`##CA`) | `aggregation_strategy` not set | Set `aggregation_strategy=\"simple\"` in `pipeline()` |\n| Model download times out | Large model files (1–10 GB); slow connection | Set `HF_HUB_OFFLINE=1` and download manually with `huggingface-cli download` |\n| NER misses entities at end of long abstracts | Input truncated at 512 tokens | Split abstracts into sentences; process each separately |\n| Fine-tuning loss is `NaN` | Learning rate too high or gradient explosion | Reduce `learning_rate` to 2e-5; enable gradient clipping `max_grad_norm=1.0` |\n| Wrong entities for specialized domain | Generic biomedical model not suited to subdomain | Fine-tune on domain-labeled data; use more specific model (e.g., gene-only NER) |\n| BioGPT generates repetitive text | `no_repeat_ngram_size` too small | Set `no_repeat_ngram_size=3` or `4`; increase `num_beams` |\n\n## Related Skills\n\n- `pubmed-database` — retrieve PubMed abstracts that serve as input to biomedical NLP pipelines\n- `biorxiv-database` — retrieve preprints for NLP analysis before peer review\n- `scientific-critical-thinking` — evaluate quality of NLP-extracted evidence before using for research conclusions\n\n## References\n\n- [HuggingFace Transformers docs](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Ftransformers\u002F) — pipeline, tokenizer, and training API\n- [BioBERT paper: Lee et al. (2020), Bioinformatics](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fbioinformatics\u002Fbtz682) — pre-training on PubMed and PMC\n- [PubMedBERT paper: Gu et al. (2021), ACL](https:\u002F\u002Fdoi.org\u002F10.1145\u002F3458754) — from-scratch pre-training on PubMed\n- [BioGPT paper: Luo et al. (2022), Briefings in Bioinformatics](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fbib\u002Fbbac409) — generative biomedical language model\n- [BioCreative benchmarks](https:\u002F\u002Fbiocreative.bioinformatics.udel.edu\u002F) — standard NER and relation extraction datasets\n",{"name":5,"license":15,"description":7},"master","63f17866001c5ca854bf2fa0b678ce277133de5b","skills\u002Fawesome-skills\u002Ftransformers-bio-nlp",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill transformers-bio-nlp",{"tool":40,"command":41},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill transformers-bio-nlp",{"tool":43,"command":44},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill transformers-bio-nlp","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Ftransformers-bio-nlp\u002FSKILL.md",true,[],[49,58,65,72,79,86],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":57},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":57},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":57},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":57},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":57},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":57},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]