0

I want to build a simple java application using DJL that is first trained on a relatively large number of text documents. Then I want to model to be saved. After this I want to be able to answer multiple questions that will be answered based on the text document contents that I used for training.

All the examples that I find show how to use QAInput where I have one question and one paragraph from which the answered should be derived. Instead I want to first add multiple paragraphs (documents). Then I want to ask multiple questions. Psudo code

String text1, text2, .... , text1000 model.addContext(text1); model.addContext(text2); .... model.addContext(text1000);

String question1; String question2;

String answere1 = translator.predict(question1) String answere2 = translator.predict(question1)

Every time I search I get the following code

BertTranslator translator = new BertTranslator();
Criteria<QAInput, String> criteria = Criteria.builder()
            .setTypes(QAInput.class, String.class)
            .optModelPath(Paths.get("src/main/resources/trace_cased_bertqa.pt"))
            .optTranslator(translator)
            .optProgress(new ProgressBar()).build();

ZooModel<QAInput, String> model = criteria.loadModel();
    
    try (Predictor<QAInput, String> predictor = model.newPredictor(translator)) {

predictor.predict(input); }

Here the input consists of Question and Paragraph

0 Answers0