| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Welcome to the Java ONNX Embedding & Retrieval-Augmented Generation (RAG) Engine! This project showcases how to integrate modern AI models with legacy Java systems using ONNX. While most AI development today happens in Python, many enterprises still rely heavily on Java ecosystems. This solution bridges that gap, allowing seamless embedding generation and document retrieval using popular transformer models. This code/library was first developed for the InfiniteStack of SciCrop and is now open-sourced as a SciCrop Academy initiative.
# Clone the project
$ git clone https://github.com/Scicrop/javaSentenceBertEmbedding
$ cd javaSentenceBertEmbeddingEnsure Maven is installed and run:
# Build the project and download dependencies
$ mvn clean installBERT Base (Uncased)
python3 -m optimum.exporters.onnx --model bert-base-uncased ./onnx_bert/Sentence-BERT (all-mpnet-base-v2)
python3 -m optimum.exporters.onnx --model all-mpnet-base-v2 ./onnx_mpnet/Place your text files in a directory (e.g., /tmp/sources/). Then run:
# For BERT embeddings
$ java -jar target/BertDataEmbedd.jar /tmp/sources /tmp/embeddings/ /opt/infinitestack/onnx_bert/
# For Sentence-BERT embeddings
$ java -jar target/MpnetDataEmbedd.jar /tmp/sources /tmp/embeddings/ /opt/infinitestack/onnx_mpnet/In the above commands embeddings will be saved as .json files in /tmp/embeddings/.
Run a semantic search query against your embeddings:
$ java -jar target/QueryEngine.jar "how was the computer invented?" /tmp/embeddings/This will output the most relevant document and its similarity score.
In the world of AI-driven solutions, Python dominates. But many large enterprises have mission-critical applications written in Java. Rewriting these in Python is often not feasible due to cost, security, or compliance concerns.
By enabling RAG systems and semantic search in Java:
Contributions are welcome! Feel free to open issues or submit PRs to enhance functionality, support more models, or improve performance.
This project is licensed under the Apache License.
Stay ahead in the AI revolution while leveraging your trusted Java infrastructure. Let's build intelligent, scalable, and enterprise-ready solutions together! 💡💪
| Back | FazBrowse Home | New Git URL |