whatisgithub

What is text_classification?

happy-chen-ch/text_classification — explained in plain English

Analysis updated 2026-05-18

79PythonAudience · researcherComplexity · 4/5LicenseSetup · hard

In one sentence

A Chinese news headline classifier comparing traditional ML, FastText, BERT, and a distilled small model across 10 categories.

Mindmap

mindmap
  root((Text Classifier))
    What it does
      Sorts news headlines
      10 categories
      Chinese language
    Tech stack
      Python
      PyTorch
      BERT
      FastText
    Approaches
      Random forest
      FastText model
      BERT fine-tune
      Knowledge distillation
    Setup needs
      Download BERT weights
      GPU or Apple Silicon
    Audience
      Researchers
      NLP learners

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Compare traditional machine learning, FastText, and BERT approaches on the same text classification task.

USE CASE 2

Learn how knowledge distillation can shrink a large BERT model into a smaller, faster student model.

USE CASE 3

Serve trained text classifiers over an HTTP API using the included Flask setup.

What is it built with?

PythonPyTorchBERTFastTextFlaskjieba

How does it compare?

happy-chen-ch/text_classificationliuluhaixiu/davinci-autoedit-agenta2328275243/mempalace-evolve
Stars797978
LanguagePythonPythonPython
Setup difficultyhardmoderateeasy
Complexity4/53/53/5
Audienceresearchervibe coderdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires downloading a large pre-trained BERT model separately and ideally a GPU.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

This Python project builds a classifier that sorts Chinese news headlines into one of ten categories: finance, real estate, stocks, education, science, society, politics, sports, gaming, and entertainment. The source data is described as coming from the Toutiao news platform and contains 200,000 labeled examples split into 180,000 for training and 10,000 each for validation and testing. The repository offers three main approaches to the classification problem. The first uses traditional machine learning: headlines are tokenized with the jieba Chinese word segmenter, converted into TF-IDF feature vectors, and fed to a random forest classifier. The second uses FastText, a lightweight neural model that trains on word n-gram features and exposes a REST API via Flask for real-time inference. The third fine-tunes a full Chinese BERT model, a pre-trained deep language model with 110 million parameters, by adding a single linear classification layer on top. A fourth approach explores knowledge distillation. Here the large BERT model acts as a teacher and a much smaller TextCNN model acts as a student. During training the student learns from both the labeled data and the teacher's output probabilities. The final student model is far smaller and faster than BERT while retaining much of its accuracy, which makes it more practical for devices with limited computing power. The BERT model is large, around 390 MB before quantization and 146 MB after applying PyTorch dynamic quantization, and must be downloaded separately from the official source. The README notes that the random forest and FastText paths have been verified to work, but the knowledge distillation path may still contain bugs. The code detects and supports CUDA, Apple Silicon (MPS), and CPU automatically. Each sub-project includes a Flask API for serving predictions over HTTP. The README is written in Chinese. The project is licensed under MIT.

Copy-paste prompts

Prompt 1
Explain how the random forest and TF-IDF pipeline in this project classifies Chinese news headlines.
Prompt 2
Help me understand how knowledge distillation works between the BERT teacher and TextCNN student here.
Prompt 3
Walk me through downloading and setting up the pre-trained BERT model for this project.
Prompt 4
Show me how to run the Flask API to get predictions from one of these classifiers.

Frequently asked questions

What is text_classification?

A Chinese news headline classifier comparing traditional ML, FastText, BERT, and a distilled small model across 10 categories.

What language is text_classification written in?

Mainly Python. The stack also includes Python, PyTorch, BERT.

What license does text_classification use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is text_classification to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is text_classification for?

Mainly researcher.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.