Run this model with HF Jobs
Run ProdicusII/ZeroShotBioNER on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/ProdicusII/ZeroShotBioNER. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ProdicusII/ZeroShotBioNER on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use ProdicusII/ZeroShotBioNER with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ProdicusII/ZeroShotBioNER with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="ProdicusII/ZeroShotBioNER")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("ProdicusII/ZeroShotBioNER") model = AutoModelForTokenClassification.from_pretrained("ProdicusII/ZeroShotBioNER", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Commit ·
731585b
1
Parent(s): b25e95c
Promena, dodate informacije o tipu modela (#8)
Browse files- Promena, dodate informacije o tipu modela (0b5374e5350fd33f9de52210f4a3890ce1fd200e)
Co-authored-by: Nikola <nikolamilosevic@users.noreply.huggingface.co>
28 unmodified lines2930313233343511 unmodified lines474849505152535455565728 unmodified linesThis model was created during the research collaboration between Bayer Pharma and Serbian Institute for Artificial Intelligence Research and Development.The model is trained on about 25+ biomedical NER classes and can perform also zero-shot inference and can be further fine-tuned for new classes with just few examples (few-shot learning).For more details about our methods please see the paper named ["A transformer-based method for zero and few-shot biomedical named entity recognition"](https://arxiv.org/abs/2305.04928).Model takes as input two strings. String1 is NER label that is being searched in second string. String1 must be phrase for entity. String2 is short text where String1 is searched for semantically.model outputs list of zeros and ones corresponding to the occurance of Named Entity and corresponing to the tokens(tokens given by transformer tokenizer) of the Sring2.11 unmodified linespadding=True, truncation=True, add_special_tokens=True, return_offsets_mapping=False,max_length=512, return_tensors='pt')model = BertForTokenClassification.from_pretrained(modelname, num_labels=2)prediction_logits = model(**encodings)print(prediction_logits)```## Available classesThe following datasets and entities were used for training and therefore they can be used as label in the first segment (as a first string). Note that multiword string have been merged.28 unmodified lines2930313233343511 unmodified lines4748495051525354555657585960616263646566676869707172737475767778798081828384858687888928 unmodified linesThis model was created during the research collaboration between Bayer Pharma and Serbian Institute for Artificial Intelligence Research and Development.The model is trained on about 25+ biomedical NER classes and can perform also zero-shot inference and can be further fine-tuned for new classes with just few examples (few-shot learning).For more details about our methods please see the paper named ["A transformer-based method for zero and few-shot biomedical named entity recognition"](https://arxiv.org/abs/2305.04928). The model corresponds to BioBERT-based mode, trained with 1 in the first segment (check paper for more details).Model takes as input two strings. String1 is NER label that is being searched in second string. String1 must be phrase for entity. String2 is short text where String1 is searched for semantically.model outputs list of zeros and ones corresponding to the occurance of Named Entity and corresponing to the tokens(tokens given by transformer tokenizer) of the Sring2.11 unmodified linespadding=True, truncation=True, add_special_tokens=True, return_offsets_mapping=False,max_length=512, return_tensors='pt')model0 = BertForTokenClassification.from_pretrained(modelname, num_labels=2)prediction_logits = model0(**encodings)print(prediction_logits)```## Example of fine-tuning with few-shot learningIn order to fine-tune model to the new entity using few shots, the dataset needs to be transformed to torch.utils.data.Dataset, containing BERT tokens and set of 0s and 1s (1 is where the class is positive and should be predicted as the member of given NER class). After the dataset is created, the following can be done (for more details, please have a look at the code at GitHub - https://github.com/br-ai-ns-institute/Zero-ShotNER):```pythontraining_args = TrainingArguments(output_dir=os.path.join('Results', class_unseen, str(j)+'Shot'), # folder for resultsnum_train_epochs=10, # number of epochsper_device_train_batch_size=16, # batch size per device during trainingper_device_eval_batch_size=16, # batch size for evaluationweight_decay=0.01, # strength of weight decaylogging_dir=os.path.join('Logs', class_unseen, str(j)+'Shot'), # folder for logssave_strategy='epoch',evaluation_strategy='epoch',load_best_model_at_end=True,)model0 = BertForTokenClassification.from_pretrained(model_path, num_labels=2)trainer = Trainer(model=model0, # pretrained modelargs=training_args, # training artgumentstrain_dataset=dataset, # Object of class torch.utils.data.Dataset for trainingeval_dataset=dataset_valid # Object of class torch.utils.data.Dataset for vaLidation)start_time = time.time()trainer.train()total_time = time.time()-start_timemodel0_path = os.path.join('Results', class_unseen, str(j)+'Shot', 'Model')os.makedirs(model0_path, exist_ok=True)trainer.save_model(model0_path)```## Available classesThe following datasets and entities were used for training and therefore they can be used as label in the first segment (as a first string). Note that multiword string have been merged.
README.md+35-3