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 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 5:04:57 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

6 sources
Thank you for this, I appreciate it! That's unfortunate to hear. I may have to swap out the example I used in this article, and maybe also include a note that this technique has limitations. I think that using compression/Kolmogorov complexity metrics for classification is a fruitful endeavor and that the philosophy of groups like the Hutter Prize are sound, but the kNN + gzip example looks like it has some problems with it. For anyone else following along, I think the GitHub Issue discussion on the paper's repo is really interesting: https://github.com/bazingagin/npc_gzip/issues/3
In Mutually Assured Recursion
The article has a link[1] to a discussion between the blog author and the paper author that I find revealing. Perhaps as a reminder, the issue is that the paper’s implementation of their 2-nearest neighbor secretly uses an oracle to break ties, which obviously inflates the accuracy compared to a real-world kNN classifier that has to choose heuristically. To be fair, this could be a weird implementation accident and not malice. But I think it does invalidate the results. But rather than admit error, the author defends this choice, and does so using (in my opinion) dubious statistical arguments. Which leads me to believe that — at least at this point — they know they made a mistake and just won’t admit it. They claim that instead of a real-world accuracy, they wanted to find the “max” accuracy that their classifier was statistically capable
Read the rest
of. That is, the accuracy you get if the stars happen to align and you get the luckiest possible result. Well, not only is this creative new metric not described in the paper, it’s also not applied to the other algorithms. For example, I think a neural network is capable of achieving a “max” accuracy of 100%, if all the initial weights happen to perfectly encode both the training and test sets. But of course they just use standard training to give the numbers for those algorithms. [1] https://github.com/bazingagin/npc_gzip/issues/3
In Gzip beats BERT? Part 2: dataset issues, improved speed, and results
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.