【问题标题】:Deep Java Library: How to use solr index to answer the question?Deep Java Library:如何使用solr索引答题?
【发布时间】:2023-01-05 03:17:38
【问题描述】:

正如此链接 http://djl.ai/examples/docs/BERT_question_and_answer.html 中所述,我们正在探索用于问答应用程序的 Deep Java 库

 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);
        }
    }

然而,我们想要使用索引(lucene/solr)数据来回答问题,而不是静态的“段落”。我们该怎么做?

【问题讨论】:

    标签: machine-learning deep-learning djl


    【解决方案1】:

    抱歉,这个答案并不完全适用于 Solr,但如果您可以尝试 OpenSearch,希望它能对您有所帮助

    OpenSearch 提供semantic search feature。它在 model serving framework 之上运行文本嵌入 DL 模型,使用 DJL 作为 ML 引擎。此语义搜索功能会将句子转换为密集向量,并在摄取数据时保存到 OpenSearch 索引。然后用户可以使用 KNN 在 OpenSearch 索引中搜索相似的句子。

    OpenSearch 现在不支持 QA 模型,但他们计划支持更多的 NLP 模型。有人对此 QA 功能表现出兴趣,请查看 OpenSearch 论坛上的 [Feedback] Machine Learning Model Serving Framework - Experimental Release。您也可以在那里添加您的要求,更多人询问该功能,OpenSearch 将优先考虑它。

    【讨论】:

      猜你喜欢
      • 2013-01-06
      • 1970-01-01
      • 2012-05-06
      • 1970-01-01
      • 2017-07-06
      • 1970-01-01
      • 2017-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多