-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seq2Seq模型怎么解析输入输出 #2565
Comments
The postprocessing is done in
First of all, To parse the output, first make sure you understand what the output NDArrays are. Find the output token_ids. Then feed it to HuggingFaceTokenizer's decoder, something like the following. String tokenizerJson = "some_directory/gpt2_onnx/tokenizer.json";
HuggingFaceTokenizer tokenizer = HuggingFaceTokenizer.newInstance(Paths.get(tokenizerJson));
System.out.println(tokenizer.decode(tokenIds)); HuggingFaceTokenizer has documents in extensions/tokenizers/README.md. You can also take a look at the source code. |
你这里的token_ids是怎么来的 |
tokenIds is contained in or computed from the output NDArray. |
我怎么从这里解析出来呢 |
This requires certain knowledge of the model output. For example, for gpt2 Or just use search engine to see what the model outputs are. |
刚刚看了一下你的那个输出的NDArray NDList size: 98
0 : (128, 32128) float32
1 : (16, 128, 64) float32
2 : (16, 128, 64) float32
3 : (16, 128, 64) float32
4 : (16, 128, 64) float32
5 : (16, 128, 64) float32
6 : (16, 128, 64) float32
7 : (16, 128, 64) float32
......
91 : (16, 128, 64) float32
92 : (16, 128, 64) float32
93 : (16, 128, 64) float32
94 : (16, 128, 64) float32
95 : (16, 128, 64) float32
96 : (16, 128, 64) float32
97 : (128, 1024) float32 看起来0号是logits,剩下的一直到96都是kv cache,97不太清楚。这应该只是transformer模型的一步的输出,对应一个token。要想生成一串token,还有一个autoregressive loop的过程。看一下 #2637 #2723 里面有如何调用Translator生成text的 |
Seq2Seq模型怎么解析输入输出
我用这个TextTranslator 去处理输入输出,现在得到的NDList list内容如下:
这里怎么把这些数据转换为正确的字符串
下面是Python中进行推理的相关代码
The text was updated successfully, but these errors were encountered: