G ROUP -T RANSFORMER : T OWARDS A L IGHTWEIGHT C HARACTER - LEVEL L ANGUAGE M ODEL
Anonymous authors
Paper under double-blind review
A BSTRACT
Character-level language modeling based on Transformer has brought great success by alleviating limitation of recursive operation.
However, existing
Transformer-based models require substantial computational resources, which hinders the usability of character-level language models in applications with limited resources.
In this paper, we propose a lightweight model, called GroupTransformer , that factorizes the calculation paths by grouped embedding operators.
Additionally, Group-Transformer employs inter-group linear operators to prevent performance degradation from the group strategy.
With comparison experiments on about ﬁve times larger and the best performing LSTM-based models and compatible parameter size of Transformer-based models, we show that GroupTransformer has better performance on two benchmark tasks, enwik8 and text8.
Further experiments including ablation studies and qualitative analysis revealed that the proposed work contributes to the effective lightweight model for practical application.
The implementation code will be available.
I NTRODUCTION
Character-level language modeling has become a core task in the ﬁeld of natural language processing (NLP) such as classiﬁcation (Zhang et al., 2015),
sequence tagging (Guo et al., 2019a), question answering (He & Golub, 2016), and recognition (Baek et al., 2019; Hwang & Sung, 2016), with its simplicity on generating text and its adaptability to other languages.
Along with the development of deep learning in NLP, using recurrent neural networks (RNNs) have been a standard way to solve the problem for many years.
Recently, however, a new architecture, Transformer (Vaswani et al., 2017), have shown promise in addressing this problem and have achieved breakthroughs in general language modeling (Al-Rfou et al., 2019; Dai et al., 2019).
Though this technique has achieved incredible successes, it has led to the huge size of Transformerbased models due to building deeper and wider networks.
Transformer-XL (Dai et al., 2019) and
GPT-2 (Radford et al., 2019), for instance, contain 277M and 1542M parameters, respectively.
This trend toward a large size model for performance is not suitable for edge device applications, which require small memory sizes, such as optical character reader (OCR) and speech to text (STT), and for auto-correction and auto-completion applications that need fast real-time responsiveness.
To tackle this issue, choosing an appropriately efﬁcient strategy becomes more crucial, especially in the real-world application which requires not only good performance but a lightweight model.
In this paper, we introduce a lightweight transformer for character-level language modeling.
Our method is one of the factorization methods in that it separates the standard linear layer in transformer architecture using group-wise linear operation and makes sparse connectivity between linear transformations.
The proposed model is referred to as Group-Transformer since it is inspired by the group convolution approaches (Zhang et al., 2018; Sandler et al., 2018) that have effectively compressed huge image processing models for usability on mobile devices.
While the group strategy reduces parameters and calculations in the proposed modules, its mutually exclusive calculation for the multiple groups compromises performance, caused by the information loss of inter-group correlations.
To compensate for this problem, we added two inter-group operations that share a common feature over groups for the group attention layer and linking features in different groups for the group feed-forward layer.
By modeling the inter-group information ﬂows,
Group-Transformer becomes performant as well as lightweight.
We conducted extensive experiments on two benchmark datasets, enwik8 and text8 , and found that
Group-Transformer with 6M parameters outperformed all LSTM-based models with under 35M parameters.
Furthermore, Group-Transformer shows better performance when compared against
Transformers with a comparable number of parameters.
We provide further analysis to identify the contributions of our proposed modules in detail.
To the best of our knowledge, Group-Transformer is the ﬁrst attempt to build a lightweight Transformer with the group strategy.
R ELATED W ORKS 2. T OWARDS A LIGHTWEIGHT TRANSFORMER
Since Transformer has become a promising model for diverse NLP tasks, there have been attempts to improve its efﬁciency with two majority approaches.
The ﬁrst is to restrict dependencies between input tokens to reduce superﬂuous pair-wise calculations (Child et al., 2019;
Guo et al., 2019b;
Sukhbaatar et al., 2019a).
The approach provides time efﬁciency during inference, but it does not address the heavy parameterization of Transformer.
The second approach is to develop a lightweight network architecture while maintaining the properties of Transformer.
For example, Tay et al.
(2019) utilize quaternion algebra to build lightweight modules for Transformer.
They also use the factorize the components of the embedding layer, but the expression power can be limited by the connection of factorized components based on the quaternion principle.
Another such approach (Sukhbaatar et al., 2019b) combined the multi-head attention and point-wise feed-forward layer to devise a uniﬁed module with fewer parameters.
Despite these attempts on architectural changes, their models still struggle to provide a lightweight language model with nearly still 30M parameters.
In this work, we describe a lightweight transformer with less than 10M parameters, which is extremely small when compared against previous character-level language models.
2. GROUP STRATEGY
A group strategy has attracted much attention recently to compress many large and deep state-of-theart convolutional neural networks (CNNs) (Krizhevsky et al., 2012; Szegedy et al., 2015; Chollet, 2017).
For example, when the group strategy is applied to a standard linear layer with a weight
W ∈ R
I × O , the feature map is partitioned into G groups.
As a result, the layer is replaced by
G small linear layers where each holds a weight W (cid:48)
∈ R ( I/G ) ×
( O/G ) , leading to a signiﬁcant parameter reduction.
Although intuitively appealing, it has been reported that applying the group strategy to the model often leads to huge performance degradation, since the features in different groups cannot interact with each other.
To overcome this problem, ShufﬂeNet (Zhang et al., 2018) proposed channel shufﬂe operation to make interactions between different groups.
This kind of consideration has also been applied to recurrent neural networks (RNNs).
Kuchaiev & Ginsburg (2017) proposed group-wise RNN as a special form of ensembled RNNs.
But, they did not consider the interactions between different groups.
Inspired by the ShufﬂeNet , Gao et al.
combined the shufﬂing idea into the group-wise RNN and achieved promising results.
In this work, we adopt the group strategy and build the group-wise operations suitable for Transformer architecture.
G ROUP -T RANSFORMER
Figure 1a shows the overall architecture of Group-Transformer .
It consists of a group embedding (bottom grey box), which embeds a character into grouped features, a group attention (yellow box), which contains attention modules to identify dependencies in the time domain, and a group feedforward layer (green box), which re-conﬁgures the grouped features.
As can be seen, when an input character is given, Group-Transformer converts the input into multiple group representation (blue dots and red dots), processes and merges them to predict the next character.
Figure 1b and 1c show group-wise information ﬂow (blue and red arrows), and inter-group information ﬂow (grey arrow) in the sub-modules.
Without the inter-group information ﬂows, the grouped features are processed independently.
We observed that inter-group modeling ensures that the groups become aware of the others and prevents different groups hold the same information.
The following subsections describe architectural details of the sub-modules and their relations.
[Figure]
3. G ROUP EMBEDDING LAYER
Group embedding layer identiﬁes a set of embeddings to represent a token.
The idea of representing a sentence, word or even character using a set of vectors can widely be found in many NLP models that embed input tokens by concatenating (or summing) its embedding and its sub-units’ embeddings (Verwimp et al., 2017; Bojanowski et al., 2017;
Kim et al., 2019; Zhou et al., 2019).
Similarly, we assume a single character c to be represented with G vector representations of groups, that is, [ u c 1 , ..., u cG ] where u cg ∈ R D group , 1 ≤ g ≤ G .
When a character is given, the group embedding layer retrieves a corresponding set of vectors and passes it to the following group attention layer.
Through this paper, we describe a process at a single time step.
3. G ROUP ATTENTION LAYER
The attention mechanism identiﬁes dependencies between features in the time domain and combines the information of them.
It contains three steps; (1) identifying queries, keys, and values, (2) retrieving relative features at different times, and (3) transforming the attended feature into the input domain (Vaswani et al., 2017).
The main focus of this paper is to apply a group strategy to the feature space of Transformer.
Thus, we let the second step be identical to those of the original
Transformer and focused on the ﬁrst and the third steps.
Figure 1b explains the architecture of group attention.
The multi-head attention module represents the second step, the under operations identify the queries for the ﬁrst step, and the upper operations transform the attention output for the third step.
We note that we do not represent the key and value for the multi-head attention block in the ﬁgure because they are possible to come from another source domain.
The group attention processes the grouped features with intra-group operations (white boxes) and inter-group operations (grey boxes).
Grouped Queries, Keys and Values
Let x =
[ x 1 , ..., x G ] be a set of input vectors where x g ∈ R D group for the group g .
Since the multi-head attention contains H attention modules for a single group, group attention ﬁrst calculates query q gh for a group g and its head h as the below,
[Equation]
where W q-intra gh ∈ R D group × ( D group /H ) and W q-inter gh ∈ R D group × ( D group /H ) are linear weights to describe an intra-group (white boxes) and an inter-group (grey box) combinations, respectively.
In the formula, the ﬁrst term on the right-hand side identiﬁes a speciﬁc feature for the head h in the group g and the second term determines head-wise features that allow the grouped features to share a common expression retrieving other features in a different time.
When comparing with the fully connected linear layer over the groups, the approach restricts the connection between the groups, so requires a fewer number of parameters and calculations.
For the key k gh and the value v gh , we use fully connected layers by using all group pairs g (cid:48) and g ; k gh = (cid:80) g (cid:48)
x g (cid:48)
W k g (cid:48) gh
and v gh = (cid:80) g (cid:48) x g (cid:48)
W v g (cid:48) gh where W k g (cid:48) gh ∈ R D group × ( D group /H ) and W v g (cid:48) gh ∈
R D group × ( D group /H ) are linear weights.
As we mentioned, since the keys and the values can be deﬁned from the other source domain, we use the same formula of the original Transformer, pursuing the universality of the proposed module.
Multi-head Attention
The identiﬁed headed elements are used for connecting features in the time domain.
In this step, position encoding (Vaswani et al., 2017) has an important role for the features to be aware of their position in an input sequence.
In this paper, we apply the relative positional encoding, which describes a long-length character sequence effectively.
By following Dai et al.
(2019), we deﬁne the attention score map with the relative positional information and the attention mechanism determines the attended feature a gh of the head h in the group g .
Combination of Multiple Heads
The multiple heads [ a g 1 , ..., a gH ] in the group g are combined as the below;
[Equation]
where W o-intra gh ∈ R ( D group /H )
× D group and W o-inter gh ∈ R ( D group /H )
× D group are linear weights for combining intra-group and inter-group information, respectively.
As can be seen, the ﬁnal output is determined with a speciﬁc feature from its own group and a shared feature from whole groups.
This step utilizes the same mechanism used to identify the queries with the same objective spreading group-wise information from multi-headed attention to all groups.
These intra-group and inter-group modelings mainly contribute to reducing the number of parameters and calculations.
Finally, the inputs x g are added into the output o g as ˆ x g = x g + o g for a residual connection.
3. G ROUP FEED - FORWARD LAYER
Group feed-forward layer re-conﬁgures the outputs of the attention module, ˆ x g , by applying groupwise operation at each position.
Figure 1c shows the architecture of the proposed module.
As can be seen, the groups are shufﬂed (grey box) and support each other.
The group-wise features are processed with two linear transformations and one non-linear activation.
As the original module does, the linear layers in our module transpose the input feature into a high dimensional space with non-linear activation and transform the output back into the input space.
The group feed-forward layer can be formally explained as follows.
Given G input features [ˆ x 1 , ..., ˆ x G ] , group feed-forward layer transposes the grouped features into a high dimensional space as follows;
[Equation]
where W f1-intra g ∈ R D group × ¯ D G and W
[Table]
∈ R D
[Table] × [Table] D G are linear weights for mapping intra-group and inter-group information into the ¯ D G -dimensional space, relatively bigger than D group dimension.
Here, we introduce a low-rank matrix approximation on the inter-group transformation matrix W f1-inter g (cid:48) g .
Modeling interactions between the groups requires the G × G numbers of weights, as well as the multiple weights for the group g , transpose the group into the high dimensional space for the target group g (cid:48) .
If designing a fully connected weight for all groups like the original Transformer, the feed-forward layer still holds heavyweights and expensive calculations.
To reduce the overburden, we factorize the matrix W f1-inter g (cid:48) g into two matrices, W f1-inter[1] g (cid:48) g ∈ R D group × M and W f1-inter[2] g (cid:48)
g ∈ R M × ¯ D G , inspired by Sainath et al.
and Novikov et al.
The newly introduced dimension M is smaller than D group , and thus the number of parameters and calculation is reduced proportionally with the ratio between M and D group .
In this paper, we set M as D group /G to control the dimension relatively with the number of the groups.
Interestingly, such matrix factorization can be modeled efﬁciently with a group-wise linear transformation and a shufﬂe trick as shown in Figure 1c.
Please refer to the appendix for the detail of the shufﬂe trick.
Finally, a group-wise linear transformation is applied upon the high-dimensional feature as follow;
[Equation]
where W f2 g ∈ R ¯ D G × D group is a linear weight.
For a residual connection, each grouped input feature is added into the output of the group feed-forward layer; ˆ y g
= ˆ x g + y g .
3. R ESOURCE R EQUIREMENT
Here, we describe the efﬁciency of Group-Transformer in view of the number of parameters and required computational costs.
When considering the original transformer, its required numbers of parameters are 4 ∗ O ( D 2 model ) for its attention module (query, key, value, and output linear) and
2 ∗ O ( D model ¯ D model ) for its feed-forward module, where ¯ D model is a bottleneck dimension.
Group-Transformer pursues to reduce the number of parameters by splitting the hidden state into multiple groups and processing them group-wisely.
When we set the total dimension over groups as
D model =
D group ∗ G , the resource requirements of Group-Transformer become (2+ 4 G ) ∗
O ( D 2 model ) for group attention and 3 G ∗ O
( D model ¯ D model ) for group feed-forward module.
The number of groups is increasing, the resources is decreasing.
Appendix B provides the detailed required resources of all sub-modules and comparisons with those of the original Transformer.
E XPERIMENTAL R ESULTS 4. D ATASET AND E XPERIMENTAL S ETTINGS
We demonstrate the efﬁciency of the proposed Group-Transformer with two popular benchmark datasets, enwiki8 and text8 .
The enwiki8 dataset contains 100M of English Wikipedia texts withunique characters including alphabets, non-Latin and special characters.
In comparison, the text dataset provides 100MB of pre-processed texts only with 27 unique characters by ﬁltering superﬂuous content, such as tables, citations, and punctuation, and by replacing the non-Latin characters with spelled-out equivalents (i.e., “15” to “one ﬁve”).
For a fair comparison with previous works, we used the training/dev/test splits deﬁned by Mahoney (2011) for both enwiki8 and text8 .
Most of the experimental settings follow those of Dai et al.
(2019), where the difference lies in the hyperparameters that inﬂuence the size of the model.
We set the number of layers L as 9, and we ﬁxed the total size of feature D model for a single character as 256 and the total numbers of heads as 8 while the number of groups are explored in { 2,4 } .
For the regularization of the model, we applied layer normalization (Ba et al., 2016) independently over groups and dropout layers upon the outputs of the group attention and the group feed-forward layer with the probability p = 0 .
The length of the feed sequence was 512 with the cached 512-length for the previous sequence (Dai et al., 2019).
We use the Adam optimizer with a learning rate of 2.5e-4, β 1 of 0.9, β 2 of 0.999, a batch size of 22, the number of iterations of 400,000, and the best model on the validation set is chosen.
The implementation code will be available for the other details.
4. C OMPARISON AGAINST PRIOR CHARACTER - LEVEL LANGUAGE MODELS
We compare the Group-Transformer against existing character-level language models using under 50M parameters in Table 1.
The prior models are grouped according to their methodologies, including “LSTM,” and “Transformer”.
We observe that the Group-Transformer outperforms the LSTM models with under 30M parameters and that the 2 Group-Transformer attains the best performance against all prior LSTM models on the enwik8 dataset.
When compared to Transformers, we observe
[Table]
the Group-Transformers provide lower performances but use extremely lower number of parameters.
The next section describes a fair comparison with Transformer in a lightweight setting
[Table]
4. C OMPARISONS A GAINST L IGHTWEIGHT T RANSFORMERS
Here, we compare Group-Transformers against Transformers with a comparable number of parameters and time complexity.
In this experiment, we have explored the model settings of TransformerXL to identify the Transformer models with under 8M parameters.
All models are trained by Adam with 3e-4 of the learning rate through 200,000 iterations and the length of feed sequence is set to
[Table]
model indicate the number of layers and heads, the hidden dimension over the model.
The FLOPs indicates the number of calculations to generate 512 length of a character sequence.
We used
D group = D model /G and H =
H model /G for Group-Transformers to set the same number of the total heads in the attention module.
Table 2 shows the comparison results, focusing both on the performance and efﬁciency.
At each class, we tuned Transformer-XL to have the similar number of parameters when the number of layers are 5, 7, and 9.
When compared to Transformers at each category, Group-Transformer shows better performance than the baseline models.
In particular, the 2 Group-Transformer shows its efﬁciency by using 82.1% parameters and 71.3% FLOPs of the base Transformer, but provides similar performance.
The 4 Group-Transformer outperforms the second-best model with a large margin of 0.025.
This is the result of inherent computational efﬁciency enjoyed by group-wise operation and our careful design of the inter-group connections.
[Figure]
The number of groups can be interpreted as a hyper-parameter affecting the model size.
Figureshows the effectiveness of three hyper-parameters such as the number of layers, the size of hidden dimension, and the number of groups.
The default model used Transformer-XL (Dai et al., 2019) with L = 9 , H model = 8 , D model = 256 , and ¯ D model = 4 ∗ D model , and then we reduced the three hyper-parameters.
When making the model thinner or shallower, the performances of the model become worse, but the required resources are getting lower.
When comparing ours with two reduction methods, the group strategy shows better performances than the models requiring comparable resources.
This experiment proved that the feature grouping methods, the main idea of this paper, is more efﬁcient to reduce the model size and the time complexity than tuning other model parameters.
4. A BLATION S TUDIES ON P ROPOSED M ODULES
Group-Transformer includes two modules utilizing group-wise operations and inter-group modeling.
We conduct ablation studies to identify the contributions of the proposed modules and inter-group operations.
2 groups 4 groups 8 groups # Param.
FLOPs bpc # Param. FLOPs bpc # Param.
FLOPs bpc Atten.
FF.
( ∆ Param.)
( ∆ FLOPs) ( ∆ bpc) ( ∆ Param.) ( ∆ FLOPs) ( ∆ bpc) ( ∆ Param.) ( ∆ FLOPs) ( ∆ bpc)
Original Original 8.1M 9.4B 1.
8.1M 9.4B 1. 8.1M 9.4B 1.
Ours
Original 7.8M 9.1B 1.
7.1M 8.3B 1.
6.6M 8.0B 1.
(-0.3M) (-0.3B) (+0.012) (-1.0M) (-1.1B) (+0.023) (-1.5M) (-1.4B) (+0.018)
Original Ours 7.1M 7.0B 1.
5.3M 5.8B 1.
4.1M 5.2B 1.
(-1.0M) (-2.4B) (-0.003) (-2.8M) (-3.6B) (+0.027) (-4.0M) (-4.2B) (+0.060) Ours Ours 6.8M
[Table]
Table 3 shows the module-wise impact on the number of parameters and performance.
For a fair comparison, we set the baseline model to a reduced Transformer-XL (Dai et al., 2019) of less than 8M parameters, and can gradually reduce the model size by replacing the attention and the feedforward layer with Group-Transformer module selectively.
When replacing the feed-forward layer with Group-Transformer module, we observe that the number of parameters in all cases decreases more efﬁciently than replacing the attention module.
Interestingly, when replacing both modules, the degradation is lower than the sum of the individual performance losses, but the sum of the individuals’ reduces the required resources.
This result demonstrates more efﬁciency of concurrently using both group-wise modules.
[Table]
[Figure]
In addition to this, we also investigate the inﬂuence of inter-group operations in our model.
When the inter-group operations are removed (grey boxes in Figure 1b and 1c), we observed the performance degradation on 2-Group-Transformer by 0.028 bpc and 4-Group-Transformer by 0.051 bpc.
These gaps are relatively huge when compared to the performance gap between Transformer-XL and Group
Transformers in Table 3.
The results re-emphasize the importance of inter-group modeling in GroupTransformer.
Figure 3 shows the similarity patterns between the multi-head attention of our models ((a) and (c)) and the ablation models without the inter-group operations ((b) and (d)).
As can be seen, the multi-head attention map from the model without inter-group operations shows high similarities among different groups, while the proposed model shows the opposite.
These similarity patterns imply that the model cannot fully take advantage of multi-head attention, which is designed to attend multiple positions of content, without the proposed inter-group operation.
C ONCLUSION
Recently, remarkable progress has been made in character-level language modeling by Transformer.
The advantage of Transformer lies in its effectiveness in modeling long-term dependencies between characters.
However, the models have been developed with a huge number of parameters, and the inference of them has required an expensive computational cost.
We argue that big models cannot be used in a limited computational environment.
Group-Transformer has been developed to prove the effectiveness of Transformer in a lightweight setting.
We have grouped features and proposed group-wise operations to reduce the number of parameters and time complexity of Transformer.
In addition, to fully realize the advantage of the original Transformer, we have connected the groups to interact with each other.
When applying Group-Transformer on enwik8 and text8 , we found that Group-Transformer only with 6M parameters achieves better performances than LSTM-based models holding over 30M parameters.
Further analysis has proved the effectiveness of the group strategy to reduce computational resources.
A S HUFFLE T RICK FOR G ROUP I NTERACTION
Here, we describe the shufﬂe trick used for the inter-group interaction in the group feed-forward layer;
[Equation]
) where W inter[1] g (cid:48) g
[Equation]
and W inter[2] g (cid:48)
g ∈ R M × ¯ D group are linear weights used in the low rank matrix factorization.
To explain the relationship from the shufﬂe trick, we describes the operations in the group feed-forward layer in a bottom-up way.
When we applying group-wise linear operations on the input features [ˆ x 1 , ..., ˆ x G ] , the outputs are formed as [ˆ x 1 W inter[1], ..., ˆ x G W inter[1] G ] , where
W inter[1] g ∈ R D group × ( M ∗ G ) , 1 ≤ g ≤ G .
By splitting each element into G groups and the shufﬂe operation perturbs the outputs as follows;
[Equation]
x
[Equation]
W [Equation] [Equation] where the Shufﬂe operation transposes the ﬁrst and second dimensions of G × G × M matrix and
W inter[1] g (cid:48)
g ∈ R D group × M is a linear weight describing information ﬂow from the group g (cid:48) to the group g .
Finally, a linear transformation with a weight W inter[2] g
[Equation]
M ∗ G ) × ¯ D group is applied at the column g ;
[Equation]
y inter g = Flatten ( [Equation] W inter[
[Equation]
(7) where the Flatten operation vectorizes G × M matrix to G ∗ M vector.
Therefore, the outputs ( ¯ y inter g ∈
R ¯ D group , ∀ g ), deﬁned with multiple calculations with 2 G 2 matrices ( W inter[1] g (cid:48) g and W inter[2] g (cid:48) g , ∀ g (cid:48) g ), can be formulated with only 2 G matrices ( W inter[1] g and W inter[2] g , ∀ g ) by applying the introduced shufﬂe trick.
B R EQUIRED R ESOURCES OF G ROUP -T RANSFORMER
In this section, we compare Group-Transformer from the original transformer in views of the numbers of parameters.
For a common expression, we denote D model , ¯ D model , H as the feature size, the ﬁlter size in the feed-forward layer and the number of heads for the original transformer, and we set the feature size of a group as D group =
D model /G , the ﬁlter size ¯ D group =
¯ D model /G , the number of heads in a group as H group =
H/G for Group-Transformer.
In this calculation, we set the ﬁlter size as four times bigger than D model .
B. A TTENTION M ODULES
The multi-head attention of the original transformer uses 4 D 2 model of parameters for the query, the key, the value, and the output.
The feature size for the multiple head is usually set as D model /H
where H is the number of the heads.
Therefore, all transformations in the module is conducted for a D model -dimensional input feature to identify a D model -dimensional feature.
In comparison, a group attention requires G 2 D 2 group +4 GD 2 group = 2 D 2 model + 4 G D 2 model of parameters, including 2 GD 2 group for W q-intra g and W q-inter g , 2 GD 2 group for W o-intra g and W o-inter g , and G 2 D 2 group for the keys and the value transformations.
As we mentioned, we set D G = D model /G and thus the total number of the parameters becomes 2 D 2 model + 4 G D 2 model .
When the number of groups is 2, the number of parameters of group attention is the same with those of the original transformer.
However, when the number of groups increases to 4 or 8, the number of the parameters decreases to 75% or 62.5% of the original module.
B. F EED - FORWARD M ODULES
A point-wise feed-forward layer of the original transformer requires 8 D 2 model of parameters to map an input feature into 4 D model -dimensional space and transpose it back to the input space, D model .
In comparison, a group feed-forward layer requires 8 GD 2 group + 5 G 2 MD group of parameters, including 4 GD 2 group from W f1-intra g , G 2 MD group from W f1-inter[1] g (cid:48) g , 4 G 2 MD group from W f1-inter[2] g (cid:48) g and
4 GD 2 group from W f2 g .
In our experiment, since we set M as D group /G , the total number of parameters becomes 13 GD 2 group = 13 G D 2 model .
When the number of groups is 2, the group feed-forward layer uses 81% parameters of those of the original transformer.
When increasing the number of groups to 4 or 8, the number of the parameters decreases proportionally to 40.6% or 20.3%.
C C HARACTER S EQUENCE G ENERATION
To see the effectiveness of our models on real-world applications, we have performed two generative tasks; word completion and sentence completion.
The former is to generate a word and the latter is to conclude a sentence when a given character sequence is in-complete.
Word completion task :
Table 4 shows the generated top 20 words to conclude the in-complete character sequence, “pr”.
Although our 6M and 4M Group-Transformers showed relatively lower scores (bpc) on the quantitative evaluations, as can be seen, the model still produces all real or plausible
English words without a signiﬁcant quality gap from the Transformer-XL with 41M parameters.
[Table]
text8 test dataset.
Sentence completion task :
Table 5 shows the generated sentences.
We observe that the all models generate reasonable sentences.
Seed : By age ﬁfteen, [Table] worldwide. [Table]
a
[Table]
at the
[Table]
Leipzig Conservatory]], in [[1876]] he [Table] to
[Table]
in [
[Table]
Brussels]]. [Table] [Table] went to
[Table]
(Truth) [[Budapest]] [Table] with [[Franz Liszt]], only
[Table]
ﬁnd out
[Table] Liszt was in [[Weimar, Germany]]. Transformer
[Table]
XL
[Table]
41M
[Table]
bpc
[Table] [Table]
[Table]
D W ORD - LEVEL L ANGUAGE M ODEL
The proposed method is focused on developing character-level language models, but the model can be applied to other NLP tasks.
When it comes to the word-level language modeling, compressing the word embedding layer becomes the most important part for designing a lightweight language model.
Therefore, we set a embedding dimension as 500 and adjusted the number of layers and the hidden dimension for the models to have the same number of parameters (4.5M).
Speciﬁcally, we set the bottleneck dimension as 4 times larger than the hidden dimension and follows other experimental settings of Dai et al.
Table 6 compares scale-downed Transformer-XL and the
Group-Transformers.
In all multiple settings, the Group-Transformers show better performances than the baselines.
[Table]