Chinese Fake News Detection based on MacBERT
0
stars
38
commits
Python
primary language
Aug 25, 2025
updated
A deep learning–powered system for probabilistic fake news detection in Chinese-language news
DeFake-ZH is a deep learning–based system for Chinese fake news detection, integrating MacBERT, MGP Database Matching, and Contradiction Detection.
Trained on over 390k news articles (Sept. 2024–May 2025), the system achieves 99.12% accuracy and 0.9912 F1-score, outperforming previous studies.
Figure: Overall system architecture of DeFake-ZH
Figure: Experimental results comparing two settings. (Left) MGP-only baseline. (Right) MGP+MacBERT.
| System | Precision | Recall | F1-score | Accuracy |
|---|---|---|---|---|
| Only MGP | 0.8421 | 0.7908 | 0.7827 | 0.7908 |
| MGP + MacBERT | 0.9913 | 0.9912 | 0.9912 | 0.9912 |
| THIS PROJ. | [1] | [2] | |
|---|---|---|---|
| Language | Chinese | Chinese | Chinese |
| Method | MacBERT | Keras Sequential | BERT |
| Accuracy | 99.12% | 90.53% | - |
| F1-score | 0.9912 | - | 0.6701 |
The proposed system achieved an accuracy of 99.12% and an F1-score of 0.9912,
clearly outperforming prior studies.
In particular, [2] (Lin, 2021) applied a BERT-based model to classify CoFacts
data into binary categories, achieving a best-case Macro-F1 score of 0.6701.
⚠️ Due to copyright restrictions, the dataset is not distributed with this repository.
Users may collect comparable data from the listed sources and fact-checking organizations.
Or contact us for further information regarding data access.
Collected news data come from a variety of Taiwanese media outlets:
The dataset includes the following classification labels:
entertain_sports – Entertainment & Sportsinternational – International Newslocal_society – Local & Societypolitics – Politicstechnology_life – Technology & LifeDeFake-ZH is also informed by fact-checking resources from trusted Taiwanese organizations:
data/data/
├── db/ # Reference DBs/indexes (.json/.pkl/.faiss)
├── features/ # Extracted feature tensors (.npy/.pt)
├── processed/ # Cleaned and split data (train/val/test)
└── raw/ # Raw CSV/JSON news data
models/models/
├── bge-m3/ # Sentence embeddings (BAAI/bge-m3)
├── chinese-macbert-large/ # Chinese MacBERT (hfl/chinese-macbert-large)
├── ltp/ # HIT-SCIR LTP models
├── task/ # Task-specific classifier
├── text2vec/ # Chinese sentence embeddings
├── word2vec/ # Chinese word embeddings
└── README.md
src/src/
├── gui.py # Gradio app entry point (Blocks UI & events)
├── interface.py # Pipeline orchestrator (single-/multi-machine; helper clients)
├── otherGUI.py # Shared GUI components & CSS hooks
├── scores.py # Scoring & summary rendering
├── mgpSearch.py # MGP database search (sentence similarity, OpenCC, threshold≈0.75)
├── contradiction.py # Triplet extraction (LTP) + NLI contradiction checks (with caching)
├── classifier.py # PyTorch MLP classifier + metrics
├── trainClassifier.py # Training script
├── buildDatabase.py # DB/index builder (merge, sentence split, triplets)
├── dataPreparation.py # Cleaning, deduplication, tokenization, splits
├── featureEngineering.py # Embedding/feature pipelines (MacBERT/BGE/Text2Vec/Word2Vec)
├── PU_Learning.py # PU learning: initial labeling with TF‑IDF + logistic regression
├── helper.py # Helper server runner (contrad/MGP) for remote calls
├── const.py # Global constants and canonical paths
└── nodes.py # Embedding & vector store utils (FAISS, LangChain docs)
tests/tests/
├── predict_single_news.py # Single‑news prediction demo
├── testMLP.py # Plot training/validation curves for MLP
└── testAll.py # Analyze results: confusion matrices & PR/F1 across phases
git clone https://github.com/yachiashen/DeFake-ZH.git
cd DeFake-ZH
git lfs install
git lfs pull
Note: Git LFS
This repository uses Git LFS to manage large files (e.g., models, databases).
Please make sure you have Git LFS installed:# Install Git LFS (only once per system) git lfs install # After cloning the repository, fetch large files git lfs pull
conda env update -f environment.yml --prune
conda activate defake-zh
pip install -r requirements.txt
chinese-macbert-large: auto-download via Hugging Face transformersbge-m3, ltp, word2vec, text2vec, task): download manually as described in models/README.mdEnsure the models/ directory and its subfolders exist before running.
cd src
python gui.py
After launching, Gradio will display a local URL in the terminal (e.g., http://127.0.0.1:7860/).
Open it in your browser, enter a News Title and News Content, then choose Quick Analysis or Full Analysis.
Or try it online (with limited functionality): DeFake-ZH on Hugging Face Spaces
This project was carried out as part of the Undergraduate Capstone Project at the Department of Computer Science and Information Engineering, NCKU, 2025.
Prof. Fan-Hsun Tseng,
for his guidance and supervision throughout the project.
All news articles are copyrighted by their original publishers and fact-check platforms. Please comply with their usage policies.
28 commits
10 commits
Python
100.0%
Chinese Fake News Detection based on MacBERT
0
stars
38
commits
Python
primary language
Aug 25, 2025
updated
A deep learning–powered system for probabilistic fake news detection in Chinese-language news
DeFake-ZH is a deep learning–based system for Chinese fake news detection, integrating MacBERT, MGP Database Matching, and Contradiction Detection.
Trained on over 390k news articles (Sept. 2024–May 2025), the system achieves 99.12% accuracy and 0.9912 F1-score, outperforming previous studies.
Figure: Overall system architecture of DeFake-ZH
Figure: Experimental results comparing two settings. (Left) MGP-only baseline. (Right) MGP+MacBERT.
| System | Precision | Recall | F1-score | Accuracy |
|---|---|---|---|---|
| Only MGP | 0.8421 | 0.7908 | 0.7827 | 0.7908 |
| MGP + MacBERT | 0.9913 | 0.9912 | 0.9912 | 0.9912 |
| THIS PROJ. | [1] | [2] | |
|---|---|---|---|
| Language | Chinese | Chinese | Chinese |
| Method | MacBERT | Keras Sequential | BERT |
| Accuracy | 99.12% | 90.53% | - |
| F1-score | 0.9912 | - | 0.6701 |
The proposed system achieved an accuracy of 99.12% and an F1-score of 0.9912,
clearly outperforming prior studies.
In particular, [2] (Lin, 2021) applied a BERT-based model to classify CoFacts
data into binary categories, achieving a best-case Macro-F1 score of 0.6701.
⚠️ Due to copyright restrictions, the dataset is not distributed with this repository.
Users may collect comparable data from the listed sources and fact-checking organizations.
Or contact us for further information regarding data access.
Collected news data come from a variety of Taiwanese media outlets:
The dataset includes the following classification labels:
entertain_sports – Entertainment & Sportsinternational – International Newslocal_society – Local & Societypolitics – Politicstechnology_life – Technology & LifeDeFake-ZH is also informed by fact-checking resources from trusted Taiwanese organizations:
data/data/
├── db/ # Reference DBs/indexes (.json/.pkl/.faiss)
├── features/ # Extracted feature tensors (.npy/.pt)
├── processed/ # Cleaned and split data (train/val/test)
└── raw/ # Raw CSV/JSON news data
models/models/
├── bge-m3/ # Sentence embeddings (BAAI/bge-m3)
├── chinese-macbert-large/ # Chinese MacBERT (hfl/chinese-macbert-large)
├── ltp/ # HIT-SCIR LTP models
├── task/ # Task-specific classifier
├── text2vec/ # Chinese sentence embeddings
├── word2vec/ # Chinese word embeddings
└── README.md
src/src/
├── gui.py # Gradio app entry point (Blocks UI & events)
├── interface.py # Pipeline orchestrator (single-/multi-machine; helper clients)
├── otherGUI.py # Shared GUI components & CSS hooks
├── scores.py # Scoring & summary rendering
├── mgpSearch.py # MGP database search (sentence similarity, OpenCC, threshold≈0.75)
├── contradiction.py # Triplet extraction (LTP) + NLI contradiction checks (with caching)
├── classifier.py # PyTorch MLP classifier + metrics
├── trainClassifier.py # Training script
├── buildDatabase.py # DB/index builder (merge, sentence split, triplets)
├── dataPreparation.py # Cleaning, deduplication, tokenization, splits
├── featureEngineering.py # Embedding/feature pipelines (MacBERT/BGE/Text2Vec/Word2Vec)
├── PU_Learning.py # PU learning: initial labeling with TF‑IDF + logistic regression
├── helper.py # Helper server runner (contrad/MGP) for remote calls
├── const.py # Global constants and canonical paths
└── nodes.py # Embedding & vector store utils (FAISS, LangChain docs)
tests/tests/
├── predict_single_news.py # Single‑news prediction demo
├── testMLP.py # Plot training/validation curves for MLP
└── testAll.py # Analyze results: confusion matrices & PR/F1 across phases
git clone https://github.com/yachiashen/DeFake-ZH.git
cd DeFake-ZH
git lfs install
git lfs pull
Note: Git LFS
This repository uses Git LFS to manage large files (e.g., models, databases).
Please make sure you have Git LFS installed:# Install Git LFS (only once per system) git lfs install # After cloning the repository, fetch large files git lfs pull
conda env update -f environment.yml --prune
conda activate defake-zh
pip install -r requirements.txt
chinese-macbert-large: auto-download via Hugging Face transformersbge-m3, ltp, word2vec, text2vec, task): download manually as described in models/README.mdEnsure the models/ directory and its subfolders exist before running.
cd src
python gui.py
After launching, Gradio will display a local URL in the terminal (e.g., http://127.0.0.1:7860/).
Open it in your browser, enter a News Title and News Content, then choose Quick Analysis or Full Analysis.
Or try it online (with limited functionality): DeFake-ZH on Hugging Face Spaces
This project was carried out as part of the Undergraduate Capstone Project at the Department of Computer Science and Information Engineering, NCKU, 2025.
Prof. Fan-Hsun Tseng,
for his guidance and supervision throughout the project.
All news articles are copyrighted by their original publishers and fact-check platforms. Please comply with their usage policies.
28 commits
10 commits
Python
100.0%