|
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 |
3 | 2 |
|
| 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/). |
4 | 4 |
|
| 5 | +## Installation |
5 | 6 |
|
| 7 | +Open the project folder in a Java IDE (recommended: IntelliJ IDEA Community) with Gradle support and build the project. |
6 | 8 |
|
7 |
| -## Installation: |
8 |
| -Open Project folder in Java IDE (`Recommended: IntelliJ IDEA Community`) with gradle support and Build the project |
| 9 | +### Requirements |
9 | 10 |
|
| 11 | +1. Java Development Kit (JDK) version 17 |
| 12 | +2. Gradle version 8.9 |
10 | 13 |
|
11 |
| -### Requirements: |
12 |
| -1. Java Development Kit JDK version: 11 |
13 |
| -2. Gradle version 7+ |
| 14 | +### Download Files |
14 | 15 |
|
15 |
| -### Download files |
| 16 | +These files are required to run the project: |
16 | 17 |
|
17 |
| -These files are required to run the project |
18 |
| - |
19 |
| -1. ONNX model |
| 18 | +1. ONNX model |
20 | 19 | 2. `tokenizer.json` file
|
21 | 20 |
|
22 |
| -### Convert the ONNX model |
| 21 | +### Convert the ONNX Model |
23 | 22 |
|
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. |
25 | 24 |
|
26 |
| - |
| 25 | + |
27 | 26 |
|
| 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).) |
28 | 28 |
|
| 29 | +After running one of the above codes, your ONNX model will be saved in the `onnx/` folder. |
29 | 30 |
|
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 |
31 | 32 |
|
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). |
33 | 34 |
|
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** |
37 | 36 |
|
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. |
40 | 38 |
|
41 | 39 | 
|
42 | 40 |
|
| 41 | +## Building the Project |
43 | 42 |
|
44 |
| -## Building project |
45 |
| -Build the project using This button |
| 43 | +Build the project using the button shown below. |
46 | 44 |
|
47 | 45 | 
|
48 | 46 |
|
49 | 47 | ## Run the Code
|
50 | 48 |
|
51 |
| -Open the `Main.java` file and click the play button as shown in the red box in the below image |
52 |
| - |
| 49 | +Open the `Main.java` file and click the play button as shown in the red box in the image below. |
| 50 | + |
| 51 | + |
0 commit comments