Skip to content
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

[Example] Mllama: basic example with llama-3.2-vision. #169

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

q82419
Copy link
Member

@q82419 q82419 commented Jan 21, 2025

No description provided.

Copy link
Member

juntao commented Jan 21, 2025

Hello, I am a code review agent on flows.network. Here are my reviews of changed source code files in this PR.


wasmedge-ggml/mllama/Cargo.toml

Potential issues

  1. Missing dependency for handling image data, which is crucial for llama-3.2-vision processing.
  2. wasmedge-wasi-nn version "0.8.0" may not support the specific functionalities required by llama-3.2-vision; consider updating to a compatible version.
  3. No logging or error handling mechanism specified, which can lead to silent failures and make debugging difficult.

Summary of changes

    • Added a new Cargo.toml file for the package configuration.
  • Defined package metadata including name, version, and edition.
  • Specified dependencies: serde_json and wasmedge-wasi-nn.

wasmedge-ggml/mllama/src/main.rs

Potential issues

  1. Issue 1: read_image_path() lacks an error message in the expect call, which could lead to confusing panic messages.

    • Explanation: The expect call in read_image_path() should have a descriptive error message, e.g., .expect("Failed to read image path").
  2. Issue 2: Unhandled potential errors in serde_json::from_str calls within get_options_from_env().

    • Explanation: Using .unwrap() can cause the program to panic if the JSON parsing fails. It's better to handle these errors gracefully, e.g., using .expect("Failed to parse JSON value").
  3. Issue 3: Hardcoded tensor index in set_data_to_context and get_data_from_context.

    • Explanation: Using hardcoded indices (e.g., 0 for input/output) can lead to maintenance issues if the model's inputs/outputs change. It's safer to define constants or use a more dynamic approach.

Summary of changes

  • Key Changes:
  • Graph and Context Initialization: Introduced a comprehensive setup for graph building and context initialization using environment variables and command-line arguments, enabling flexibility in model parameters and options.
  • Input Handling: Implemented functions to read user input interactively, including support for image paths, formatting prompts accordingly for the mLLama chat system.
  • Error Handling and Output Retrieval: Added robust error handling during computation and defined methods to fetch and print outputs from the execution context.

wasmedge-ggml/mllama/wasmedge-ggml-mllama.wasm

Potential issues

  1. Potential Out-of-Bounds Access: The code uses hardcoded indices (e.g., A�j!�) and assumes certain structures without bounds checking, which can lead to out-of-bounds access if the data size or structure changes.

  2. Magic Numbers Abundant: There are numerous magic numbers (, , , etc.) used throughout the code, making it difficult to understand their significance and purpose without clear documentation.

  3. Lack of Error Handling: The code does not include comprehensive error handling after function calls or operations, which can lead to silent failures or undefined behavior if a step fails.

Summary of changes

  • • Added support for llama-3.2-vision model integration in the basic example.
  • Updated documentation to reflect changes related to the new model.
  • Modified configuration settings to accommodate llama-3.2-vision specific parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants