DEV Community

Andy Mak
Andy Mak

Posted on

Anti-FraudX: Local Scam Defense Training with Gemma 4 E4B

Gemma 4 Challenge: Build With Gemma 4 Submission

This is a submission for the Gemma 4 Challenge: Build with Gemma 4

What I Built

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

Instead of only showing static scam warnings, it lets people practise scam detection through interactive AI conversations, RPG-style training, and automated multi-agent simulations. The idea is to turn anti-fraud education into something people can rehearse, not just read about.

The project focuses on a very real local problem: scams are fast, emotional, and often happen through familiar channels such as WhatsApp messages, phishing SMS, fake banking pages, fake police calls, romance scams, investment scams, and QR code payment traps. Anti-FraudX turns those risks into practice scenarios so users can see how pressure, urgency, trust, and manipulation appear in real conversations.

The system includes:

  • an RPG-style training mode for scenario-based learning
  • a personal chat mode where users can test their reactions
  • an auto simulation mode with scammer, victim, expert, and recorder agents
  • local model serving through Ollama for privacy-sensitive use
  • a workflow that can be deployed in schools, homes, and community centres

The goal is to make anti-fraud education more practical, more repeatable, and more accessible for people who need it most.

Demo

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

A strong walkthrough should show:

  1. a Hong Kong scam scenario, such as a suspicious message or fake payment request
  2. the user entering the RPG or chat mode
  3. the scammer applying pressure or urgency
  4. the victim and recorder agents responding through Gemma 4 E4B
  5. the expert agent explaining the red flags
  6. the final trust score, risk explanation, and learning takeaway

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

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 model defaults for each agent role
  • backend/api/chat_routes.py — routes chat requests through the configured local model
  • backend/services/vision_service.py — shared 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

Representative runtime configuration:

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

Anti-FraudX keeps the older fine-tuned scammer and expert models for specialist behavior, while Gemma 4 E4B powers the default reasoning, victim simulation, recorder analysis, and the main local training loop.

How I Used Gemma 4

I used Gemma 4 E4B as the main local reasoning model for Anti-FraudX.

Gemma 4 powers the parts of the system where general reasoning and user-facing explanation 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.

I chose E4B because Anti-FraudX needs to run in realistic community environments. A larger model such as 31B Dense may offer stronger reasoning, but it also increases hardware cost and makes local deployment harder. Smaller models are easier to run, but they do not give enough depth for role-based simulation, trust scoring, and clear anti-fraud explanations.

E4B is the best balance for this project because it is:

  • practical for local Ollama deployment
  • strong enough for short multi-step reasoning
  • suitable for privacy-sensitive scam training data
  • useful for both conversation and moderation-style feedback
  • accessible enough for schools, homes, and community workshops

This makes Gemma 4 more than a chatbot model inside the project. It sits inside the training loop: users interact with scenarios, agents respond, the recorder explains what happened, and the system turns the interaction into a learning experience.

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. Product value comes from context

The model alone is not the story. The real value comes from using Gemma 4 in a product that helps people make safer decisions under pressure. That is what turns the model into something meaningful for everyday users.

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 larger point is that local AI is not only about convenience. It is about trust. When conversations, training data, and scam examples can stay local, the system becomes easier to use in real environments where privacy and access are just as important as model quality.

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 shows that open local models can do more than answer questions. They can help people build resilience before the moment of risk, and that makes them especially valuable in safety and education settings.

Top comments (0)