Hello Inanc,
TM_CATEGORIZE_KNN requires exactly one document. So no improvement options on that side.
But you can approve your Java and SQLScript coding to avoid the round trips between your Java application and the stored procedure. Instead of reading all documents (texts) in the Java application and then call for each document the stored procedure you can push down that to a procedure. Read the documents in the procedure and do the classification.
For further optimization check the options how you can specify the document for the function (Advanced Data Processing: TM_CATEGORIZE_KNN - SAP HANA SQL and System Views Reference - SAP Library).
Regards,
Florian