Inspiration
I was inspired by the challenge businesses face when identifying fraudulent invoices. Manual verification can be slow and difficult to scale, while simple rule-based systems may miss subtle patterns in invoice descriptions.
We wanted to explore whether Natural Language Processing (NLP) could be used to detect suspicious language in invoices alongside structured information such as vendor details, tax IDs, payment addresses, and invoice amounts. This led us to create Fraud Invoice Detector, an AI-powered system designed to provide an additional layer of invoice fraud detection.
What it does
Fraud Invoice Detector allows users to submit key invoice information, including:
Vendor name Vendor address Web3 address Tax ID Invoice amount Invoice description
The system analyses the invoice description using a fine-tuned DistilBERT model, starting from Hugging Face's distilbert-base-uncased model. The model is fine-tuned to classify invoice descriptions based on patterns associated with fraudulent and legitimate invoices.
The structured invoice information is also processed and engineered alongside the NLP output to produce a final fraud-detection result.
How we built it
The core of our system is a fine-tuned Hugging Face DistilBERT model. We tokenised our labelled invoice-description data and fine-tuned distilbert-base-uncased for the fraud-classification task.
We experimented with different hyperparameter configurations and selected the best-performing run based on our evaluation results. We use Scikit-learn to measure model performance, including precision and recall.
For data processing and feature engineering, we use Pandas and NumPy. The application uses Flask and Express.js for backend functionality, JavaScript for the frontend, and MySQL for database storage.
Our pipeline is:
Invoice Input → Data Pre-processing → Feature Engineering → DistilBERT NLP Analysis → Fraud Classification → Result
Challenges we ran into
One of our biggest challenges was adapting a general-purpose language model to the specialised task of invoice fraud detection. DistilBERT was not originally trained specifically for this problem, so preparing suitable training data and finding an effective fine-tuning configuration required experimentation.
We also had to balance precision and recall. In fraud detection, missing a fraudulent invoice can be costly, but incorrectly flagging legitimate invoices can also create unnecessary manual work.
Another challenge was integrating the machine-learning model into a complete web application and ensuring that both structured invoice information and unstructured text could be processed together.
Accomplishments that we're proud of
We are proud of successfully taking a pre-trained transformer model and adapting it to a specific real-world fraud detection problem.
We also built an end-to-end system rather than only a standalone machine-learning model. This includes the frontend, backend, database, data-processing pipeline, and trained NLP model.
Another accomplishment was experimenting with different hyperparameters and evaluating the model using metrics such as precision and recall (getting a 92% recall and 89% precision) allowing us to select a better-performing configuration rather than relying on a single training run.
What we learned
This project taught us how to work with transformer-based NLP models and fine-tune a pre-trained model for a custom classification task.
We learned how to:
Prepare and tokenise text data for DistilBERT. Fine-tune distilbert-base-uncased using Hugging Face Transformers. Experiment with hyperparameters and compare model performance. Evaluate classification models using precision and recall. Perform feature engineering with Pandas and NumPy. Integrate an ML model into a web application. Connect the application to a MySQL database.
Most importantly, we learned that building an effective fraud-detection system requires combining machine learning, structured data, and software engineering, rather than relying on a model alone.
What's next for Fraud Invoice Detector
Our next step is to improve the model by expanding and diversifying the training data and continuing to refine the feature-engineering pipeline.
We also plan to improve the user experience, provide clearer explanations for why an invoice was flagged, and test the system against a wider range of realistic invoice scenarios.
In the longer term, we want Fraud Invoice Detector to become an effective first layer of automated invoice verification, helping organisations identify suspicious invoices before payment while keeping final decisions with human reviewers.
Built With
- artificial-intelligence
- data-science
- deep-learning
- distilbert
- express.js
- flask
- fraud-detection
- hugging-face
- hyperparametertuning
- javascript
- machine-learning
- mysql
- natural-language-processing
- numpy
- pandas
- python
- scikit-learn
- text-classification
- transformers
Log in or sign up for Devpost to join the conversation.