A web-based implementation of Google's Gemma language model using MediaPipe Tasks for GenAI.
This project demonstrates how to run Google's Gemma language model directly in the browser using WebAssembly. It provides a simple interface for text generation using the Gemma 2B model.
- Browser-based inference using WebAssembly
- No server required - runs completely client-side
- Simple text input interface
- Real-time text generation
- Modern web browser with WebAssembly support
- Kaggle account (for model download)
-
Clone the repository:
git clone https://github.com/atomostechhq/google-gemma-for-web-exp.git cd google-gemma-for-web-exp
-
Download the model:
- Follow the instructions in
assets/instructions.txt
to:- Set up Kaggle authentication
- Download the model file
- Place it in the correct location
- Follow the instructions in
-
Serve the application:
- Use any HTTP server to serve the files locally
- For example, with Python:
python3 -m http.server 8000
- Or with Node.js:
npx http-server
-
Access the application:
- Open your browser and navigate to
http://localhost:8000
- Open your browser and navigate to
- Enter your text prompt in the input field
- Click "Get Response" to generate text
- The model will stream its response in real-time
- Uses MediaPipe Tasks for GenAI
- Implements the Gemma 2B model quantized to INT8
- Runs inference directly in the browser using WebAssembly
- Initial model loading may take some time depending on your internet connection
- Performance depends on your device's capabilities
This project uses Google's Gemma model which is subject to its own license terms. Please refer to the Gemma documentation for details.