TorchScript format problem: ai.djl.engine.EngineException: forward() is missing value for argument 'attention_mask' #3538
Replies: 5 comments 5 replies
-
Can you provide your script that trace the model? The model takes multiple inputs, but your |
Beta Was this translation helpful? Give feedback.
-
This is summarization model, it's a bit complicated, you need write a loop to generate all tokens. You need to take a look our TextGeneration example: https://github.com/deepjavalibrary/djl/blob/master/examples/src/main/java/ai/djl/examples/inference/nlp/TextGeneration.java Here is how I trace the model:
And here is a naive implementation in java, I use a simple greedy search and hard-code everything (max_token, eos_token_id, bos_token_id), they should read from
Here is java code:
|
Beta Was this translation helpful? Give feedback.
-
@frankfliu thanks for great explanation. Got following Sumarization from Java:
But from python, I got: Question: does this mean that the TorchScript version (used in Java code) is still unable to generate the proper output? ...or is this because of what you said:
-I looked at https://github.com/deepjavalibrary/djl/blob/master/examples/src/main/java/ai/djl/examples/inference/nlp/TextGeneration.java |
Beta Was this translation helpful? Give feedback.
-
Anyone? |
Beta Was this translation helpful? Give feedback.
-
The text generation task is pretty complicated, we don't have builtin java code that can handle common models. My recommendation is to take a look at our model server solution: https://docs.djl.ai/master/docs/serving/serving/docs/lmi/index.html |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Scenario:
HuggingFaceTokenizer tokenizer = HuggingFaceTokenizer.newInstance(Paths.get('/pathToTheLocation/with_tokenizer_json_etc'));
-loaded the model as follows:
-Translator creation:
All this causes the following error:
Beta Was this translation helpful? Give feedback.
All reactions