Nerp

Latest version: v1.0.2.2

Safety actively analyzes 681775 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

1.1rc1

- or via the repository:
bash
git clone --branch v1.1-rc1 https://github.com/Chaarangan/NERP.git
cd NERP && pip install -e .



Training
- Common function to call
python
model.train()

There are several options depending on your needs:
- Casual Training: Configure the YAML file and set continue_from_checkpoint as False and is_kfold as False. Then call model.train().
- Training from a previous checkpoint: Configure the YAML file and set continue_from_checkpoint as True and is_kfold as False. You will need to specify the checkpoint_path. Then call model.train().
- Training with KFold: Configure the YAML file and set continue_from_checkpoint as False and is_kfold as True. You will need to specify the number of splits. If you wish to test each fold with your original test set rather than its own test split, set the test_on_original variable as True. Then call model.train().
- Training from a previous checkpoint with KFold: Configure the YAML file and set continue_from_checkpoint as True and is_kfold as True. You will need to specify the checkpoint_path. Then call model.train().

Predictions
There are several options depending on your needs:
- Prediction on a CSV file: Configure the YAML file and give model_path, tokenizer_path (if exists), in_file_path, and out_file_path. Then call model.predict().
python
model.predict()


- Prediction on text: Configure the YAML file and give model_path and tokenizer_path (if exists). Then call model.predict_text(“some text”).
python
output = model.predict_text("Hello from NERP")
print(output)


Thank you
Last but certainly not least, a big Thank You to the contributors of NERP.

PRs
- [tanmaysurana](https://github.com/tanmaysurana) (Tanmay Surana): add support for testing on multiple files, add additional parameters to maintain consistency across multiple experiments (validation batch size, shuffle, fixed seed), and improve loss computation algorithms [PR #20](https://github.com/Chaarangan/NERP/pull/20)

1.0.2.2

- or via the repository:
bash
git clone --branch v1.0.2.2 https://github.com/Chaarangan/NERP.git
cd NERP && pip install -e .

1.0.2.1

- or via the repository:
bash
git clone --branch v1.0.2.1 https://github.com/Chaarangan/NERP.git
cd NERP & pip install -e .

1.0.2

- or via repository:
bash
git clone --branch v1.0.2 https://github.com/Chaarangan/NERP.git
cd NERP & pip install -e .

1.0.0

NERP - Pipeline for training NER models

What is it?
NERP (Named Entity Recognition Pipeline) is a python package that offers an easy-to-use pipeline for fine-tuning pre-trained transformers for Named Entity Recognition (NER) tasks.

Main Features
- Train a base model
- Train an already trained model by loading its weights
- Training with K-Fold Cross-Validation
- Train an already trained model with K-Fold Cross Validation after loading its weights
- Bulk mode training
- Prediction on a single text
- Prediction on a CSV file

Usage
**Environment Setup**
- Activate a new conda/python environment
- Install NERP via pip
python
pip install NERP


or via repository
bash
git clone https://github.com/Chaarangan/NERP
cd NERP
pip install -e .


**Initialize NERP**
python
from NERP.models import NERP
model = NERP("env.yaml")


**Training a NER model using NERP**
- Train a base model
python
model.train()

- Train an already trained model by loading its weights
python
model.train_after_load_network()

- Training with K-Fold Cross-Validation
python
model.train_with_kfold()

- Train an already trained model with K-Fold Cross Validation after loading its weights
python
model.train_with_kfold_after_loading_network()


**Inference of a NER model using NERP**
- Prediction on a single text
python
output = model.inference_text()
print(output)

- Prediction on a CSV file
python
model.inference_bulk()


Diagrams
<table>
<tr>
<td>NERP Main Component</td>
</tr>
<tr>
<td><img alt="NERP Main Component" src="https://github.com/Chaarangan/NERP/blob/master/diagrams/1.png"/></td>
</tr>
<tr>
<td>Component of NERP K-Fold Cross Validation</td>
</tr>
<tr>
<td><img align="left" alt="Component of NERP K-Fold Cross Validation" src="https://github.com/Chaarangan/NERP/blob/master/diagrams/2.png" height="200"/></td>
</tr>
<tr>
<td>Component of NERP Inference</td>
</tr>
<tr>
<td><img align="left" alt="Component of NERP Inference" src="https://github.com/Chaarangan/NERP/blob/master/diagrams/3.png" height="200"/></td>
</tr>
</table>

Links

Releases

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.