AIパーソナル・ラーニング
と実践的なガイダンス
サイバーナイフ用ドローイングミラー

MNN-LLM-Android: AndroidのためのMNNマルチモーダル言語モデリング

はじめに

MNN(Mobile Neural Network)は、アリババが開発し、モバイルデバイス向けに最適化された効率的で軽量なディープラーニングフレームワークである。MNNは、モバイルデバイス上での高速推論を可能にするだけでなく、テキスト生成、画像生成、音声処理などのマルチモーダルなタスクもサポートしている、MNNは、Taobao、Tmall、Youku、Nail、Idle Fishなどのアリババアプリケーションに統合されており、ライブストリーミング、ショートビデオキャプチャ、検索レコメンデーション、商品画像検索など、70以上の使用シナリオをカバーしています。


 

機能一覧

  • マルチモーダルサポートテキスト生成、画像生成、音声処理など幅広いタスクに対応。
  • CPU推論の最適化モバイル端末で優れたCPU推論性能を実現。
  • 軽量フレームワークフレームワークは軽量で、モバイル機器のリソース制約に適した設計になっています。
  • 汎用アリババの複数のアプリケーションに統合されており、幅広いビジネスシナリオをカバーしています。
  • オープンソース統合や二次開発を容易にするために、完全なオープンソースコードとドキュメントが提供されています。

 

ヘルプの使用

設置プロセス

  1. ダウンロードとインストールGitHubリポジトリからプロジェクトコードをクローンする。
    git clone https://github.com/alibaba/MNN.git
    cd MNN
    

2. **编译项目**:根据项目提供的README文档,配置编译环境并编译项目。
```bash
mkdir build
cd build
cmake ..
make -j4
  1. Androidアプリケーションへの統合コンパイルしたライブラリファイルをAndroidプロジェクトに統合するにはbuild.gradleファイルで設定する。

使用方法

マルチモーダル機能

MNNは、テキスト生成、画像生成、音声処理など、さまざまなマルチモーダル タスクをサポートしている。以下に、これらの機能の使用例を示す:

  • テキスト生成学習済み言語モデルを使用したテキスト生成。
    import MNN
    interpreter = MNN.Interpreter("text_model.mnn")
    session = interpreter.createSession()
    input_tensor = interpreter.getSessionInput(session)
    # 输入文本进行预处理
    input_data = preprocess_text("输入文本")
    input_tensor.copyFrom(input_data)
    interpreter.runSession(session)
    output_tensor = interpreter.getSessionOutput(session)
    output_data = output_tensor.copyToHostTensor()
    result = postprocess_text(output_data)
    print(result)
    
  • 画像生成訓練済み生成モデルを用いた画像生成。
    import MNN
    interpreter = MNN.Interpreter("image_model.mnn")
    session = interpreter.createSession()
    input_tensor = interpreter.getSessionInput(session)
    # 输入数据进行预处理
    input_data = preprocess_image("输入图像")
    input_tensor.copyFrom(input_data)
    interpreter.runSession(session)
    output_tensor = interpreter.getSessionOutput(session)
    output_data = output_tensor.copyToHostTensor()
    result = postprocess_image(output_data)
    print(result)
    
  • 音響処理訓練済みのオーディオモデルを使用したオーディオ生成または処理。
    import MNN
    interpreter = MNN.Interpreter("audio_model.mnn")
    session = interpreter.createSession()
    input_tensor = interpreter.getSessionInput(session)
    # 输入音频数据进行预处理
    input_data = preprocess_audio("输入音频")
    input_tensor.copyFrom(input_data)
    interpreter.runSession(session)
    output_tensor = interpreter.getSessionOutput(session)
    output_data = output_tensor.copyToHostTensor()
    result = postprocess_audio(output_data)
    print(result)
    

詳しい操作手順

  1. 推論インスタンスの作成MNNモデルを初期化し、推論セッションを作成する。
    import MNN
    interpreter = MNN.Interpreter("model.mnn")
    session = interpreter.createSession()
    
  2. 入力データの前処理モデルの種類に応じて入力データを前処理する。
    input_tensor = interpreter.getSessionInput(session)
    input_data = preprocess_data("输入数据")
    input_tensor.copyFrom(input_data)
    
  3. 経営推論推論のためのセッションを実行します。
    interpreter.runSession(session)
    
  4. 出力データの後処理出力を取得し、後処理する。
    output_tensor = interpreter.getSessionOutput(session)
    output_data = output_tensor.copyToHostTensor()
    result = postprocess_data(output_data)
    print(result)
    
無断転載を禁じます:チーフAIシェアリングサークル " MNN-LLM-Android: AndroidのためのMNNマルチモーダル言語モデリング
ja日本語