Sent2Matrix: Folding Character Sequences in Serpentine Manifolds for Two-Dimensional Sentence

Hongyang Gao, Yi Liu, Xuan Zhang, Shuiwang JiarXiv 2021

Abstract

Sent2Matrix is a novel text representation method that transforms one-dimensional character sequences into two-dimensional matrices, enabling the application of powerful 2D Convolutional Neural Networks (CNNs) to natural language processing tasks. By utilizing a unique "serpentine padding" technique, the model preserves the sequential flow of text while explicitly capturing both fine-grained character morphology and clear word boundaries. Evaluated on standard text classification benchmarks, Sent2Matrix consistently outperforms traditional 1D word-level and character-level models.

Introduction

In deep learning for NLP, text is typically treated as a 1D sequence. Current representation methods generally fall into two categories, both with significant trade-offs. Word-level embeddings treat words as atomic units, respecting boundaries but ignoring internal morphology (e.g., the shared root of "run" and "running"). Conversely, character-level embeddings capture morphology well but often treat word separators as just another character, making word boundaries vague for the neural network.

Furthermore, while 2D CNNs have revolutionized computer vision by capturing complex spatial relationships, NLP has largely remained restricted to 1D convolutions. The authors of Sent2Matrix argue that representing text in a 2D format allows models to capture multi-scale relationships between characters and words simultaneously, leveraging the architectural advantages of spatial feature extraction.

The Sent2Matrix Representation

The core of the proposed method is the conversion of a sentence into a 3D tensor. Instead of a flat sequence of vectors, each word is converted into a separate matrix where rows represent characters and columns represent one-hot character encodings. Stacking these word-matrices results in a 3D tensor (Words $\times$ Characters $\times$ Encoding).

Comparison of word-level (a), character-level (b), and the proposed 3D tensor representation (c).

Because the data is now structured like an image, the model can apply 2D filters. These filters slide across both the character dimension (capturing morphology) and the word dimension (capturing context) at the same time. To ensure maximum information flow, the architecture utilizes a Densely Connected Network (DenseNet) style, where the outputs of previous layers are concatenated to subsequent ones.

Serpentine Padding and Folding

To handle variable-length words and maintain the logical "flow" of a sentence in a 2D grid, the authors developed a "serpentine" approach. In this manifold, the text is folded back and forth. To keep characters in the correct logical order for 2D filters, every other "row" (word) is reversed. This allows 2D kernels to look "above" and "below" a character to see characters in adjacent words that are logically nearby in the sequence.

Visualization of the serpentine folding process, showing how a sentence is mapped into a 2D manifold using spaces as U-turn signals.

Experimental Results

The authors evaluated Sent2Matrix on three standard benchmarks: AG’s News (topic classification), Yelp Full (sentiment analysis), and MR (Movie Reviews). Sent2Matrix CNN consistently outperformed LSTMs and traditional 1D CNNs across all datasets:

  • AG’s News: Achieved 92.1% accuracy, outperforming the best word-level CNN baseline (91.4%).
  • Yelp Full: Achieved 63.2% accuracy, a significant jump over character-level CNNs (62.1%).
  • MR: Achieved 77.9% accuracy.

An ablation study on padding strategies showed that Serpentine Padding provided a 2-4% accuracy boost over simple Zero Padding, proving that the "folding" logic is critical to the model's success in maintaining sequential integrity.

Conclusion and Limitations

Sent2Matrix demonstrates that treating text as a 2D manifold can unlock the potential of spatial CNN architectures for NLP. While the method currently faces constraints regarding fixed dimensions and computational costs associated with 3D tensors, it provides a robust framework for integrating morphological and contextual information. Future work will explore applying this 2D representation to more complex tasks like machine translation and sequence labeling.

Summary updated

Abstract

We study text representation methods using deep models. Current methods, such as word-level embedding and character-level embedding schemes, treat texts as either a sequence of atomic words or a sequence of characters. These methods either ignore word morphologies or word boundaries. To overcome these limitations, we propose to convert texts into 2-D representations and develop the Sent2Matrix method. Our method allows for the explicit incorporation of both word morphologies and boundaries. When coupled with a novel serpentine padding method, our Sent2Matrix method leads to an interesting visualization in which 1-D character sequences are folded into 2-D serpentine manifolds. Notably, our method is the first attempt to represent texts in 2-D formats. Experimental results on text classification tasks shown that our method consistently outperforms prior embedding methods.
BibTeX
@misc{gao2021sent,
  author = {Hongyang Gao and Yi Liu and Xuan Zhang and Shuiwang Ji},
  title = {{Sent2Matrix: Folding Character Sequences in Serpentine Manifolds for Two-Dimensional Sentence}},
  year = {2021},
  eprint = {2103.08387},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.08387},
}
Figure