Elamur Research

Attribute Injection for Pretrained Language Models: A New Benchmark and an Efficient Method

Paper · 2022 · Reinald Kim Amplayo, Kang Min Yoo and Sang-Woo Lee

Summary

The same words can carry different evidence depending on who wrote them or what they describe. In a review, calling something sweet can signal approval or disappointment. Knowing which reviewer wrote it may help interpret the comment. Many text collections already carry this kind of context as metadata, such as reviewer and product IDs, author lists, or recipe ingredients. The authors ask how to use those fields in text classification while reusing an encoder built through pretraining. The method has to accommodate identifiers with no useful wording, fields with several labels per document, and labels that appear rarely or never during training.

The paper introduces AttrIB, a benchmark with eight datasets and six versions of review datasets in which training data are deliberately reduced to create unseen metadata labels. The tasks include sentiment classification, spoiler detection, estimating recipe duration, and predicting separate ratings for aspects of a beer. The proposed method, Injectors, inserts small trainable components called adapters inside the encoder and keeps the pretrained weights fixed. Metadata can change an adapter’s bias, supplying a prior tendency before accounting for the wording, or change its weights, altering how it processes the text. The method builds these weight changes from smaller pieces to avoid learning a large projection. During training it sometimes hides attributes, and when a field contains several labels it processes each label before combining their contributions.

With BERT-base, Injectors led the BERT-based comparisons on all eight main datasets. On Goodreads spoiler detection, it reached an F1 score of 57.78, compared with 48.92 for BERT with ordinary adapters. On IMDB sentiment classification, it reached 58.90 accuracy, compared with 57.3 for the strongest BERT-based alternative reported there. The BERT version trained 0.10× the reference parameter count used for full BERT-base training, with embeddings excluded from that comparison. The authors also tested the method with RoBERTa-base and found higher scores on several datasets, including Goodreads, where it reached 60.73 F1.

The controlled comparisons show that different tasks benefit from different ways of using metadata. On Goodreads, removing the metadata-dependent bias had a greater effect than removing the metadata-dependent weights. On the recipe and arXiv tasks, combining the contributions of multiple labels after processing them was especially helpful. Injectors also led at every tested level of synthetic cold start, although its gains were smallest at the highest level. In a separate beer-rating experiment, attribute adapters learned on some rating aspects improved prediction on a held-out aspect. That transfer result concerns related tasks within the same review collection. The authors make the AttrIB benchmark and Injectors code available.

Deep dive: Attribute Injection for Pretrained Language Models: A New Benchmark and an Efficient Method

Attribute injection adds user IDs and other metadata to a frozen text encoder, improving classification even when some labels are unseen. · about 35 minutes to read

The problem and its context

When the text comes with useful context

A review can describe the same feature that appears in many other reviews of a product. Its author can also have a history of giving unusually low ratings. These are different clues. The product identifies what the text refers to, while the reviewer identifies someone whose ratings may follow a recognizable pattern. A predictor given only the current review has to recover whatever it can from the wording. A predictor that also receives the metadata can use patterns learned from other examples with that product or reviewer.

The distinction matters for more than reviews. A scientific abstract may come with several authors and several research areas. A political tweet may be accompanied by information about the politician, the outlet, the audience, and political bias. The classification target changes with the domain. An arXiv example asks about conference acceptance, while a political example asks what kind of message a tweet conveys. The common question is whether information attached to a document improves the prediction made from its text.

In the paper’s terminology, an attribute is a field such as reviewer, research area, or ingredient. A label is a value in that field. One reviewer can occupy the reviewer field, whereas an author field can hold an entire list. These labels have a different role from the class the system predicts. An ingredient label, for example, is part of the input to the recipe task. The recipe’s duration class is the output. A review rating can occupy either role depending on the task. The paper uses ratings as targets in sentiment classification and uses an existing rating as context in spoiler detection.

What makes the fields difficult to use is the variation in how their values are represented and how often they occur. A research area may have a descriptive name. An account ID can be an arbitrary string whose characters offer little guidance about the person behind it. An abstract can have several authors, with each name adding a different possible signal. Even with a large collection, many labels may occur in very few training examples. A new review can also come from a reviewer whose ID is entirely absent from training. The authors distinguish sparsity, meaning there are few examples, from cold start, meaning there are none.

These distinctions affect what can be learned. Repeated examples give a trainable representation of a reviewer opportunities to reflect that reviewer’s pattern. A never-observed ID supplies no such history. A method that works with both kinds of input has to take advantage of familiar values and still make a sensible prediction from whatever evidence is available when a value is missing. When a field contains a list, the method must also decide how to combine evidence from its members. Collapsing the list immediately into one representation can change what a later nonlinear computation is able to use.

From custom architectures to small additions

The paper traces the use of metadata back to systems built around manually designed features. In research collections, earlier work used information such as an author list or publication venue. Other examples included topical information for sentences and time or location information for tweets. Review sentiment was a common setting because review collections often already supplied user and product information. A designer could decide which features would represent a user’s tendencies or a product’s reception, then supply those features alongside the text.

Neural approaches learned dense representations of users and products from the task data. The paper describes several places where those representations entered the computation. They could affect the vectors used for words or whole documents. They could influence which parts of a document received more weight during pooling, the step that combines local representations into a document representation. They could also enter memory networks or supply matrices that change how much the classifier uses different parts of its input. These approaches differed in what they let the metadata change, from an intermediate representation to the final decision.

Many such designs assumed that the architecture could be specified for the task and trained from scratch. The starting point changed once fine-tuning a pretrained encoder became the usual comparison in this paper’s setting. The encoder already had a sequence of layers and learned weights. Replacing substantial parts of that design to fit a particular metadata field made it harder to reuse the original computation. The authors therefore wanted to keep the pretrained architecture and add a way for metadata to influence the intermediate representation.

One earlier BERT-based approach, MA-BERT, added its own attribute-aware Transformer layers after the pretrained encoder. The paper describes the original extension as six layers and puts their parameter cost at 50% of BERT-base’s original parameter count. These layers use attributes to condition attention, so they can change how signals in the encoded document are combined. Their location matters. By the time the added layers see the metadata, BERT’s intermediate processing of the document has already happened. For the authors, the engineering question was whether small components inside the encoder could supply contextual information along the way.

Why prompts, tokens, and ordinary adapters only cover part of the problem

The paper also discusses earlier work on text generation that supplied a prompt or added a special token for a desired property, such as topic or sentiment. A meaningful word in a prompt gives the encoder ordinary linguistic material to process. A dedicated token makes it possible to represent a category explicitly. Both methods are natural when the categories are easy to express or when there are only a few possible values. The paper contrasts those cases with a collection that records many product IDs, large sets of authors, or heterogeneous fields that mix names, categories, and arbitrary identifiers. CTRL

A control token can still be assigned to an opaque identifier, and the experiments include precisely that baseline. The issue is what the system can learn from the token and how the interface handles the range of attributes. Turning a reviewer ID into a token gives it a place in the sequence. It provides no ordinary linguistic meaning and does not specify how to combine it with other attributes. With multiple labels, the sequence also has to carry all the chosen values. The authors wanted an interface that treated metadata as categorical input and could give each attribute type its own way of modifying a text representation.

Ordinary adapters offered a starting point. An adapter is a small trainable component placed in a network whose original weights can stay fixed. Its parameters provide a place to learn task-specific behavior. In the work the authors build on, adapters support efficient adaptation or allow components learned for different purposes to be combined. The paper also discusses adjacent approaches that condition computation on textual questions or supply commonsense knowledge. Injectors extends the adapter idea to fields whose values may lack any useful rendering as natural language. Parameter-Efficient Transfer Learning for NLP AdapterFusion

This choice connects the architecture to the benchmark. A design tested only with familiar reviewers and products could succeed largely by learning repeated IDs. A test confined to single-valued fields would give little evidence about whether it handles an author list. AttrIB brings these conditions together so the paper can ask when metadata improves text prediction and whether the same method remains practical as the number and variety of labels grow.

The method, step by step

What the system receives

Start with a document and a target to predict. A recipe supplies a text description and a duration class. Its metadata gives the contributor, ingredients, and tags. The encoder processes the recipe as a sequence of tokens, the units into which the input text is divided. The metadata travels through a separate route. Each observed value has a learned representation called an embedding, a vector that is adjusted during training. The ingredient field can therefore provide several embeddings for one recipe, while the contributor field provides one.

The paper formalizes the difference between text alone and text with metadata as follows.

p(y ∣ x) and q(y ∣ x, z)

Here x is the text, y is a possible output class, and z is the full collection of attributes for that text. The vertical bar means “given.” The function p predicts from the text, and q predicts from the text and its attributes. In the paper’s task definition, p comes from a pretrained encoder fine-tuned for the task. The objective is a gain in task performance from incorporating z. The notation does not imply that the gain is positive for every input or every injection method.

x = {xᵢ}ᵢ₌₁ᴺ

Here xᵢ is the token at position i, and N is the number of tokens. The braces collect the tokens, with the position index preserving their order.

z = {zⱼ}ⱼ₌₁ᴹ

Here M is the number of attribute types, j indexes a type, and zⱼ is the value or collection of values in that field. The braces collect the fields available for x.

zⱼ = [zⱼ⁽ᵏ⁾], with zⱼ ⊆ Zⱼ

Here k indexes the individual labels in field j, and zⱼ⁽ᵏ⁾ denotes one such label. The square brackets collect those labels. Zⱼ is the finite vocabulary for that attribute type, and ⊆ indicates that the example’s labels belong to it. The vocabulary for user IDs and the vocabulary for product IDs are conceptually distinct, even if both contain values represented as strings.

How Injectors uses text and metadata

The steps in order.

How Injectors uses text and metadataStep 1: Encode the text with a frozen Transformer1. Encode the text with a frozen TransformerStep 2: Pass intermediate vectors through a task adapter2. Pass intermediate vectors through a task adapterStep 3: Look up embeddings for available attribute labels3. Look up embeddings for available attribute labelsStep 4: Derive bias and weight contributions per label4. Derive bias and weight contributions per labelStep 5: Combine contributions within each attribute field5. Combine contributions within each attribute fieldStep 6: Apply the attribute adapters in sequence6. Apply the attribute adapters in sequenceStep 7: Classify using the final classification-token vector7. Classify using the final classification-token vector

The adapter operations in the diagram take place inside the encoder as it processes the text. The first step does not imply that the encoder finishes before an attribute is used. Figure 2 places the adapter sequence at the insertion points of a Transformer block. The task adapter acts first at a given point, and the attribute adapters follow. Later pretrained operations can thus receive hidden vectors that have already been affected by the metadata.

The task adapter prepares the hidden representation

An encoder layer passes along a hidden vector, a numerical representation of a token at a particular stage of processing. A standard adapter takes this vector and briefly projects it into a space with fewer coordinates. It applies a nonlinear transformation there, projects the result back to the original width, and adds it to the input. The small intermediate dimension is the bottleneck. Because the added correction has the same width as the input, the rest of the encoder can accept the resulting vector through its existing interface.

h′ = Adapt(h) = FFNetᵤₚ(f(FFNet_dₒwₙ(h))) + h

Here h is the input hidden vector and h′ is the output of Adapt, the adapter operation. Both have width dₕ, which is the encoder’s hidden size. FFNet_dₒwₙ maps from width dₕ to the smaller adapter width dₐ, and FFNetᵤₚ maps back to dₕ. The function f applies a nonlinearity in the bottleneck. The final plus sign denotes a residual connection, which adds the adapter’s correction to h.

FFNet(v) = Wv + b

Here FFNet is either of the two affine projections. v is the vector entering that projection, W is its weight matrix, and b is its bias vector. Multiplication by W mixes the input coordinates, and addition of b shifts the resulting coordinates. The weight matrix and bias have shapes appropriate to the direction of the projection.

Injectors begins its sequence with this ordinary adapter. It is task-specific and receives the hidden text vector directly. A duration predictor and a spoiler detector need different transformations even before metadata is considered. Keeping that part of the computation in its own adapter also gives the later transfer experiment a natural division. An attribute component can be carried over while the new task learns its own task adapter and classifier.

Attribute adapters change the bias and the weights

After the task adapter, each attribute type gets an adapter of its own. Suppose the input is a review with a user ID and a product ID. The hidden vector leaving the task adapter enters the first attribute adapter. Its output then becomes the input to the next one. The product stage can therefore act on a representation that has already been altered by the reviewer stage, if that is their order. The design gives each field a distinct operation while keeping the hidden vector compatible with the encoder.

For a field with a single label, the system looks up that label’s embedding. To distinguish a categorical label from its numerical representation, the formulas below use eⱼ for the embedding associated with zⱼ. They use an indexed hidden vector hⱼ for the representation after applying the adapter for field j.

h₀ = h′

Here h₀ is the hidden vector before the first attribute adapter, and h′ is the output of the task adapter at that insertion point. The subscript 0 marks the starting state of the attribute sequence.

hⱼ = AttrAdapt(hⱼ₋₁, eⱼ) = FFNetᵤₚ(f(W_zⱼ hⱼ₋₁ + b_zⱼ)) + hⱼ₋₁

Here AttrAdapt is the attribute adapter, hⱼ₋₁ is the preceding hidden vector, and hⱼ is the vector it produces. eⱼ is the embedding of the selected label. W_zⱼ is the down-projection matrix conditioned on the label, written in multiplication order for a column-vector input. b_zⱼ is the corresponding bias in the bottleneck. The input to f has width dₐ. FFNetᵤₚ restores width dₕ, and the residual addition passes along the preceding vector with the correction applied.

The two terms inside the nonlinearity give metadata different jobs. A bias can encode a tendency that does not depend on which words occur in the review. A reviewer may commonly give low ratings, or may tend to include spoilers. The label can shift the bottleneck activations before the nonlinearity even when the same text vector is held fixed. The correction eventually returned by the adapter still depends on the text, because the shift and the projected text meet inside f.

b_zⱼ = g_bᵢₐₛ(eⱼ) + c_bᵢₐₛ

Here g_bᵢₐₛ is a learned linear projection from embedding width d_z to bottleneck width dₐ. eⱼ is the attribute embedding, c_bᵢₐₛ is a learned offset of width dₐ, and the resulting b_zⱼ is the bias used by the attribute adapter. Different labels can produce different biases through the same projection for that adapter.

The weights give a label a way to change the operation applied to the text. The paper’s sweet-food example illustrates the motivation. A mention of sweetness may contribute differently to a rating depending on the reviewer’s preferences. An attribute-dependent weight matrix can change which combinations of hidden coordinates affect the bottleneck, allowing the same words to yield a different interpretation for a different reviewer.

W_zⱼ = g_wₑᵢgₕₜ(eⱼ) + C_wₑᵢgₕₜ

Here g_wₑᵢgₕₜ maps the embedding eⱼ to a matrix-shaped correction. C_wₑᵢgₕₜ is the learned matrix that supplies the attribute-independent part of the projection. Their sum is W_zⱼ, the matrix used to project the previous hidden vector into the bottleneck. The two matrices being added have the same shape, with dimensions dₕ and dₐ in the storage notation used in the paper.

A direct linear map to all the entries of the weight matrix would need a learned tensor of size d_z × dₕ × dₐ. That cost recurs for the metadata-conditioned projections. The authors’ solution is to produce the large correction from smaller learned projections, vectors, and matrices.

Building a large correction from small pieces

The construction starts by projecting the embedding along several components. The paper calls this a hypercomplex representation. For the computation here, it can be read as a collection of ordinary real-valued vectors. The components provide distinct contributions to the final matrix, and the authors omit imaginary units so the operations can be carried out in real space.

êⱼ = [σ₁(eⱼ), …, σᴏ(eⱼ)]

Here êⱼ is the collection derived from embedding eⱼ. O is the number of hypercomplex components, and σₒ is the learned linear projection for component o. Each σₒ maps a vector of width d_z to one of width dₐ. The brackets and ellipsis indicate the complete collection of component vectors.

Sₒ = êⱼ,ₒ sₒᵀ

Here êⱼ,ₒ is the component vector produced by σₒ. The learned vector sₒ has width dₕ / O², and the superscript ᵀ means transpose. The expression is an outer product. Each entry of the resulting small matrix Sₒ is the product of an entry from each vector. This construction has rank at most one, meaning that all its columns are multiples of the same vector.

The outer product provides a compact representation, with a corresponding restriction on the form of the matrix it can express. The next operation builds a larger matrix by arranging scaled copies of a small matrix. The authors use this step, along with a sum across components, to give the correction more flexibility than a single outer product.

Ŵₒ = Reshape(tanh(Sₒ ⊗ Aₒ))

Here Aₒ is the learned O × O matrix for component o, and ⊗ is the Kronecker product. It uses each entry of Sₒ to scale a copy of Aₒ, yielding a block matrix. tanh applies the hyperbolic tangent to each entry. Reshape rearranges the entries into the layout of the adapter’s down projection. Ŵₒ is the resulting matrix contribution for that component.

g_wₑᵢgₕₜ(eⱼ) = ∑ₒ Reshape(tanh((σₒ(eⱼ) sₒᵀ) ⊗ Aₒ))

Here ∑ₒ adds the contributions across all O components. σₒ(eⱼ) projects the label embedding, sₒᵀ supplies the transposed learned vector for the outer product, and Aₒ supplies the small matrix for the Kronecker product. The hyperbolic tangent and reshape produce a contribution in the required layout before summation. The resulting g_wₑᵢgₕₜ(eⱼ) is the correction added to C_wₑᵢgₕₜ.

The appendix compares the large tensor required for a direct projection with the smaller parameters in this construction. The part of the count it analyzes is the function that produces the label-conditioned weight correction.

O × (d_z × dₐ + dₕ / O² + O²) ≈ O × d_z × dₐ

Here × means multiplication and ≈ marks the approximation used in the paper’s parameter analysis. O counts the components. Within each component, d_z × dₐ counts the entries of the linear projection, dₕ / O² is the length of sₒ, and O² counts the entries of Aₒ. The approximation retains the dominant projection term for the paper’s setting. Treating the component count as fixed leaves the embedding width and adapter width as the main dimensions in that term. A direct projection also multiplies by the full encoder width.

In the default setup, both d_z and dₕ are 768, the adapter width dₐ is 64, and the component count O is 4. The authors report a 192× reduction for this construction compared with the direct projection. This compares ways of parameterizing the metadata-conditioned weight correction. The comparison of trainable parameters for whole systems uses a different denominator and is reported separately.

When attributes are missing or have several labels

During training, attribute dropout randomly masks attributes at rate r_dᵣₒₚ. This gives the system practice seeing otherwise usable examples with some metadata unavailable. The purpose is to approximate the conditions encountered when a label at evaluation time was never observed during training. The text remains available, as can other attributes. The training procedure gives the predictor a chance to use that remaining evidence without requiring a learned history for the missing value.

Multiple labels present a different problem. An arXiv abstract with several authors has multiple values in one field. A recipe can have multiple ingredients and multiple tags. An early-aggregation procedure combines their embeddings before running the attribute transformation. Injectors instead applies the transformation to each label and then adds the resulting contributions. The authors call this post-aggregation.

b_zⱼ = ∑ₖ g_bᵢₐₛ(eⱼ⁽ᵏ⁾) + c_bᵢₐₛ

Here eⱼ⁽ᵏ⁾ is the embedding of label k in field j. ∑ₖ adds the contributions over the labels of that field. g_bᵢₐₛ is the projection into the bottleneck bias, c_bᵢₐₛ is the learned offset added after summing, and b_zⱼ is the combined bias. Because g_bᵢₐₛ is linear, this expression corresponds to summing embeddings first and then projecting, provided the same sum and offset are used.

W_zⱼ = ∑ₖ g_wₑᵢgₕₜ(eⱼ⁽ᵏ⁾) + C_wₑᵢgₕₜ

Here ∑ₖ adds the separate weight corrections for the labels of field j. g_wₑᵢgₕₜ is the matrix-producing function, including its nonlinearity. C_wₑᵢgₕₜ provides the learned base matrix, and W_zⱼ is the combined down projection used by this field’s adapter. Each label contributes through the same function before the corrections are added. That order matters for a nonlinear function, since different sets of labels can have the same summed embedding and still produce different sums of separately transformed embeddings.

The aggregation is within the field. Ingredients produce one combined correction for the ingredient adapter, and tags produce another for the tag adapter. The field adapters still act in sequence. Summation also makes a field’s combined contribution independent of the order in which its labels are listed. That property suits a collection of ingredients, although it also means that order within a list of authors is unavailable through this operation.

How training produces the final classifier

The main experiments use the bert-base-uncased configuration. For inputs that would run beyond BERT’s 512-token limit, the authors concatenate the first and last 250 tokens. This retains material from both ends of a document, with any intervening portion left out for such inputs. The encoder supplies a final vector for the [CLS] token, a dedicated classification position. A trained logistic classifier converts that vector to logits, the scores used to predict the output class.

The pretrained weights remain fixed for Injectors. The trainable components include the task and attribute adapters, the metadata embeddings, and the classifier. General dropout and attribute dropout both use a rate of 0.2. The batch size is 8. The authors use Adam with weight decay at a learning rate of 3e − 5 and run for 200K training steps, with a linear warmup during the first 20K steps. These are the settings for the reported training procedure, while the comparison systems differ in which parameters they update. Decoupled Weight Decay Regularization

Most tasks use cross-entropy, which rewards assigning higher probability to the correct class. In Goodreads, the authors give the spoiler class a loss weight of 1.0 and the more common negative class a weight of 0.5. In Beeradvocate, each aspect has its own classifier. The system averages their losses while sharing the computation that produces their inputs. PolMed lacks a development split, so the reported setup follows the earlier dataset work in using 10-fold cross-validation.

Experiments and results

What AttrIB asks the systems to predict

The eight main datasets vary along several dimensions at once. Their texts range from tweets to recipes and reviews. Their training sets range from PolMed’s 4.5K examples to Beeradvocate’s 1.5M. Some datasets supply repeated, well-represented reviewer or product IDs. Others have many labels with few training examples. The dataset statistics count a label as sparse when it has less than 10 training examples. The cold-start variants apply a different criterion, measuring labels with zero training examples.

Y2013 and Y2014 use Yelp reviews to predict sentiment classes from the review, reviewer, and product. Each has 5 output classes. The Y2013 splits contain 62.5K training, 7.8K development, and 8.7K test examples. The corresponding Y2014 splits contain 183.0K, 22.7K, and 25.4K examples. IMDB uses the same kinds of attributes for a 10-class task and has 67.4K training, 8.4K development, and 9.1K test examples. All three report 0.0% sparsity at the threshold used for the main dataset statistics, making them a useful setting for studying metadata that has repeated training support.

AAPR asks whether an arXiv paper was accepted to a conference. It uses author identities and research areas, both of which can have several values for one paper. Its splits contain 33.5K training, 2.0K development, and 2.0K test examples. The combined attribute vocabulary is 51.6K, and 97.8% of labels are sparse by the paper’s definition. Thus the system has to combine lists while learning from limited occurrences of individual labels. To determine a tweet’s message type, PolMed considers the politician, the media source, the audience, and political bias. It has 9 output classes and a much smaller attribute vocabulary of 0.5K, but 63.8% of the labels are sparse. A smaller vocabulary can still present a sparsity problem when the dataset itself is small or frequencies are uneven.

How the new datasets were assembled

For Food, the authors take a recipe collection originally used for personalized recipe generation and repurpose it to predict duration. The target is the estimated number of minutes rounded down to the tens. The predictor receives the recipe text, user, ingredients, and tags. The authors remove recipes with durations below 5 minutes or above 150 minutes. They also exclude texts with fewer than 10 tokens or more than 500 tokens and apply a cutoff to tag lists with more than 50 labels. They remove tags that directly state a duration range, along with broadly applied labels such as the one indicating time to make. This keeps a tag that effectively states the answer from dominating the intended prediction task.

The authors shuffle Food and assign 10% each to development and test, leaving 80% for training. The benchmark table reports 162.4K training examples and 20.3K examples in each held-out split. The task has 16 duration classes, a vocabulary of 40.5K attribute values, and 80.0% sparse labels. Its inputs make the post-aggregation comparison particularly relevant, since both ingredients and tags can contain multiple values.

Good uses Goodreads reviews and asks whether each contains a spoiler. The metadata gives the reviewer, the book, and the rating. The authors assemble their own splits because the previously used split was unavailable publicly. They exclude reviews under 32 tokens and over 256 tokens. The dataset table reports 714.7K training examples, 10.0K development examples, and 10.0K test examples. The attribute vocabulary has 43.8K values, with 34.4% classified as sparse. The large training set coexists with an imbalanced target, so both the weighted loss and the choice of evaluation metric matter when reading its scores.

Beer uses Beeradvocate reviews to predict ratings for appearance, aroma, palate, and taste. The reviewer, the beer, and the overall rating are input attributes. The authors follow the same outlier-removal and splitting procedure as for Goodreads. The benchmark table lists 1.5M examples for training and 10.0K each for development and test. The attribute vocabulary reaches 98.0K, of which 75.3% is sparse. The classifier for each aspect predicts among 9 classes. Supplying the overall rating as input makes this an aspect prediction task conditional on a reviewer’s general judgment as well as the text and IDs.

The baselines and how to read the scores

The BERT-base and ordinary-adapter baselines use text alone. BERT-base establishes what happens when the pretrained parameters are fine-tuned for the task. BERT with ordinary adapters tests task adaptation with small trainable additions. The distinction helps isolate what is gained by adding metadata to adapters, since a comparison with BERT alone changes both the input and the training arrangement.

BERT with control tokens prepends metadata values to the text and classifies from the [CLS] vector. BERT with UPA uses attributes to alter the biases that enter the attention-pooling weights. BERT with CHIM uses attribute-dependent importance matrices to modify the logistic classifier’s weight matrix. These methods put metadata in different places, so their scores reflect differences in both the conditioning operation and its location.

MAA modifies the projections for queries, keys, and values in attribute-aware attention. The paper compares its own implementation with a smaller version, Tiny MAA, which uses a single additional Transformer layer and reduced dimensions. For the original MAA, the results table also lists previously reported scores where available. Those entries are useful context for the authors’ implementation, which scores differently on the review datasets. A RoBERTa-base comparison tests Injectors with another pretrained encoder. RoBERTa

The metric is accuracy except on Goodreads. Accuracy counts how often the predicted class matches the recorded class. Goodreads uses F1, which combines precision and recall and gives a view of spoiler detection that accuracy on an imbalanced collection might hide. For Beer, the reported figure averages the accuracies for the aspect classifiers. The main comparisons use the benchmark evaluation splits, with PolMed reported under its cross-validation procedure. The metric and task change across columns, so a Goodreads F1 value and an IMDB accuracy value answer different questions even when their numerical values are similar. Evaluation & benchmarks

Main classification results

Goodreads produces the largest lead highlighted by the authors. The BERT Injectors variant reaches 57.78 F1, and BERT with ordinary adapters is the next strongest BERT-based entry at 48.92. The paper reports the gap as 9.68 points. Its own MAA implementation scores 48.10, while control tokens score 44.79. Ordinary adapters are already effective on this task relative to fully fine-tuned BERT-base at 41.98 F1. The additional improvement for Injectors is therefore visible even against a baseline with the same general idea of adapting through small added components.

BERT-based systems on Goodreads spoiler detection, F1

Injectors has the highest F1 among the BERT-based comparisons.

BERT-based systems on Goodreads spoiler detection, F1BERT-base: 41.98BERT-base41.98BERT + ordinary adapters: 48.92BERT + ordinary adapters48.92BERT + control tokens: 44.79BERT + control tokens44.79BERT + MAA (authors’ implementation): 48.10BERT + MAA (authors’ implementation)48.10BERT + Injectors (this paper): 57.78BERT + Injectors (this paper)57.78
The numbers
System or settingF1
BERT-base41.98
BERT + ordinary adapters48.92
BERT + control tokens44.79
BERT + MAA (authors’ implementation)48.10
BERT + Injectors (this paper)57.78

The review sentiment tasks show gains even where the familiar baseline methods themselves make productive use of attributes. On Y2013, BERT Injectors reaches 70.86 accuracy. The authors’ MAA implementation scores 70.15, and the original MAA result is 70.3. On Y2014, Injectors reaches 71.69, compared with 70.51 for the authors’ MAA and 71.4 as originally reported. Distinguishing the two MAA rows matters because comparison with the reimplementation alone would suggest a larger lead on Y2014 than comparison with the original result.

For IMDB, the strongest text-only BERT result is 52.69 with ordinary adapters, and fully fine-tuned BERT-base scores 52.45. Several ways of adding metadata improve on both. UPA and Tiny MAA each reach 55.76, and the authors’ MAA implementation reaches 56.98. The original MAA figure is 57.3. BERT Injectors reaches 58.90 accuracy, extending a progression already visible among the alternatives that use metadata.

BERT-based systems on IMDB sentiment classification, accuracy

Several metadata methods improve on text alone, with Injectors leading the comparison.

BERT-based systems on IMDB sentiment classification, accuracyBERT-base: 52.45BERT-base52.45BERT + ordinary adapters: 52.69BERT + ordinary adapters52.69BERT + UPA: 55.76BERT + UPA55.76BERT + CHIM: 54.31BERT + CHIM54.31BERT + MAA (authors’ implementation): 56.98BERT + MAA (authors’ implementation)56.98BERT + MAA (original result): 57.3BERT + MAA (original result)57.3BERT + Injectors (this paper): 58.90BERT + Injectors (this paper)58.90
The numbers
System or settingaccuracy %
BERT-base52.45
BERT + ordinary adapters52.69
BERT + UPA55.76
BERT + CHIM54.31
BERT + MAA (authors’ implementation)56.98
BERT + MAA (original result)57.3
BERT + Injectors (this paper)58.90

On AAPR, BERT Injectors reaches 67.10 accuracy. CHIM is the strongest BERT-based alternative there at 65.30, followed by the authors’ MAA at 65.15. With PolMed, the cross-validation accuracy for Injectors is 47.27, while the best competing BERT-based result is 44.65 with Tiny MAA. The neighboring alternatives change from task to task. The method that is closest on paper acceptance is different from the one that is closest on tweet message type.

Food and Beer show another difference in which baselines are competitive. On Food, BERT Injectors scores 45.01 accuracy, compared with 43.97 for UPA and 41.89 for BERT-base. On Beer, Injectors reaches a mean aspect accuracy of 57.87, compared with 55.04 for the authors’ MAA and 50.48 for BERT-base. Food has two list-valued fields. Beer combines single-valued metadata with several output classifiers. The results show the same BERT Injectors architecture leading both sets of comparisons, under their respective metrics.

The paper marks a difference as significant using paired bootstrap resampling at p < 0.05. The test compares the competing predictions on resampled evaluation examples. The marked BERT-based wins are on Y2014, IMDB, and AAPR, as well as PolMed, Good, and Beer. Y2013 and Food are numerical leads in that table without the significance mark. The marks concern comparisons against the second-best BERT-based system. The stars in the charts identify the Injectors entries as the method under study.

What changes with a different encoder or training budget

RoBERTa with Injectors improves on RoBERTa-base in every column of the main results table. On Goodreads, the pair scores 44.12 and 60.73 F1, respectively. On IMDB, RoBERTa-base reaches 53.31 accuracy, and RoBERTa with Injectors reaches 60.32. The latter also exceeds the BERT Injectors accuracy of 58.90. On Y2013 and Y2014, the RoBERTa Injectors variant reaches 73.00 and 73.50 accuracy, respectively. These comparisons show that the adapter design works with both tested encoders.

Which encoder gives the highest Injectors score depends on the task. BERT Injectors reaches 47.27 on PolMed, compared with 46.26 for RoBERTa Injectors. On Food, BERT gives 45.01 with the method, while RoBERTa gives 44.19. On AAPR, the order reverses, with 67.10 for BERT and 67.30 for RoBERTa. These results capture behavior under the tested configurations. They do not isolate which aspects of the underlying pretraining account for the differences.

The parameter column is relative to fully fine-tuned BERT-base, shown as 1.00×, and excludes embeddings. BERT with ordinary adapters uses 0.02× in this accounting. Injectors uses 0.10× with either backbone, while the authors’ BERT MAA uses 1.50×. Tiny MAA is listed at 1.01×. The authors say they used one GeForce GTX 1080Ti GPU to train each system, with one exception: under the stated settings, BERT with the full MAA extension needed four GPUs for training across the datasets. They also report that unfreezing BERT in their final Injectors configuration gave no improvement over their frozen version. The result supports the chosen division of trainable parameters under these conditions.

What the ablations show

Bias, weight changes, and the task adapter do different jobs

The paper removes individual components from BERT Injectors and evaluates each resulting variant on the benchmark. The point of an ablation is to measure the effect of removing one design choice while keeping the rest of the system in place. These comparisons give more information about the architecture than the main baseline ranking, since a completely different baseline may change several aspects of training and prediction at once.

Both metadata-conditioned bias and metadata-conditioned weights contribute to the full system’s results. On Good, the full configuration scores 57.78 F1. Removing bias injection gives 57.06, while removing weight injection gives 57.61. The greater effect of the bias removal fits the possibility that an attribute can supply a useful prior for spoiler detection. The authors point to a reviewer’s tendency to reveal spoilers as an example. Since the ablation removes the bias route for the attributes together, it cannot establish that reviewer identity alone accounts for the effect.

PolMed gives a different ordering. The full configuration reaches 47.27 accuracy. Removing bias injection yields 46.67, while removing weight injection yields 45.66. The larger effect of removing the weights suggests that conditioning the transformation of the text is valuable on this task. In Beer, the full result is 57.87 mean aspect accuracy, compared with 57.67 without bias injection and 57.29 without weight injection. These comparisons show how the two routes can have different relative value even though they are built into the same adapter.

Removing the task-specific adapter lowers scores across the reported datasets. On Y2013, the full result is 70.86 accuracy and the variant without this adapter reaches 69.21. On Y2014, the corresponding values are 71.69 and 69.68. The result on Good is 57.78 F1 with the task adapter and 56.57 without it. The comparison shows that the ordinary task adapter contributes in the complete architecture. It cannot by itself distinguish the benefit of keeping task adaptation separate from the benefit of the added trainable capacity.

Dropout, label aggregation, and the compact weight construction

The variant trained without attribute dropout scores below the full configuration in every main dataset column. On AAPR it reaches 65.55 accuracy, compared with 67.10 for the full system. On Good it reaches 56.62 F1, compared with 57.78. Y2013 also declines, from 70.86 to 69.29 accuracy, even though its dataset statistics report no sparse labels at the benchmark’s main threshold. Randomly hiding attributes during training can help under the original dataset conditions as well as serving the intended purpose of preparing the system for missing labels. The ablation does not identify the reason for every improvement.

The clearest post-aggregation results come from the tasks with lists. On Food, the full configuration reaches 45.01 accuracy, while removing post-aggregation gives 43.30. On AAPR, the corresponding figures are 67.10 and 64.42. These are the two datasets marked as having multi-label attributes. Good and PolMed give the same scores with or without post-aggregation, at 57.78 F1 and 47.27 accuracy, respectively. The pattern ties the effects most directly to examples where there are several labels to combine. It also complements the formula: keeping each label available to the nonlinear weight transformation can matter when a field contains a real collection of distinct values.

The weight construction has two distinct controls. Removing the low-rank step makes training run out of memory in every column under the experimental setup. The result concerns feasibility on that hardware, so there are no predictive scores for the corresponding variant. Removing the hypercomplex construction allows training but gives lower results throughout the table. On IMDB, the score is 56.74 accuracy without that construction and 58.90 for the full system. On Good, the two scores are 55.99 and 57.78 F1. Together, the controls show the roles of the two pieces as implemented. One keeps the tested construction within memory limits, and the other improves the quality of the compact version that can be trained.

What happens when training leaves identifiers unseen

The synthetic cold-start benchmark uses Y2013 and IMDB with reduced training sets and the original development and test sets. Its nominal levels are 20%, 50%, and 80%, denoting the intended proportion of metadata labels unseen in training. The realized proportions differ slightly. In Y2013, the 20% variant has 38.7K training examples and 20.5% cold-start labels. At the 80% level, it has 2.4K training examples and 79.6% cold-start labels. In IMDB, the corresponding training sizes are 44.3K and 2.5K, and the realized cold-start proportions are 19.3% and 80.7%. These figures describe progressively less training text as well as less coverage of attribute labels.

Injectors leads the comparisons on both datasets at all three levels. On Y2013 at the nominal 20% level, it scores 67.89 accuracy against 67.03 for MAA and 65.24 for BERT-base. At 50%, the three scores are 64.32, 64.22, and 63.88. At 80%, Injectors reaches 59.23, MAA reaches 58.48, and BERT-base reaches 58.23. Tiny MAA falls to 57.68 at that last level. Its lower score than BERT-base is a concrete example of metadata injection losing value when the training conditions become more restrictive.

On IMDB at 20%, Injectors scores 55.62 accuracy, compared with 53.52 for MAA and 50.24 for BERT-base. At 50%, the corresponding values are 49.87, 49.25, and 47.77. At 80%, they are 41.78, 41.61, and 41.37. Tiny MAA scores 40.78 at 80%, also below BERT-base. The margin over MAA is especially small on IMDB at the highest cold-start level. The authors include HCSC, an earlier neural approach adapted for cold start, as a historical comparison. The strongest results come from the BERT-based approaches. The individual rows still matter. At IMDB’s 20% level, HCSC scores 50.5 and plain BERT-base scores 50.24.

IMDB-COLD accuracy at the nominal 80% cold-start level

Injectors remains ahead in the sparsest setting, with MAA and plain BERT close behind.

IMDB-COLD accuracy at the nominal 80% cold-start levelHCSC: 36.8HCSC36.8BERT-base: 41.37BERT-base41.37BERT + CHIM: 41.22BERT + CHIM41.22BERT + Tiny MAA: 40.78BERT + Tiny MAA40.78BERT + MAA: 41.61BERT + MAA41.61BERT + Injectors (this paper): 41.78BERT + Injectors (this paper)41.78
The numbers
System or settingaccuracy %
HCSC36.8
BERT-base41.37
BERT + CHIM41.22
BERT + Tiny MAA40.78
BERT + MAA41.61
BERT + Injectors (this paper)41.78

A useful feature of this experiment is that it holds the evaluation documents fixed within each review corpus while changing what the system sees in training. As more labels become cold-start, it also sees fewer training reviews. The scores characterize robustness to that combined change. They give an aggregate result over the evaluation set, where available metadata and training support can differ from example to example.

What metadata can say without reading the text

The appendix asks whether a label’s class frequencies in training are a good guide to the corresponding frequencies in development. For example, if a reviewer often assigns a certain rating in training, does that preference appear in their development examples? The authors estimate class distributions from the examples that contain the attribute and compare them with the corresponding development distributions.

q_z(y) = (∑ₓ∈D_z 𝟙(x, y)) / |D_z|

Here q_z(y) is the training frequency of class y among examples with attribute value z. D_z is the subset of training examples that contain z, and x in this formula is an example in that subset. The indicator 𝟙(x, y) returns 1 when the example belongs to class y and 0 otherwise. The sum counts matching examples, and |D_z| is the size of the subset used as the denominator. The paper denotes the analogous development distribution by p_z(y).

The comparison uses KL-divergence, a measure of how far one probability distribution is from another in a specified direction. Lower values in this analysis indicate a closer fit to the development distribution. The references are a uniform distribution and the overall class distribution, which the paper calls its majority baseline. This is a diagnostic of metadata-derived priors. It evaluates class frequencies without the classifier’s text representation.

On Y2013, the overall class distribution has a divergence of 1.358. Using the user alone gives 1.406, and using the product alone gives 1.419. Combining the attributes lowers the divergence to 1.265. On IMDB, the overall distribution gives 2.087, and the combination gives 1.873. A label can contribute to a useful combined signal even if its class-frequency distribution is a relatively poor guide by itself.

PolMed illustrates the importance of which attributes are combined. The audience field alone gives 3.640, while the uniform baseline gives 2.195. Using all attributes gives 1.770. The authors report that using media source and audience together gives 1.726, their best configuration for this analysis. The result is consistent with the same attribute being weak as an isolated prior and useful in combination. As the authors suggest, a classifier may also find that its usefulness depends on the text. The frequency diagnostic cannot measure that text-dependent effect directly.

Whether the attribute adapters can transfer

Beer supplies related targets with the same metadata fields. The authors use this to test whether a component trained to use reviewer, beer, and overall-rating information for some aspects remains useful for a different aspect. They partition the training data by aspect for the transfer experiment so that source and target training examples do not overlap. In each run, the source learns to predict the other aspects. Its attribute-specific parameters are then carried to the target and held fixed while the task adapter and classifier are trained for the target aspect.

On appearance, the directly trained Injectors system scores 55.58 accuracy. With attribute parameters transferred from the other aspects, it reaches 56.23. For aroma, the corresponding scores are 53.62 and 55.48, with the paper reporting a relative improvement of +3.47%. For palate, they are 55.44 and 55.63. Taste improves from 59.39 to 60.27. The benefit varies across aspects, but each transferred Injectors configuration improves over its directly trained comparison.

The same procedure produces lower scores for MAA on all the aspects. On aroma, for example, its directly trained version reaches 51.79, and its transferred version reaches 50.57. The contrast gives evidence for reusing the separate attribute components of Injectors on related tasks. A source that has learned something about how reviewers and beers relate to several aspect ratings can help the target learn its own decision with those attribute parameters fixed. The design and results leave open how much of the benefit would survive a larger change in task or domain.

Limitations

Limits the authors identify

The authors leave transfer to substantially different tasks for future work. Their Beer experiment uses a collection where the text genre, metadata types, and general goal remain closely related across the aspect predictors. They point to the lack of datasets with common attributes across different tasks as an obstacle to a broader test. The experiment supports reusing attribute parameters under a shared review setting, while transfer to a distant task with the same kinds of identifiers remains an open question.

The authors also leave much larger attribute vocabularies and generation for future work. They propose studying settings with millions of attributes. In the tested predictor, constructing a weight correction from small pieces saves projection parameters, while each known categorical value still has a learned embedding. The results on vocabularies such as Beer’s 98.0K therefore establish a scale at which the method was tested. They provide no direct measurement at the larger scale the authors propose. The generation question likewise changes the job of the system. In these experiments, metadata helps select a recorded class. Generating text would require evaluating what metadata changes in the produced language.

The cold-start results are also qualified by the setting the authors created. They point out that the gains are smallest for the sparsest datasets, which also have smaller training splits. In an application where many identifiers are new and little labeled text exists, the reported lead therefore gives a much narrower indication of benefit than the original benchmark comparisons.

What the setup leaves unresolved

The synthetic cold-start design changes two conditions together. Reducing the training set deprives the encoder’s trainable components of labeled text and makes some attributes entirely unseen. To measure the independent contribution of label coverage, a comparison would need to vary coverage at a fixed quantity of training text. Moreover, the paper reports overall test accuracy rather than a breakdown by whether each example has a familiar reviewer, a familiar product, both, or neither. Those aggregate gains can coexist with very different behavior among those groups.

The results establish predictive associations in particular datasets. The Goodreads analysis, for instance, is consistent with reviewer tendencies supplying a helpful prior. A reviewer ID could encode multiple recurring patterns, and the ablation removes contributions from several fields at once. The experiment does not establish which underlying behavior the classifier learned about any individual. Likewise, AAPR evaluates prediction of the recorded acceptance outcome using abstracts and metadata. That setup measures agreement with those outcomes rather than independently assessing scientific quality or the effect of changing an author name on a real decision.

Metadata can also be unusually close to the target. Food’s tag filtering addresses an explicit route by which a duration label could give away the answer. Beer intentionally supplies the overall rating when asking about its component ratings. Both are legitimate parts of the defined tasks, but they show why the meaning of a metadata gain depends on the available input at prediction time. The experiments do not say how the scores would change if a consumer had to predict the aspects before an overall rating existed, or if a deployment collected attributes through a different process.

The efficiency results concern trained parameters, memory feasibility on the authors’ hardware, and the compact parameterization of the weight correction. The table excludes embeddings, which are particularly relevant for vocabularies of user, product, or author IDs. The trainable parameter ratios give no direct measurement of latency or throughput. Combining the corrections of several labels and applying adapters inside the encoder introduces computation whose practical cost depends on the workload. The stated hardware comparisons are sufficient to discuss which tested configurations fit, while performance at deployment scale remains unmeasured.

The paper motivates the compact construction with a rank argument. The outer product does have rank at most one, and the Kronecker step can increase the rank available from that factor. The computation also includes an elementwise nonlinearity and a reshape, after which the original rank calculation does not directly apply. Adding a learned base matrix further affects the rank of the final projection. The parameter count and ablation results can be read independently of a strict rank bound on that final matrix. A related distinction applies to post-aggregation. Nonlinear transformation before summation can preserve differences that early summation would erase, but the learned transformation and sum do not by their form alone guarantee that every distinct label collection has a distinct representation. The direct evidence is the held-out improvement on the list-valued tasks.

What came after

No later study is documented here that tests or extends AttrIB or Injectors. The paper identifies several continuations whose outcomes remain open: testing much larger vocabularies, transferring attribute adapters to more distinct tasks that share identifiers, and conditioning text generation on metadata. Its Beer experiment provides the starting result for transfer, where the reused components improved predictions across related rating aspects. Its benchmark provides the classification comparisons for work on sparsity and cold start. Evidence that either result carries over to the broader settings would require a separate evaluation.

Cite

Cite as Reinald Kim Amplayo, Kang Min Yoo and Sang-Woo Lee. 2022. Attribute Injection for Pretrained Language Models: A New Benchmark and an Efficient Method. Proceedings of the 29th International Conference on Computational Linguistics.

The paper itself, not this page. BibTeX from the library's record of the work.

@inproceedings{amplayo2022attribute,
  title = {{Attribute Injection for Pretrained Language Models: A New Benchmark and an Efficient Method}},
  author = {Reinald Kim Amplayo, Kang Min Yoo and Sang-Woo Lee},
  booktitle = {Proceedings of the 29th International Conference on Computational Linguistics},
  year = {2022},
  url = {https://aclanthology.org/2022.coling-1.88/}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/amplayo-2022-attribute-injection-pretrained-language-models/