Oh crud, I made the front page. It should be obvious that this is junk quality as a language model. But it's a cool example of the equivalence between compression codes and probability distributions, so I hope people find it interesting for that reason. You can also get a bit of an intuitive sense for the patterns that gzip and bzip2 pick up on in text (they like repetitive strings).
Maybe this was the inspiration for your project but I just saw a paper that applied compressors as part of a text classification system getting accuracy competitive with BERT. 14 lines of Python. https://aclanthology.org/2023.findings-acl.426/
Ziplm: Gzip-Backed Language Model
11–20 of 59 posts
Re: Ziplm: Gzip-Backed Language Model
#12Of course, it doesn't really matter, as the whole thing is obviously just a toy, but I still think that this approach should be able to produce much better output than the garbled Moby Dick example.
Re: Ziplm: Gzip-Backed Language Model
#13Oh crud, I made the front page. It should be obvious that this is junk quality as a language model. But it's a cool example of the equivalence between compression codes and probability distributions, so I hope people find it interesting for that reason. You can also get a bit of an intuitive sense for the patterns that gzip and bzip2 pick up on in text (they like repetitive strings).
Re: Ziplm: Gzip-Backed Language Model
#14Oh crud, I made the front page. It should be obvious that this is junk quality as a language model. But it's a cool example of the equivalence between compression codes and probability distributions, so I hope people find it interesting for that reason. You can also get a bit of an intuitive sense for the patterns that gzip and bzip2 pick up on in text (they like repetitive strings).
Repeating this experiment with a more optimal compression algorithm might be interesting too.
Re: Ziplm: Gzip-Backed Language Model
#15scipy.special.log_softmax(-code_lengthsself.conversion(1/temperature))
Your codes are K-ary but this doesn't look like its taken into account ala the README. What is the log(256) conversion factor? What is 1/temperature for?
Re: Ziplm: Gzip-Backed Language Model
#16Earlier quoted context omitted.
I am not sure if it was intentional, but in your "Moby Dick" example, the "alphabet" vocab is missing the letter 'f'.
Ha, yeah. I was just running my finger along the keyboard to type out the string. I just regenerated it, btw, and got a better looking result.
Re: Ziplm: Gzip-Backed Language Model
#17Oh crud, I made the front page. It should be obvious that this is junk quality as a language model. But it's a cool example of the equivalence between compression codes and probability distributions, so I hope people find it interesting for that reason. You can also get a bit of an intuitive sense for the patterns that gzip and bzip2 pick up on in text (they like repetitive strings).
Re: Ziplm: Gzip-Backed Language Model
#18[0] http://bactra.org/notebooks/nn-attention-and-transformers.ht...
Re: Ziplm: Gzip-Backed Language Model
#19Hey author, would you mind explaining the conversion from compression length to probability please? Namely this line: scipy.special.log_softmax(-code_lengths self.conversion (1/temperature)) Your codes are K-ary but this doesn't look like its taken into account ala the README. What is the log(256) conversion factor? What is 1/temperature for?
The temperature parameter is there in case anyone wants to play around with it.
Re: Ziplm: Gzip-Backed Language Model
#20It should be noted that Moby Dick is (in)famous for its very large and unusual vocabulary. Some lighter reading might yield better results for demonstration purposes. Also, while fairly long for a single novel, the number of words is still minuscule compared to what other LMs are trained on. Using the entire Gutenberg library, or a Wikipedia dump, could improve the quality dramatically. Of course, it doesn't really m…