Skip to main content
QUICK REVIEW

[Paper Review] Human Readable Compression of GFA Paths Using Grammar-Based Code

Heringer, Peter, J. D. Richardson|arXiv (Cornell University)|Jan 1, 2025
Natural Language Processing TechniquesComputer Science24 citations
TL;DR

This paper introduces SentencePiece, a language-independent subword tokenizer and detokenizer that trains directly from raw text without pre-tokenization, enabling fully end-to-end neural text processing. It achieves comparable NMT performance to conventional methods while supporting lossless tokenization and fast inference, especially beneficial for non-space-separated languages like Japanese.

ABSTRACT

Pangenome graphs offer a compact and comprehensive representation of genomic diversity, improving tasks such as variant calling, genotyping, and other downstream analyses. Although the underlying graph structures scale sublinearly with the number of haplotypes, the widely used GFA file format suffers from rapidly growing file sizes due to the explicit and repetitive encoding of haplotype paths. In this work, we introduce an extension to the GFA format that enables efficient grammar-based compression of haplotype paths while retaining human readability. In addition, grammar-based encoding provides an efficient in-memory data structure that does not require decompression, but conversely improves the runtime of many computational tasks that involve haplotype comparisons. We present sqz, a method that makes use of the proposed format extension to encode haplotype paths using byte pair encoding, a grammar-based compression scheme. We evaluate sqz on recent human pangenome graphs from Heumos et al. and the Human Pangenome Reference Consortium (HPRC), comparing it to existing compressors bgzip, gbz, and sequitur. sqz scales sublinearly with the number of haplotypes in a pangenome graph and consistently achieves higher compression ratios than sequitur and up to 5 times better compression than bgzip in HPRC graphs and up to 10 times in the graph from Heumos et al.. When combined with bgzip, sqz matches or excels the compression ratio of gbz across all our datasets. These results demonstrate the potential of our proposed extension of the GFA format in reducing haplotype path redundancy and improving storage efficiency for pangenome graphs.

Motivation & Objective

  • Address the limitation of existing subword tokenizers that require pre-tokenized input, which hinders end-to-end and multilingual NLP systems.
  • Enable lossless tokenization by preserving whitespace and punctuation as distinct symbols using meta-characters like '_'.
  • Support direct training from raw sentences to eliminate dependency on language-specific pre-processing tools.
  • Improve efficiency and scalability for non-segmented languages like Japanese and Korean by avoiding pre-tokenization bottlenecks.
  • Provide a self-contained, reproducible model format for consistent normalization and subword segmentation across systems.

Proposed method

  • Uses a normalization module to canonicalize Unicode characters before tokenization.
  • Employs two subword segmentation algorithms: byte-pair encoding (BPE) and unigram language model, both trained directly on raw text.
  • Applies a binary heap-based O(N log N) algorithm to accelerate BPE training and segmentation, reducing O(N²) complexity.
  • Manages vocabulary-to-ID mapping explicitly, supporting special tokens like <unk>, <s>, </s>, and <pad>.
  • Enables direct conversion between text and ID sequences via encoding and decoding functions, supporting on-the-fly processing in neural models.
  • Integrates with TensorFlow and PyTorch via model-embedded operations for seamless deployment in deep learning pipelines.

Experimental results

Research questions

  • RQ1Can subword tokenization be performed effectively without pre-tokenization, especially for non-space-separated languages?
  • RQ2How does direct training from raw text compare to pre-tokenized subword training in terms of NMT performance?
  • RQ3What is the computational efficiency of SentencePiece compared to existing tools like subword-nmt, particularly on raw, non-segmented data?
  • RQ4Does lossless tokenization—preserving whitespace and punctuation—improve detokenization reliability and reproducibility?
  • RQ5Can SentencePiece enable truly end-to-end, multilingual NMT systems without language-specific preprocessing?

Key findings

  • SentencePiece achieves BLEU scores comparable to or better than standard subword methods: 29.55 BLEU on ja→en and 21.62 on en→ja, outperforming word-level baselines.
  • Pre-tokenization is not necessary for performance gains; in fact, it slightly degrades results in English-to-Japanese translation (20.86 BLEU vs. 21.62 without pre-tokenization).
  • SentencePiece trains and segments 380× faster than subword-nmt on raw Japanese data (217.3s vs. 528.0s for training), demonstrating superior scalability.
  • Segmentation speed reaches ~74k sentences/sec on Japanese data, making real-time inference feasible.
  • The unigram and BPE models in SentencePiece show nearly equivalent performance, validating both as viable options.
  • Lossless tokenization via meta-symbol escaping (e.g., '_' for space) ensures perfect reversibility and eliminates ambiguity in detokenization.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.