-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: upgrade gradle, dependencies and java
Upgraded Gradle to version 8.9 updated dependencies upgraded Java from version 11 to 17
- Loading branch information
Showing
7 changed files
with
145 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,7 @@ bin/ | |
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
.DS_Store | ||
|
||
# python | ||
venv |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,51 @@ | ||
# Run HuggingFace NER (NLP) Model on Java using ONNX Runtime and DJL | ||
A NLP (Natural Language Processing) Java Application which detects `Names`, `organizaions`, and `locations` in a text by running Hugging face's [Roberta NER model](https://huggingface.co/xlm-roberta-large-finetuned-conll03-english) using [ONNX runtime](https://onnxruntime.ai/docs/get-started/with-java.html) and [Deep Java Library](https://djl.ai/) | ||
# Run HuggingFace NER (NLP) Model on Java using ONNX Runtime and DJL | ||
|
||
A Natural Language Processing (NLP) Java application that detects `names`, `organizations`, and `locations` in a text by running Hugging Face's [Roberta NER model](https://huggingface.co/xlm-roberta-large-finetuned-conll03-english) using [ONNX Runtime](https://onnxruntime.ai/docs/get-started/with-java.html) and the [Deep Java Library](https://djl.ai/). | ||
|
||
## Installation | ||
|
||
Open the project folder in a Java IDE (recommended: IntelliJ IDEA Community) with Gradle support and build the project. | ||
|
||
## Installation: | ||
Open Project folder in Java IDE (`Recommended: IntelliJ IDEA Community`) with gradle support and Build the project | ||
### Requirements | ||
|
||
1. Java Development Kit (JDK) version 17 | ||
2. Gradle version 8.9 | ||
|
||
### Requirements: | ||
1. Java Development Kit JDK version: 11 | ||
2. Gradle version 7+ | ||
### Download Files | ||
|
||
### Download files | ||
These files are required to run the project: | ||
|
||
These files are required to run the project | ||
|
||
1. ONNX model | ||
1. ONNX model | ||
2. `tokenizer.json` file | ||
|
||
### Convert the ONNX model | ||
### Convert the ONNX Model | ||
|
||
To convert HuggingFace NER model to ONNX Open this [Google Colaboratory Notebook](https://colab.research.google.com/drive/1kZx9XOnExVfPoAGHhHRUrdQnioiLloBW#revisionId=0BwKss6yztf4KS0NKaWRiQjc0RGRvQkd6ZFp3OUFhR1lTclBNPQ) run the code as image shown below and follow all the steps | ||
To convert the Hugging Face NER model to ONNX, open this [Google Colaboratory Notebook](https://colab.research.google.com/drive/1kZx9XOnExVfPoAGHhHRUrdQnioiLloBW#revisionId=0BwKss6yztf4KS0NKaWRiQjc0RGRvQkd6ZFp3OUFhR1lTclBNPQ), run the code as shown in the image below, and follow all the steps. | ||
|
||
![run colab code cell](images/run-colab.jpeg) | ||
![run colab code cell](images/run-colab.jpeg) | ||
|
||
(The code for this purpose is also saved in the Jupyter notebook file `convert Huggingface model to ONNX.ipynb`. You can run the code using [Jupyter Notebook](https://jupyter.org/install).) | ||
|
||
After running one of the above codes, your ONNX model will be saved in the `onnx/` folder. | ||
|
||
(the code for above purpose is also saved in jupyter notebook in the file `convert Huggingface model to ONNX.ipynb`. you can run the code using [Jupyter notebook](https://jupyter.org/install)) | ||
### Download tokenizer.json | ||
|
||
after running the one of above codes your onnx model will be saved in `onnx/` folder. | ||
The tokenizer file `tokenizer.json` was taken from this [Hugging Face repository](https://huggingface.co/xlm-roberta-large-finetuned-conll03-english). Download the `tokenizer.json` from this [link](https://huggingface.co/xlm-roberta-large-finetuned-conll03-english/raw/main/tokenizer.json). | ||
|
||
### Download tokenizer.json | ||
Tokenzer file `tokenizer.json` was taken from this [huggingface repo](https://huggingface.co/xlm-roberta-large-finetuned-conll03-english) | ||
Download the `tokenizer.json` from the [link](https://huggingface.co/xlm-roberta-large-finetuned-conll03-english/raw/main/tokenizer.json) | ||
**Move Files** | ||
|
||
**move files** | ||
Copy files created from above two stesp into `raw-files` directory as shown in the below image | ||
Copy the files created from the above steps into the `raw-files` directory as shown in the image below. | ||
|
||
![raw-files path](images/model-location.png) | ||
|
||
## Building the Project | ||
|
||
## Building project | ||
Build the project using This button | ||
Build the project using the button shown below. | ||
|
||
![how to build project](images/building-project.jpg) | ||
|
||
## Run the Code | ||
|
||
Open the `Main.java` file and click the play button as shown in the red box in the below image | ||
![how to run project](images/run-code.jpg) | ||
Open the `Main.java` file and click the play button as shown in the red box in the image below. | ||
|
||
![how to run project](images/run-code.jpg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |