COFFEE : Counterfactual Fairness for Personalized Text Generation in Explainable Recommendation (2023)

Abstract: As language models become increasingly integrated into our digital lives, Personalized Text Generation (PTG) has emerged as a pivotal component with a wide range of applications. However, the bias inherent in user written text, often used for PTG model training, can inadvertently associate different levels of linguistic quality with users’ protected attributes. The model can inherit the bias and perpetuate inequality in generating text w.r.t. users’ protected attributes, leading to unfair treatment when serving users. In this work, we investigate fairness of PTG in the context of personalized explanation generation for recommendations. We first discuss the biases in generated explanations and their fairness implications. To promote fairness, we introduce a general framework to achieve measure-specific counterfactual fairness in explanation generation. Extensive experiments and human evaluations demonstrate the effectiveness of our method.

## introduction personalized text generation (ptg) has extensive applications, such as explainable recommendation @xcite , post generation @xcite , and conversational systems @xcite @xcite . the auto-generated text, functioning at the frontier of human-machine interaction, influences users' decisions and transforms their way of thinking and behaving. however, due to its immense power and wide reach, ptg can inadvertently give rise to fairness issues and lead to unintended consequences @xcite @xcite . in this work, we investigate the fairness issues in ptg, focusing on one of the mostly studied settings: generating natural language explanations for recommendations @xcite @xcite @xcite . personalized explanation generation aims to provide a user with descriptive paragraphs on recommended items that align with his/her preferences, enabling more informative and accurate decision-making. the generators are typically language models trained on user written reviews from e-commerce platforms @xcite @xcite , where sentences related to item descriptions are retained to construct the ground-truth explanations. however, due to historical, social, or behavioral reasons, inherent bias may exist within the review text, associating specific linguistic characteristics with the users' protected attributes such as gender or race @xcite @xcite . while certain linguistic features that capture the diversity of language use @xcite are suitable for personalization, others pertaining to the linguistic quality of explanations, such as informativeness or detailedness, @xcite , should be excluded. failure to do so can result in unfair treatment when serving users. as an example, we investigate the explanation generation on amazon movies 1 with the personalized transformer model peter @xcite . we adopt feature coverage (featcov, the number of unique features mentioned about a movie) as an automatically measurable metric of explanation 1 the details about experiment setup is in section 6. quality. as shown in figure 1 (left), reviews from male users generally have higher featcov on the target movies than those from female users @xcite foot_0 . a model trained on such data can inherit the bias and generate explanations discriminately when serving users-higher featcov for males than females, as indicated in figure 1 (right). to further substantiate the bias issue, we conducted a user study and found strong positive correlation, shown in figure 2 , between featcov and human evaluated quality criteria including informativeness, detailedness and helpfulness. the observations remain consistent when results from male and female human evaluators are analyzed separately, affirming that both genders consider featcov a significant indicator of quality. this study demonstrates the bias in featcov as a concerning issue for ptg. details of the user study are in section 7. in particular, the bias observed in training data originates from various factors such as different demographic behavior patterns that are beyond our control. but the system should not inherit the bias and act discriminately by generating explanations of different quality for different users-the lack of informative reviews from users of a demographic group should not prevent them from receiving informative explanations. without proper intervention, the system can exhibit such bias, thus adversarially affecting the users' experience, reliance and trust in the system @xcite . from a broader perspective, the bias can reinforce itself by influencing how users write online, and jeopardize fairness in the long run @xcite @xcite . to mitigate the issue, we take a causal perspective to dissect the bias and enforce counterfactual fairness (cf) @xcite in personalized explanation generation: the quality of generated explanations should not differentiate a user in the real world vs. in the counterfactual world where only the user's protected attribute (e.g., gender) is changed. this problem is essential and unique compared to fairness problems in the literature (section 2), and imposes specific technical challenges (section 4). to achieve the goal, we develop a general framework, coffee, for counterfactual fairness in explanation generation. coffee treats a user's protected attribute value as a separate token input to the model, and disentangles its representation from the user's representation @xcite @xcite . by controlling the input attribute values for counterfactual inference (ci), we impose a measure-specific cf constraint @xcite on generated explanations. then a novel fair policy learning scheme is developed to optimize cf with carefully designed rewards, which generalizes to any single or combination of quality measures. we use user-side fairness by default in discussions, but coffee is general to ensure fairness on either user or item side in the two-sided market @xcite , and be adapted to different models. extensive experiments and rigorous user studies demonstrate coffee's superiority in achieving fairness and maintain high generation performance compared to baselines. ## background uniqueness and importance: fairness in machine learning (ml) is originally studied in automatic decision-making systems that directly impose "significant" or "legal" effects on individuals (voigt and bussche, 2017). such fairness considerations often revolve around resource allocation by ml models, exemplified in contexts like loan assessments (lee and floridi, 2021) or job applications @xcite , where model predictions can unfavorably affect a protected group @xcite . in contrast to resource allocation fairness, nlp researchers primarily examine the representational fairness @xcite @xcite regarding how language models shape social biases and stereotypes through natural language understanding (nlu) or generation (nlg). in the realm of nlg, fairness particularly concerns how generated text may contain biased information about a specific demographic group. for instance, @xcite analyze the sentence completion by a gpt-2 model, and find dif-ferent sentiment distributions of completed sentences when the occupation word is counterfactually changed in the prompts. @xcite revealed a more frequent co-occurrence of the 'doctor' with male pronouns and 'nurse' with female pronouns in generated text. however, these biases, directly encapsulated within the text, can be more easily analyzed. to the best of our knowledge, our work is pioneering in exploring how personalization, bridging nlp and recommendation, associates the bias in nlg with protected attributes of users. fairness notions: various fairness notions exist in the literature, with group-wise fairness notions being the firstly studied ones @xcite @xcite . yet, group-wise fairness has different quantitative definitions that are generally incompatible @xcite . some definitions can even exacerbate discrimination @xcite . individual fairness @xcite requires similar users to receive similar predictions. but it relies on carefully chosen domain-specific similarity metrics @xcite . in contrast, counterfactual fairness (cf) @xcite , considering fairness from a causal perspective, has gained prominence recently as a more robust fairness notion @xcite @xcite , which can also enhance group-wise fairness in certain scenarios @xcite . though cf has been studied in some nonpersonalized nlp tasks @xcite , most existing works study the dependency of model outputs on attribute-specific words within the input text @xcite @xcite . in such cases, ci can be easily performed on the input text itself, such as changing male pronouns to female pronouns @xcite . however, cf in ptg necessitates ci on the protected attributes of users being served-an area yet to be thoroughly explored. ## problem formulation in the following discussions, we consider a single protected attribute on the user side for simplicity, but our proposed framework is versatile to accommodate multiple attributes on either the user or the item side. the value of a user's protected attribute is denoted by a variable @xmath0, where a is the set of possible attribute values, e.g., @xmath1, f emale, other} for gender. each dataset entry is a tuple of (u, i, a, e), corresponding to user id, item id, observed attribute value, and ground-truth explanation. the explanation generator g θ is a language model parameterized by θ. given a user u, an item i, and observed attribute value a, an explanation can be sampled from the generator as y ∼ g θ (u, i|@xmath2. the linguistic quality of any explanation y is measured by a function q(y). notably, we treat q as a black box oracle-a quality measure that can only be queried. this is essential in practice and offers the flexibility to arbitrarily tailor q based on the fairness requirements of the application. an explanation can be gauged in various ways by customizing q, such as using an explicit function, human evaluation, or a tool provided by authorities. we assume, without loss of generality, that higher q values represent superior quality. cf on any measure q of explanations is achieved when, given a user u and an item i, for ease of presentation, we consider a single useritem pair, and the total loss on a dataset is simply summed over all user-item pairs with the constraint applied to every pair. in this work, we apply the first-order moment of the quality of generated explanations to construct the constraint, and leave the extension to other moment-matching constraints for future work. we further simplify the expression of the constraint as e[q(y a←a )] = e[q(y a←a ′ )]. figure 3 : given a user with attribute value a and a recommended item, coffee performs ci by switching the attribute value to a ′ to get the counterfactual user, which is achieved by disentangled attribute embeddings. explanations y for both the real user and the counterfactual user are sampled from the generator, evaluated by q. coffee then updates the generator's parameters θ by policy learning from the fairness constraint. ## coffee user and item ids are conventionally input to the generator for explanation generation, represented as learned embedding vectors @xcite @xcite . however, the user's protected attribute, entangled with their preference, is implicitly encoded in the representations @xcite , hindering its direct manipulation for ci. one way explored for cf in personalization involves removing all information about the protected attribute in representations via discriminators @xcite @xcite . although this improves fairness, it detrimentally affects personalization and eliminates desired characteristics linked to the protected attribute. in contrast, we aim to enforce the independence of the protected attribute from any specified quality measure q on generated explanations, while preserving explanation content-dependence to sustain high personalization performance. to enable ci, coffee considers a user's protected attribute value as a separate token input to the model, along with user and item ids, and learns disentangled attribute representations from the user representation to encapsulate the effect of each attribute value in explanation generation @xcite @xcite . this mirrors methods in controllable text generation @xcite @xcite , where disentangled attribute tokens are utilized as inputs to modulate the topic, sentiment, or style of generated text. ci is then achieved by altering the attribute token input to the model. subsequently, we enforce a fairness constraint based on the explanations generated pre and post ci, and establish a policy learning method for optimizing this constraint. an illustration of the coffee framework is shown in figure 3 . ## applying coffee to existing models existing models for personalized explanation generation mostly adopt either transformer @xcite or rnn @xcite @xcite . in this section, we demonstrate the application of coffee to peter (li in peter @xcite , user and item ids, represented as special tokens, are appended to the start of each explanation sequence before being inputted to transformer layers. a context prediction loss is introduced for enhanced personalization in addition to the nll loss, which predicts the words in the explanations regardless of their order. we denote the overall loss as l peter , which is the sum of the nll loss and context prediction loss @xcite . to apply coffee to peter, we introduce an attribute token at the start of each sequence for disentangled attribute embedding. the discriminator is applied at the input embedding layer to enhance disentanglement. user, item, and attribute tokens can attend to each other, while the explanation words can only attend to past tokens. when applying coffee to peter, the loss is constructed by replacing l gen in eq. ( 3 ) by l peter . ## experiments we conduct experiments on three public review datasets: amazon video games, amazon movies & tv, and yelp restaurant, and compare coffee with multiple baseline models. due to space limit, we present the results based on peter, and put example explanations and results based on nrt in appendix e. ## human evaluation we conduct human evaluations to justify the use of featcov for fairness and confirm coffee's efficacy. human evaluators, recruited on mechanical turk, are asked to assess explanations generated from amazon movies' test data, as movies are 2.5577 more universally understood. in each questionnaire, we present the title of a recommended movie for a user, randomly sampled from the dataset, along with two explanations: one generated for the real user and the other for a counterfactual user with a modified gender. evaluators then assess each explanation from three criteria: informativeness, detailedness, and helpfulness. each criterion is rated on a scale of 5: 1: "not at all", 2: "somewhat", 3: "moderate", 4: "very", 5: "extremely". we also collect evaluators' gender (only for aggregated analysis) to examine if humans with different genders evaluate the explanations differently. rigorous privacy protection and quality control mechanisms are implemented. we compare the explanations generated from the raw model and coffee, with 150 valid questionnaires collected for each. we measure fairness in the three human evaluated criteria of explanations. the results are shown in ## conclusion we investigate the fairness problem in ptg by focusing on the bias in featcov of explanation generation. we propose coffee for achieving counterfactual fairness in explanation generation. comprehensive experiments and human evaluations show the efficacy of coffee in achieving fairness without hurting the utility of explanations. this work opens the new direction of quality fairness in ptg. we anticipate that this work will encourage researchers to investigate novel fairness notions in this problem, based on different quality measures, and conduct in-depth analyses on their social impacts. a promising direction is to involve humans in the loop for direct fairness optimization on human evaluated measures. we also plan to generalize the coffee to other ptg settings, such as conversational systems.