0

We are exploring Deep Java Library for Question & Answer application as mentioned in this link http://djl.ai/examples/docs/BERT_question_and_answer.html

 public static String predict() throws IOException, TranslateException, ModelException {
    //        String question = "How is the weather";
    //        String paragraph = "The weather is nice, it is beautiful day";
    String question = "When did BBC Japan start broadcasting?";
    String paragraph =
            "BBC Japan was a general entertainment Channel. "
                    + "Which operated between December 2004 and April 2006. "
                    + "It ceased operations after its Japanese distributor folded.";

    QAInput input = new QAInput(question, paragraph);
    logger.info("Paragraph: {}", input.getParagraph());
    logger.info("Question: {}", input.getQuestion());

    Criteria<QAInput, String> criteria =
            Criteria.builder()
                    .optApplication(Application.NLP.QUESTION_ANSWER)
                    .setTypes(QAInput.class, String.class)
                    .optFilter("backbone", "bert")
                    .optEngine(Engine.getDefaultEngineName())
                    .optProgress(new ProgressBar())
                    .build();

    try (ZooModel<QAInput, String> model = criteria.loadModel()) {
        try (Predictor<QAInput, String> predictor = model.newPredictor()) {
            return predictor.predict(input);
        }
    }

However instead of a static "paragraph", we want to use index (lucene/solr) data to answer the question. How can we do it?

user989010
  • 137
  • 1
  • 16

1 Answers1

0

Sorry this answer is not exactly for Solr, but hope it can help you if you are ok to try OpenSearch

OpenSearch provides semantic search feature. It runs text embedding DL model on top of model serving framework which uses DJL as ML engine. This semantic search feature will convert sentence to dense vector and save to OpenSearch index when ingest data. Then user can use KNN to search similar sentences in OpenSearch index.

OpenSearch doesn't support QA model now, but they have plan to support more NLP models. Someone shows interest on this QA feature, check [Feedback] Machine Learning Model Serving Framework - Experimental Release on OpenSearch forum. You can also add your requirement there, more people asking the feature, OpenSearch will prioritize it.