onnxruntime-inference-examples use qwen error
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- android, java
- Domain
- machine-learning, mobile-dev
Research direction
Start with mobile/examples/phi-3/android and inspect MainActivity.java, SimpleGenAI.generate, and the model files expected in the app's external-files directory. Compare the Qwen model inputs and past_key_values dimensions with the Phi-3 example and verify the tokenizer and model assets used by the demo. Done means the documented model setup runs without the reported tokenizer or dimension errors.
Written by the indexing model from the issue text.
Description
I use the demo which is onnx-runtime/onnxruntime-inference-examples/mobile/examples/phi-3/android , but I use the qwen model which is https://huggingface.co/onnx-community/Qwen2.5-0.5B-Instruct/tree/main to instead of the phi-3. Then I push the model_uint8.onnx file to the android phone. When I run the process,it occur some error below:
01-10 18:05:47.205 1957 2157 D AwareLog: iawared: WorkingsetPauseCollect ai.onnxruntime.genai.demo/.MainActivity
01-10 18:05:48.120 24819 24961 W System.err: ai.onnxruntime.genai.GenAIException: Failed to create Tokenizer.
01-10 18:05:48.120 24819 24961 W System.err: at ai.onnxruntime.genai.SimpleGenAI.generate(SimpleGenAI.java:103)
01-10 18:05:48.120 24819 24961 W System.err: at ai.onnxruntime.genai.demo.MainActivity$2$1.run(MainActivity.java:229)
01-10 18:05:48.120 24819 24961 W System.err: at java.lang.Thread.run(Thread.java:933)
01-10 18:05:48.120 24819 24961 W System.err: Caused by: ai.onnxruntime.genai.GenAIException: Token generation loop failed.
01-10 18:05:48.120 24819 24961 W System.err: at ai.onnxruntime.genai.SimpleGenAI.generate(SimpleGenAI.java:97)
01-10 18:05:48.120 24819 24961 W System.err: ... 2 more
01-10 18:05:48.120 24819 24961 W System.err: Caused by: ai.onnxruntime.genai.GenAIException: Got invalid dimensions for input: past_key_values.0.key for the following indices
01-10 18:05:48.120 24819 24961 W System.err: index: 3 Got: 14 Expected: 64
01-10 18:05:48.120 24819 24961 W System.err: Please fix either the inputs/outputs or the model.
01-10 18:05:48.120 24819 24961 W System.err: at ai.onnxruntime.genai.Generator.appendTokenSequences(Native Method)
01-10 18:05:48.120 24819 24961 W System.err: at ai.onnxruntime.genai.Generator.appendTokenSequences(Generator.java:93)
01-10 18:05:48.120 24819 24961 W System.err: at ai.onnxruntime.genai.SimpleGenAI.generate(SimpleGenAI.java:91)
01-10 18:05:48.120 24819 24961 W System.err: ... 2 more
01-10 18:05:48.120 24819 24961 D onnxActivity: GenAIException..
Here is the code :
`try {
Log.d(TAG, "start generator result");
SimpleGenAI generator = new SimpleGenAI(getExternalFilesDir(null).getPath());
GeneratorParams params = generator.createGeneratorParams();
params.setSearchOption("max_length", 20);
ByteBuffer data = ByteBuffer.allocateDirect(4 * Float.BYTES).order(ByteOrder.nativeOrder());
FloatBuffer floatBuffer = data.asFloatBuffer();
floatBuffer.put(new float[] {1.0f, 2.0f, 3.0f, 4.0f});
Tensor tensor = new Tensor(data, new long[]{64, 64}, Tensor.ElementType.uint8);
params.setInput(promptQuestion, tensor);
String result =
generator.generate(params, promptQuestion, null);
Log.d(TAG, "Result: " + result);
runOnUiThread(() -> {
generatedTV.setText(result);
sendMsgIB.setEnabled(true);
sendMsgIB.setAlpha(1.0f);
});
} catch (GenAIException e) {
e.printStackTrace();
Log.d(TAG, "GenAIException..");
}`
I don't know how to fix this error. Could anyone help me to fix this error? Thanks a lot.
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 418
- PR merge metrics
- No merged PRs in 30d
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/onnxruntime-inference-examples
-
Replace deprecated light-server with lite-server for onnxruntime-webPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Minor: typoPossibly taken @Hashim1999164 claimed this 74 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
microsoft/onnxruntime-inference-examples#124 · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
-
Package "onnxruntime-react-native" does not contain a valid config pluginPossibly taken @reginaldalfret claimed this 32 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in microsoft/onnxruntime-inference-examples
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
aristocratos/btop#1945 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
boykopovar/AnyPS5#11291 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
k2-fsa/sherpa-onnx#4100 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Mod: Part Design Topic: User Interface
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day