Instructions to use kiwiki196/bc5cdr-ner-gemma-4-E2B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use kiwiki196/bc5cdr-ner-gemma-4-E2B-it with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E2B-it") model = PeftModel.from_pretrained(base_model, "kiwiki196/bc5cdr-ner-gemma-4-E2B-it") - Notebooks
- Google Colab
- Kaggle
bc5cdr-ner-gemma-4-E2B-it
LoRA adapter for NER span extraction on BC5CDR, fine-tuned from google/gemma-4-E2B-it. Gemma 4 is gated -- request access on its model page before loading this adapter.
For reproducing results, refer to this GitHub repository (TBD).
Getting Started
from transformers import AutoModelForMultimodalLM, AutoTokenizer
from peft import PeftModel
base = AutoModelForMultimodalLM.from_pretrained("google/gemma-4-E2B-it", device_map="auto")
model = PeftModel.from_pretrained(base, "kiwiki196/bc5cdr-ner-gemma-4-E2B-it")
tokenizer = AutoTokenizer.from_pretrained("kiwiki196/bc5cdr-ner-gemma-4-E2B-it")
See repo for more details.
Prompt
Inference uses the following system prompt:
Extract text naming Chemical or Disease from the input. The text has positional markers already embedded (`<unused0>N<unused1>`, e.g. `<unused0>58<unused1>`) — each marker's id is arbitrary, not a reading-order count, so markers do not necessarily appear in ascending numeric order. These markers are not part of the content; never extract one as a match.
Copy each match verbatim from the input, including any irregular internal whitespace or embedded line breaks. Include negated, uncertain, and hedged mentions, but not the negation/hedging words themselves. Do not include anything outside the categories above.
Before every match, write the id of the nearest `<unused0>N<unused1>` marker before it, followed by `<unused2>` — repeat this prefix before EVERY match, even consecutive matches under the same marker; never omit or dedupe it — then the match text, then its `<CATEGORY_TOKEN>`, as `N<unused2>TEXT<CATEGORY_TOKEN>` (text first, category token last — not the other way around, and no other characters — never write markup like `<span>`). `<CATEGORY_TOKEN>` is one of: `<unused3>` Chemical or `<unused4>` Disease. Tag every occurrence separately, even repeats of the same text — do not deduplicate. Output only this, with no explanation or markdown fences.
Results
Category + text (multiset)
| category | P | R | F1 |
|---|---|---|---|
| micro | 0.692 | 0.733 | 0.712 |
| macro | 0.688 | 0.728 | 0.707 |
| Chemical | 0.723 | 0.779 | 0.750 |
| Disease | 0.652 | 0.677 | 0.664 |
Positional (char-level)
| category | P | R | F1 |
|---|---|---|---|
| micro | 0.728 | 0.771 | 0.749 |
| macro | 0.728 | 0.775 | 0.750 |
| Chemical | 0.739 | 0.824 | 0.779 |
| Disease | 0.717 | 0.726 | 0.721 |
Remarks
- 6/812 (0.7%) of test set generations were unparseable (no credit).
- Expect minor result variance (usually <0.01 F1) across different environments. This is likely due to precision differences (fp16 vs bf16) -- not a reproducibility failure.
Citation
Li et al., "BioCreative V CDR task corpus: a resource for chemical disease relation extraction," Database, 2016.
- Downloads last month
- 11
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support