DEV Community

Andy Mak
Andy Mak

Posted on

Why Gemma 4 E4B Was the Right Fit for Anti-FraudX

Gemma 4 Challenge: Build With Gemma 4 Submission

This is a submission for the Gemma 4 Challenge: Write About Gemma 4

What I Built

Anti-FraudX is a local anti-scam training platform for Hong Kong.

It simulates scam conversations, explains red flags, and helps users practise responses before they face a real fraud attempt. The project is designed for privacy-sensitive, community-friendly deployment, so the experience runs locally through Ollama instead of depending on cloud AI for every interaction.

The system combines role-based simulation, trust scoring, and local model serving. That means users can see not just what a scam looks like, but how it unfolds under pressure.

Gemma 4 E4B is the model that makes this practical. It powers the default reasoning path, victim simulation, recorder analysis, and the broader anti-fraud workflow.

Why I Chose Gemma 4 E4B

Gemma 4 comes in different sizes, and the right one depends on the job.

  • 2B / 4B models are best for tiny edge or browser-style deployments
  • E4B is the right balance for local, privacy-sensitive applications that still need useful reasoning
  • 26B MoE is better when throughput and richer reasoning matter more than footprint
  • 31B Dense is a stronger server-grade option when hardware is available

For Anti-FraudX, the deciding factor was deployment reality. The system needs to run in schools, homes, and community centres, where local execution and practicality matter as much as raw model size. E4B is large enough to support conversation, scoring, and explanation, but still small enough to remain usable on local infrastructure.

That trade-off is important. A model can be technically impressive and still be the wrong choice for a product if it is too expensive, too heavy, or too difficult to deploy where people actually need it.

How I Used Gemma 4

Gemma 4 E4B is used in the parts of the product that matter most:

  • Default model path for general local reasoning
  • Victim agent for realistic responses under scam pressure
  • Recorder agent for analysis, scoring, and feedback generation

That makes Gemma 4 part of the actual learning loop, not just a model sitting behind the UI. The system uses it to simulate behaviour, explain risk in plain language, and help users understand how scams work in real situations.

The runtime configuration is simple:

GEMINI_ENABLED=false
AGENT_MODEL=gemma4:e4b
AGENT_MODEL_VICTIM=gemma4:e4b
AGENT_MODEL_RECORDER=gemma4:e4b
Enter fullscreen mode Exit fullscreen mode

The point of making this configuration visible is reproducibility. If someone wants to understand how the system behaves, the model choice is not hidden in a prompt or a private script. It is explicit in the environment and in the code.

What I Learned

1. Model choice should match deployment

A larger model is not automatically a better product choice. For anti-scam training, usability and local access matter just as much as model capability.

2. The model should be visible in the code

The Gemma 4 choice is reflected in environment variables, backend defaults, Docker configuration, and tests. That makes the setup reproducible and easy to verify.

3. Useful AI systems need more than generation

Anti-FraudX combines Gemma 4 with trust scoring, role-based simulation, local serving, and testable workflows. The value comes from the system design, not only from the base model.

4. Good local AI should serve a real purpose

The most interesting thing about Gemma 4 here is not that it is powerful, but that it is practical. It can support a local training tool that helps users build safer habits before a scam reaches them.

Why This Matters

Scams are emotional, fast-moving, and highly localised. In Hong Kong, people are often targeted through WhatsApp messages, phishing SMS, fake banking pages, fake police calls, romance scams, investment scams, and QR code payment traps.

Gemma 4 makes it possible to build tools that are not only smart, but also deployable, privacy-aware, and useful in real communities. That is why E4B was the right fit for Anti-FraudX.

The broader lesson is that open local models can matter in everyday safety work. When a model is small enough to run locally but capable enough to reason clearly, it becomes useful in places where cloud AI is not the right answer.

Conclusion

Anti-FraudX needed a model that could support local inference, practical reasoning, and multimodal scam education without making deployment too heavy. Gemma 4 E4B fits that job well.

It is not just a model choice for a benchmark. It is the model choice that makes the product usable.

The project demonstrates how open local models can create meaningful safety impact: not by replacing human judgment, but by training it before the moment of risk.

Code

Repository: https://github.com/LamChingFung-2425/Anti-FraudX/tree/andy-v7(gemma-4.0)

Key implementation files:

  • backend/main.py — loads environment variables, applies startup checks, and serves the FastAPI app
  • backend/config.py — centralizes the default model selection for each agent
  • backend/api/chat_routes.py — routes chat requests through the configured local model
  • backend/services/vision_service.py — shared local model setup for analysis paths
  • backend/tests/test_environment.py — checks that the required Gemma 4 model is available
  • backend/tests/test_ollama_direct.py — verifies the direct Ollama path against Gemma 4

Demo

Demo video: https://youtu.be/BLYm_VUpMUI

Live demo: https://anti-fraudx-frontend-5gznvtwxga-uc.a.run.app/

Top comments (0)