djl icon indicating copy to clipboard operation
djl copied to clipboard

ai.djl.repository.zoo.ModelNotFoundException: No model with the specified URI or the matching Input/Output type is found.

Open josephykwang opened this issue 1 year ago • 1 comments

Description

following https://github.com/deepjavalibrary/djl/blob/master/extensions/tokenizers/README.md

for Use DJL HuggingFace model converter (experimental)

public void setup() {
    Criteria<QAInput, String> criteria =
        Criteria.builder()
            .setTypes(QAInput.class, String.class)
            .optModelPath(
                Paths.get(
                    "myproject/src/test/resources/roberta-base-squad2.zip"))
            .optProgress(new ProgressBar())
            .build();
    try {
      model = criteria.loadModel();
    } catch (IOException ex) {
      System.out.println(ex.toString());
    } catch (ModelNotFoundException ex2) {
      System.out.println(ex2.toString());
    } catch (MalformedModelException ex3) {
      System.out.println(ex3.toString());
    }
  }

also tried https://huggingface.co/deepset/roberta-base-squad2. hit with the same issue

Expected Behavior

able to load the model and the following code should run.


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

public void checkInference() {
    assertNotNull(model);

    Predictor<QAInput, String> predictor = model.newPredictor();
    assertNotNull(predictor);

    try {
      String result = predictor.predict(input);
      assertEquals(result, "December 2004");
    } catch (TranslateException ex) {

    }
  }

Error Message

(Paste the complete error message, including stack trace.)

How to Reproduce?

(If you developed your own code, please provide a short script that reproduces the error. For existing examples, please provide link.)

Steps to reproduce

run the test

What have you tried to solve it?

tried different model. tried unzip and used bert-base-cased-squad2.pt for path

josephykwang avatar Sep 20 '23 00:09 josephykwang

You need to provide a translator in the criteria. This may depend on the specific model you are using. You can try using our MxBertQATranslator, PtBertQATranslator, or hf tokenizer QuestionAnswerTranslator as a reference

zachgk avatar Oct 06 '23 20:10 zachgk