Skip to content

Commit 36aa0c9

Browse files
committed
build: upgrade gradle, dependencies and java
Upgraded Gradle to version 8.9 updated dependencies upgraded Java from version 11 to 17
1 parent 3a26e6b commit 36aa0c9

File tree

7 files changed

+145
-133
lines changed

7 files changed

+145
-133
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ bin/
4343
.vscode/
4444

4545
### Mac OS ###
46-
.DS_Store
46+
.DS_Store
47+
48+
# python
49+
venv

.idea/misc.xml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 103 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
1-
# Run HuggingFace NER (NLP) Model on Java using ONNX Runtime and DJL
2-
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/)
1+
# Run HuggingFace NER (NLP) Model on Java using ONNX Runtime and DJL
32

3+
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/).
44

5+
## Installation
56

7+
Open the project folder in a Java IDE (recommended: IntelliJ IDEA Community) with Gradle support and build the project.
68

7-
## Installation:
8-
Open Project folder in Java IDE (`Recommended: IntelliJ IDEA Community`) with gradle support and Build the project
9+
### Requirements
910

11+
1. Java Development Kit (JDK) version 17
12+
2. Gradle version 8.9
1013

11-
### Requirements:
12-
1. Java Development Kit JDK version: 11
13-
2. Gradle version 7+
14+
### Download Files
1415

15-
### Download files
16+
These files are required to run the project:
1617

17-
These files are required to run the project
18-
19-
1. ONNX model
18+
1. ONNX model
2019
2. `tokenizer.json` file
2120

22-
### Convert the ONNX model
21+
### Convert the ONNX Model
2322

24-
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
23+
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.
2524

26-
![run colab code cell](images/run-colab.jpeg)
25+
![run colab code cell](images/run-colab.jpeg)
2726

27+
(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).)
2828

29+
After running one of the above codes, your ONNX model will be saved in the `onnx/` folder.
2930

30-
(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))
31+
### Download tokenizer.json
3132

32-
after running the one of above codes your onnx model will be saved in `onnx/` folder.
33+
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).
3334

34-
### Download tokenizer.json
35-
Tokenzer file `tokenizer.json` was taken from this [huggingface repo](https://huggingface.co/xlm-roberta-large-finetuned-conll03-english)
36-
Download the `tokenizer.json` from the [link](https://huggingface.co/xlm-roberta-large-finetuned-conll03-english/raw/main/tokenizer.json)
35+
**Move Files**
3736

38-
**move files**
39-
Copy files created from above two stesp into `raw-files` directory as shown in the below image
37+
Copy the files created from the above steps into the `raw-files` directory as shown in the image below.
4038

4139
![raw-files path](images/model-location.png)
4240

41+
## Building the Project
4342

44-
## Building project
45-
Build the project using This button
43+
Build the project using the button shown below.
4644

4745
![how to build project](images/building-project.jpg)
4846

4947
## Run the Code
5048

51-
Open the `Main.java` file and click the play button as shown in the red box in the below image
52-
![how to run project](images/run-code.jpg)
49+
Open the `Main.java` file and click the play button as shown in the red box in the image below.
50+
51+
![how to run project](images/run-code.jpg)

build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
plugins {
22
id 'java'
3+
id 'application'
4+
}
5+
6+
application {
7+
mainClass.set('dev.ahwar.Main')
38
}
49

510
group 'dev.ahwar'
@@ -11,8 +16,8 @@ repositories {
1116

1217
dependencies {
1318
implementation 'com.microsoft.onnxruntime:onnxruntime:1.13.1'
14-
implementation "ai.djl.huggingface:tokenizers:0.19.0"
15-
implementation 'org.slf4j:slf4j-api:2.0.3'
19+
implementation "ai.djl.huggingface:tokenizers:0.29.0"
20+
implementation 'org.slf4j:slf4j-api:2.0.13'
1621
}
1722

1823
test {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

100644100755
File mode changed.

0 commit comments

Comments
 (0)