HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
bazingagin
npc_gzip
Python2023–2023
bazingagin / npc_gzip

npc_gzip

Code for Paper: “Low-Resource” Text Classification: A Parameter-Free Classification Method with Compressors

6Distinct people
6Mentions
0Explicit recommenders
1.8KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Code for Paper: “Low-Resource” Text Classification: A Parameter-Free Classification Method with Compressors

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 9–Nov 16 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/16/2026, 1:02:30 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by week6 dated mentions

Observed mentions: 2023-07-17 06:18:33 UTC to 2023-09-24 17:52:34 UTC. Weeks start Monday, UTC.

012342023-07-17 00:00:00 UTC to 2023-07-24 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 commentsJul 172023-07-24 00:00:00 UTC to 2023-07-31 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-07-31 00:00:00 UTC to 2023-08-07 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-08-07 00:00:00 UTC to 2023-08-14 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-08-14 00:00:00 UTC to 2023-08-21 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsAug 142023-08-21 00:00:00 UTC to 2023-08-28 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-08-28 00:00:00 UTC to 2023-09-04 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-09-04 00:00:00 UTC to 2023-09-11 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-09-11 00:00:00 UTC to 2023-09-18 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-09-18 00:00:00 UTC to 2023-09-25 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsSep 18

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Jul 172023-07-17 00:00:00 UTC2023-07-24 00:00:00 UTC404
Jul 242023-07-24 00:00:00 UTC2023-07-31 00:00:00 UTC101
Jul 312023-07-31 00:00:00 UTC2023-08-07 00:00:00 UTC000
Aug 72023-08-07 00:00:00 UTC2023-08-14 00:00:00 UTC000
Aug 142023-08-14 00:00:00 UTC2023-08-21 00:00:00 UTC000
Aug 212023-08-21 00:00:00 UTC2023-08-28 00:00:00 UTC000
Aug 282023-08-28 00:00:00 UTC2023-09-04 00:00:00 UTC000
Sep 42023-09-04 00:00:00 UTC2023-09-11 00:00:00 UTC000
Sep 112023-09-11 00:00:00 UTC2023-09-18 00:00:00 UTC000
Sep 182023-09-18 00:00:00 UTC2023-09-25 00:00:00 UTC101

What Hacker News says

4 sources
This is interesting, but why don’t they link to the paper? Or at least give its title? The paper is «“Low-Resource” Text Classification: A Parameter-Free Classification Method with Compressors»: ACL Anthology, has PDF link: https://aclanthology.org/2023.findings-acl.426/ Arxiv, has PDF link: https://arxiv.org/abs/2212.09410 arXiv Vanity, HTML render of it: https://www.arxiv-vanity.com/papers/2212.09410/ ResearchGate, has PDF link: https://www.researchgate.net/publication/366423949_Less_is_M... This is Listing 1: ”Python Code for Text Classification with gzip.” import gzip import numpy as np for (x1, _) in test_set: Cx1 = len(gzip.compress(x1.encode())) distance_from_x1 = [] for (x2, _) in training_set: Cx2 = len(gzip.compress(x2.encode()) x1x2 = " ".join([x1, x2]) Cx1
Read the rest
x2 = len(gzip.compress(x1x2.encode()) ncd = (Cx1x2 - min(Cx1,Cx2)) / max(Cx1, Cx2) distance_from_x1.append(ncd) sorted_idx = np.argsort(np.array(distance_from_x1)) top_k_class = training_set[sorted_idx[:k], 1] predict_class = max(set(top_k_class), key=top_k_class.count) Abstract: In this paper, we propose a non-parametric alternative to DNNs that’s easy, lightweight, and universal in text classification: a combi- nation of a simple compressor like gzip with a k-nearest-neighbor classifier. Without any training parameters, our method achieves re- sults that are competitive with non-pretrained deep learning methods on six in-distribution datasets. It even outperforms BERT on all five OOD datasets, including four low-resource lan- guages. Our method also excels in the few-shot setting, where labeled data are too scarce to train DNNs effectively. Code is available at https://github.com/bazingagin/npc_gzip Ah, this was already mentioned a few days ago in HN: 73 comments: “Gzip and KNN Outperforms Transformers on Text Classification” https://news.ycombinator.com/item?id=36707193 7 comments: “Plain old gzip+kNN outperforms BERT and other DNNs” https://news.ycombinator.com/item?id=36705472 7 comments: “A Parameter-Free Classification Method with Compressors” https://news.ycombinator.com/item?id=36707509
In 14-line code can be used to 'understand' similarities between sentences

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.