Skip to content

Invalid .tflite Flatbuffer issue for llm inference task on Android CPU #6093

@li-sicong

Description

@li-sicong

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

No

OS Platform and Distribution

Android 15

MediaPipe Tasks SDK version

No response

Task name (e.g. Image classification, Gesture recognition etc.)

LLM inference

Programming Language and version (e.g. C++, Python, Java)

C++

Describe the actual behavior

Got error "ERROR: The model is not a valid Flatbuffer buffer" when passing a gemma3-1b-it-q4.tflite file to the llm_inference_engine_cpu_main example

Describe the expected behaviour

Successfully run llm inference

Standalone code/steps you may have used to try to get what you need

Build command: bazel build --cxxopt=-DABSL_FLAGS_STRIP_NAMES=0 -c opt --config=android_arm64 mediapipe/tasks/cc/genai/inference/c:llm_inference_engine_cpu_main

Other info / Complete Logs

Build OS: ubuntu 24.04

Model: gemma-3-1b-it-q4.tflite downloaded from kaggle: https://www.kaggle.com/models/google/gemma-3/tfLite/gemma3-1b-it-int4

Command
caiman:/data/local/tmp $ ./llm_inference_engine_cpu_main --model_path=./gemma3-1B-it-int4.tflite      

Error log:                                                                                                               
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1758213468.982536   27774 llm_inference_engine_cpu_main.cc:119] Prompt: Write an email
ERROR: The model is not a valid Flatbuffer buffer
E0000 00:00:1758213468.984778   27774 llm_inference_engine_cpu_main.cc:127] Failed to create session: Failed to create engine: INTERNAL: ; RET_CHECK failure (mediapipe/tasks/cc/genai/inference/utils/llm_utils/model_data.cc:334) modelError building tflite model.

Metadata

Metadata

Assignees

Labels

platform:androidIssues with Android as Platformplatform:c++Issues specific to C++ framework in mediapipetype:build/installFor Build and Installation issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions