开发者用 Gemma 2 2B 打造本地马哈拉施特拉邦菜谱生成器 Mahaswad
What I Built
开发者基于 Google 开源模型 Gemma 2 2B(gemma2:2b)通过 Ollama 本地运行,构建了 100% 离线、注重隐私的 AI 菜谱生成器 Mahaswad,专攻马哈拉施特拉邦传统菜肴。
I built Mahaswad (महासवाद), a 100% local, privacy-friendly AI recipe generator dedicated to traditional Maharashtrian cuisine.
I built this for my friend who loves authentic home-cooked regional food—like Puneri Misal, Pithla Bhakri, Kolhapuri Tambda Rassa, or Kanda Poha. However, whenever he opens his kitchen pantry and sees a random assortment of ingredients, he struggles to quickly match them to an authentic traditional dish without wading through ad-heavy online recipe sites or generic AI tools that don't understand local culinary nuances.
Mahaswad solves this by letting him input whatever ingredients he has on hand (e.g., poha, peanuts, onions, turmeric) and instantly generates:
An authentic dish match categorized across four distinct regional styles (Puneri, Kolhapuri, Malvani, and Vidarbha).
Full step-by-step cooking instructions with required pantry additions.
Output options in either English or native Marathi (Devanagari script).
A specialized Chef Note detailing traditional regional serving context.
Best of all, it runs completely offline on CPU hardware with zero subscription costs or cloud APIs!
Demo
Code
Check out the full open-source repository on GitHub:
Plaintext
Mahaswad/
├── app.py # Streamlit interactive UI
├── main.py # FastAPI backend & Ollama integration
├── requirements.txt # Dependencies (FastAPI, Streamlit, Ollama, etc.)
├── run.sh # Launch script (Linux/macOS)
└── run.bat # Launch script (Windows)
GitHub Repo: onkarjadhav5598/Mahaswad
How I Built It
The main goal of Mahaswad was to deliver high performance on everyday consumer hardware (Intel i7 8th Gen CPU, 16 GB RAM, no discrete GPU).
Open-Source Model Engine: Powered by Google's Gemma 2 2B (gemma2:2b), running locally through Ollama.
FastAPI Backend (main.py): Exposes a RESTful /generate-recipe endpoint that structures regional chef system prompts, regulates inference parameters (temperature=0.6, num_predict=1024), and uses regex cleaning to strip out scratchpad reasoning tags before serving structured JSON responses.
Streamlit Frontend (app.py): Provides a clean, responsive web interface for entering ingredients, selecting meal categories (Breakfast, Main Course, Snack, Dessert), choosing regional styles, and toggling output languages.
System Architecture
Plaintext
┌─────────────────────┐ HTTP POST ┌──────────────────────┐
│ Streamlit UI │ ──────────────────────► │ FastAPI Backend │
│ (app.py) │ /generate-recipe │ (main.py) │
│ localhost:8501 │ ◄────────────────────── │ localhost:8000 │
└─────────────────────┘ RecipeResponse └──────────┬───────────┘
│ ollama.chat()
▼
┌──────────────────────┐
│ Ollama (local) │
│ gemma2:2b │
│ localhost:11434 │
└──────────────────────┘
Why Does Open Innovation Matter?
Building with open-weight models like Gemma 2 2B made this project possible in ways closed commercial APIs never could:
Zero Operating Costs & True Accessibility: Using closed-source AI APIs requires credit cards, usage caps, and per-token fees. Open-weight models running locally allow anyone to build and run AI applications indefinitely for free.
Complete Data Privacy: A cooking assistant shouldn't need to ping remote cloud servers or collect telemetry on everyday user habits. Everything remains on-device.
Hyper-Local Contextual Freedom: Open innovation gives developers full control over system instructions, custom prompt engineering, and local regional context—allowing Gemma 2B to accurately capture niche regional traditions (like Puneri, Kolhapuri, Malvani, and Vidarbha cooking styles) without cloud safety filters over-refusing cultural terminology.
Prize Categories
Best Use of Gemma ($200) — Powered entirely by Google's open-weight gemma2:2b model running locally via Ollama.
来源:Google AI:DEV 作者专属(RSS) · dev.to
