-
Notifications
You must be signed in to change notification settings - Fork 193
feat : Add Support of Qwen2.5Omni Model and MiniCPM-o-4_5 Model #612
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
base: main
Are you sure you want to change the base?
Changes from 15 commits
a04ef3e
c9333ab
e959822
0672432
927f7eb
d2e6b36
48c259a
e976d11
224d68e
d2d5c09
c4f2306
a235a13
eeac11f
adc3b64
674f97c
e1ba448
8c0cda7
af574ae
06b754c
5676edc
4baacd3
3bdf6e0
571b93d
d7c1b30
f185440
289b74b
45c2fb7
14ce9cd
027b0df
f6aee67
4fd3d34
57ef372
7f78efa
7f5d7d9
5d13411
f10363c
c366ffc
506d61a
a420a05
9d33d0d
fd16226
a6a993a
a78e3a0
9453134
5560096
e78ea11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| add_executable(mllm-qwen2_5-omni-text-runner text_infer.cpp) | ||
| target_link_libraries(mllm-qwen2_5-omni-text-runner PRIVATE MllmRT MllmCPUBackend) | ||
| target_include_directories(mllm-qwen2_5-omni-text-runner PRIVATE ${MLLM_INCLUDE_DIR}) | ||
|
|
||
| add_executable(mllm-qwen2_5-omni-image-runner image_infer.cpp) | ||
| target_link_libraries(mllm-qwen2_5-omni-image-runner PRIVATE MllmRT MllmCPUBackend) | ||
| target_include_directories(mllm-qwen2_5-omni-image-runner PRIVATE ${MLLM_INCLUDE_DIR}) | ||
|
|
||
| add_executable(mllm-qwen2_5-omni-audio-runner audio_infer.cpp) | ||
| target_link_libraries(mllm-qwen2_5-omni-audio-runner PRIVATE MllmRT MllmCPUBackend) | ||
| target_include_directories(mllm-qwen2_5-omni-audio-runner PRIVATE ${MLLM_INCLUDE_DIR}) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,84 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| // Copyright (c) MLLM Team. | ||||||||||||||||||||||||||||||||||||||||||||||
| // Licensed under the MIT License. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| #include <iostream> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <fmt/core.h> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <mllm/mllm.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <mllm/models/qwen2_5omni/configuration_qwen2_5omni.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <mllm/models/qwen2_5omni/modeling_qwen2_5omni.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <mllm/models/qwen2_5omni/tokenization_qwen2_5omni.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| using mllm::Argparse; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| MLLM_MAIN({ | ||||||||||||||||||||||||||||||||||||||||||||||
| mllm::Logger::level() = mllm::LogLevel::kError; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| auto& help = Argparse::add<bool>("-h|--help").help("Show help message"); | ||||||||||||||||||||||||||||||||||||||||||||||
| auto& model_path = Argparse::add<std::string>("-m|--model_path").help("Model path").required(true); | ||||||||||||||||||||||||||||||||||||||||||||||
| auto& model_version = Argparse::add<std::string>("-mv|--model_version").help("Model version").required(true); | ||||||||||||||||||||||||||||||||||||||||||||||
| auto& tokenizer_path = Argparse::add<std::string>("-t|--tokenizer_path").help("Tokenizer directory").required(true); | ||||||||||||||||||||||||||||||||||||||||||||||
| auto& config_path = Argparse::add<std::string>("-c|--config_path").help("Config path").required(true); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Argparse::parse(argc, argv); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| mllm::ModelFileVersion file_version = mllm::ModelFileVersion::kV1; | ||||||||||||||||||||||||||||||||||||||||||||||
| if (model_version.get() == "v1") { | ||||||||||||||||||||||||||||||||||||||||||||||
| file_version = mllm::ModelFileVersion::kV1; | ||||||||||||||||||||||||||||||||||||||||||||||
| } else if (model_version.get() == "v2") { | ||||||||||||||||||||||||||||||||||||||||||||||
| file_version = mllm::ModelFileVersion::kV2; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if (help.isSet()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| Argparse::printHelp(); | ||||||||||||||||||||||||||||||||||||||||||||||
| mllm::shutdownContext(); | ||||||||||||||||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| auto qwen2_5omni_cfg = mllm::models::qwen2_5omni::Qwen2_5OmniConfig(config_path.get()); | ||||||||||||||||||||||||||||||||||||||||||||||
| auto qwen2_5omni_tokenizer = mllm::models::qwen2_5omni::Qwen2_5OmniTokenizer(tokenizer_path.get()); | ||||||||||||||||||||||||||||||||||||||||||||||
| auto qwen2_5omni = mllm::models::qwen2_5omni::Qwen2_5OmniForCausalLM(qwen2_5omni_cfg); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| auto param = mllm::load(model_path.get(), file_version); | ||||||||||||||||||||||||||||||||||||||||||||||
| qwen2_5omni.thinker_.load(param); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("\n{:*^60}\n", " Qwen2.5-Omni Audio CLI "); | ||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("Enter 'exit' or 'quit' to end the session\n\n"); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| std::string audio_path; | ||||||||||||||||||||||||||||||||||||||||||||||
| std::string prompt_text; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("Audio path (or 'exit/quit'): "); | ||||||||||||||||||||||||||||||||||||||||||||||
| //std::getline(std::cin, audio_path); | ||||||||||||||||||||||||||||||||||||||||||||||
| //if (audio_path == "exit" || audio_path == "quit") { return 0; } | ||||||||||||||||||||||||||||||||||||||||||||||
| audio_path = ""; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("Prompt text: "); | ||||||||||||||||||||||||||||||||||||||||||||||
| //std::getline(std::cin, prompt_text); | ||||||||||||||||||||||||||||||||||||||||||||||
| //if (prompt_text.empty()) { prompt_text = "Please describe the audio."; } | ||||||||||||||||||||||||||||||||||||||||||||||
| prompt_text = ""; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cd examples/qwen2_5omni && wc -l audio_infer.cppRepository: UbiquitousLearning/mllm Length of output: 190 🏁 Script executed: head -70 examples/qwen2_5omni/audio_infer.cpp | tail -30Repository: UbiquitousLearning/mllm Length of output: 1202 🏁 Script executed: cat -n examples/qwen2_5omni/audio_infer.cpp | sed -n '40,70p'Repository: UbiquitousLearning/mllm Length of output: 1510 🏁 Script executed: rg -A 10 "convertAudioMessage" examples/qwen2_5omni/ --type cppRepository: UbiquitousLearning/mllm Length of output: 1132 🏁 Script executed: rg -B 5 -A 10 "audio_file_path" examples/qwen2_5omni/ --type cpp | head -50Repository: UbiquitousLearning/mllm Length of output: 1466 🏁 Script executed: fd "\.hpp$|\.h$" examples/qwen2_5omni --type fRepository: UbiquitousLearning/mllm Length of output: 49 🏁 Script executed: rg "convertAudioMessage" --type cpp --type hpp | head -20Repository: UbiquitousLearning/mllm Length of output: 94 🏁 Script executed: find . -type f -name "*.h" -o -name "*.hpp" | grep -E "(qwen|tokenizer)" | head -20Repository: UbiquitousLearning/mllm Length of output: 1152 🏁 Script executed: rg "convertAudioMessage" -A 15 --max-count 5Repository: UbiquitousLearning/mllm Length of output: 3215 🏁 Script executed: rg "audio_file_path" -B 5 -A 10 --max-count 10Repository: UbiquitousLearning/mllm Length of output: 16860 🏁 Script executed: rg "MLLM_ERROR_EXIT" -B 2 -A 2 --max-count 5Repository: UbiquitousLearning/mllm Length of output: 50379 🏁 Script executed: rg "readWAV" -B 3 -A 8 | head -40Repository: UbiquitousLearning/mllm Length of output: 3737 Enable interactive input for the example to work as intended. The example currently has input hardcoded to empty strings, causing Restore the commented Suggested fix (restore interactive input)- fmt::print("Audio path (or 'exit/quit'): ");
- //std::getline(std::cin, audio_path);
- //if (audio_path == "exit" || audio_path == "quit") { return 0; }
- audio_path = "";
-
- fmt::print("Prompt text: ");
- //std::getline(std::cin, prompt_text);
- //if (prompt_text.empty()) { prompt_text = "Please describe the audio."; }
- prompt_text = "";
+ fmt::print("Audio path (or 'exit/quit'): ");
+ std::getline(std::cin, audio_path);
+ if (audio_path == "exit" || audio_path == "quit") { return 0; }
+
+ fmt::print("Prompt text: ");
+ std::getline(std::cin, prompt_text);
+ if (prompt_text.empty()) { prompt_text = "Please describe the audio."; }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("Processing...\n"); | ||||||||||||||||||||||||||||||||||||||||||||||
| auto inputs = qwen2_5omni_tokenizer.convertAudioMessage({.prompt = prompt_text, .audio_file_path = audio_path}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("\nResponse: "); | ||||||||||||||||||||||||||||||||||||||||||||||
| qwen2_5omni.streamGenerate(inputs, | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| {"do_sample", mllm::AnyValue(false)}, | ||||||||||||||||||||||||||||||||||||||||||||||
| {"max_length", mllm::AnyValue(qwen2_5omni_cfg.max_cache_length)}, | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| [&](int64_t token_id) { | ||||||||||||||||||||||||||||||||||||||||||||||
| auto str = qwen2_5omni_tokenizer.detokenize(token_id); | ||||||||||||||||||||||||||||||||||||||||||||||
| std::wcout << str << std::flush; | ||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("\n{}\n", std::string(60, '-')); | ||||||||||||||||||||||||||||||||||||||||||||||
| } catch (const std::exception& e) { fmt::print("\nError: {}\n{}\n", e.what(), std::string(60, '-')); } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| qwen2_5omni.perfSummary(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| mllm::print("\n"); | ||||||||||||||||||||||||||||||||||||||||||||||
| mllm::memoryReport(); | ||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate
--model_versioninstead of silently falling back to v1.An unknown value currently defaults to v1, which can load the wrong format and fail in confusing ways. Consider rejecting unsupported values explicitly.
Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents