Abstract
This paper presents ArthNgram, a novel lossless compression technique that integrates N-gram language modeling with arithmetic coding. By transitioning from character-level to word-sequence-level analysis, the proposed method captures richer structural patterns in text data. Experimental results demonstrate that ArthNgram significantly outperforms traditional algorithms like Huffman and LZW, achieving an average file size reduction of 65%.
Introduction
The exponential growth of data generated by IoT devices, big data analytics, and Large Language Models (LLMs) necessitates advanced compression techniques to optimize storage and transmission. Traditional lossless compression algorithms, such as Huffman coding and Lempel-Ziv-Welch (LZW), primarily operate at the character level. These methods often fail to exploit the linguistic context and structural redundancies inherent in natural language. The authors propose that a word-level approach using N-gram models can provide superior "predictive" capabilities, leading to higher compression efficiency.
Methodology
The ArthNgram model combines two core components: N-gram language modeling and arithmetic coding.
- N-gram Language Modeling: The system decomposes text into sequences of $N$ words (ranging from unigrams to five-grams). By analyzing the frequency of these sequences, the model constructs a probability distribution of word transitions.
- Arithmetic Coding: Unlike symbol-based coding, arithmetic coding represents an entire message as a single numeric value within the interval [0, 1). Highly probable sequences are assigned larger sub-intervals, requiring fewer bits for representation.
As illustrated in the flowchart above, the workflow involves checking the input text against a dictionary and updating it as needed. The N-gram model calculates pair probabilities, which are then used by the compression module to find a range and generate a codeword via a specialized codebook algorithm. The decompression process reverses these steps to retrieve the original text.
Experimental Setup
The model was evaluated using five text files of varying sizes, ranging from approximately 8 Kb to 98 Kb. These datasets provided a controlled environment to benchmark the compression ratios and processing times of ArthNgram against standard Huffman and LZW implementations.
Results and Analysis
The study revealed several key insights into the performance of N-gram-based arithmetic coding:
- Contextual Efficiency: Word-level context provides significantly higher redundancy than character-level patterns. As the value of $N$ increases, the model captures more linguistic structure, improving compression.
- The Trigram Balance: While higher-order models (e.g., Arth5g) offer maximum compression, Arth3g (trigrams) was identified as the "sweet spot," providing a robust balance between compression ratio and computational complexity.
- Performance Benchmarks: ArthNgram (N=2 to N=5) consistently outperformed Huffman, LZW, and standard Arithmetic coding. On average, the proposed model achieved a 65% reduction in file size compared to traditional methods.
Discussion and Limitations
While ArthNgram offers superior space savings, it introduces a trade-off in computational overhead. Huffman coding remains significantly faster, making it preferable for real-time applications. Conversely, ArthNgram is ideal for "cold storage" scenarios where space optimization is paramount.
A critical requirement for this method is the availability of the N-gram dictionary at both the encoding and decoding ends. The practical overhead of storing or transmitting large dictionaries must be considered in real-world deployments. Future work will focus on scaling the model to larger datasets and exploring dynamic dictionary management.
Summary updated