Currently, KotlinDL does not offer support for NLP/LLM functionalities. So, to continue with this task, you will need to use external libraries or tools for tokenization. I am not personally familiar with any pre-built solutions in Java/Kotlin, but you can explore some potential approaches from the following sources:
• an external tokenizer for LLama2 as an external binary; refer to this link:
https://github.com/mukel/llama2.java.
• Another option involves using a tokenizer integrated into a custom ONNX operation, as this repository demonstrates:
https://github.com/oracle/sd4j/tree/main.