Exploration and practice of LLM in e-commerce recommendation system




This article sorts out and discusses the combined paradigm of LLM+recommendation, and attempts to transfer the emerging capabilities of LLM to the recommendation system, using the general knowledge of LLM to assist recommendations and improve recommendation effects and user experience.



background

The e-commerce recommendation system (Recommend System, RecSys) is a personalized system based on users' historical behavior and interest preferences. It can provide users with accurate and personalized product recommendations and promote users' shopping experience and consumption satisfaction. A mature RecSys usually adopts a pipeline cascade structure, including various modules such as recall, rough sorting, fine sorting, and rearrangement, and has a high degree of professional field characteristics. With the popularity of ChatGpt, large language models (LLM) have begun to emerge in more and more fields. LLM is a natural language processing technology based on deep learning that can learn language rules and patterns from large-scale corpora. When the model parameters exceed a certain scale, the performance improves significantly, and LLM begins to show emergence and generalization capabilities. The huge parameters store a large amount of general world knowledge, and it also has language understanding and expression capabilities.


Comparing RecSys and LLM, the former is a data-driven system that relies on the e-commerce ID system to model users or items. It lacks semantics and external knowledge information, and has problems such as information cocoon, cold start, insufficient diversity, and inability to recommend cross-domain information. ; The latter lacks proprietary data information in the recommendation field, does not have the sequence processing and memory capabilities of traditional recommendation models, and has high computational complexity and high training and inference costs.


A natural idea is: how to transfer the various capabilities emerging from LLM to the recommendation system through a suitable paradigm, and use the general knowledge of the LLM large language model to assist recommendation and improve the recommendation effect and user experience.


The integration of LLM and recommendation


Currently, there are many explorations about LLM and recommendation in the industry. According to the coupling strength between LLM and recommendation system, there are two modeling paradigms:

Two integration methods of LLM and recommendation [1]: 1. LLM + recommendation (left) 2. LLM as recommendation (right)


▐Method 1: LLM + recommendation  


This modeling paradigm treats the language model as a feature extractor, designing the original information of items and users (such as the title/attribute/category of the item, the user's click sequence/context) into prompts, inputting it into the LLM and outputting the corresponding The embedding or semantic summary information is subsequently used as features or to mine the user's potential interest preferences through semantics, and is eventually integrated into the decision-making process of the recommendation system.


  • LLM Embedding


In the traditional recommendation field, numerical IDs without semantics are often used to represent products and text information, and sparse one-hot is used to encode ID features. The feature encoding is designed as a simple Embedding Look-up Table. Even features rich in textual semantics (such as product titles and attributes) are unified into ID codes, resulting in information loss at the semantic level. With the rise of language models, an intuitive way is to use language models as encoders to obtain embedded representations of text information such as product titles/attributes, and combine it with the ID-based one-hot encoding mode of the recommendation system. Typical work includes: U-BERT[2] encodes user review content to enhance the user's personalized vector representation, and finally obtains a dense embedding vector; UniSRec[3] achieves this by encoding product title/user behavior sequence Cross-domain sequence recommendation goals.


  • LLM Summary


This type of work uses LLM to summarize the original corpus information of products/users and generate streamlined semantic expressions for use in subsequent recommendation modules. For example, Liu [5] et al. proposed a generative news recommendation framework GENRE based on LLM. By constructing data such as news titles and categories into prompts, LLM is stimulated to generate relevant information such as news summaries and personalized news based on its general knowledge. On the one hand, these generated information are used to iteratively optimize LLM generation; on the other hand, they are used to train the news recommendation model and supplement the knowledge information of the recommendation model.


GENRE[5], a generative news recommendation framework based on LLM


GPT4Rec[6]将LLM模型用于用户意图理解,根据用户的行为历史,进行兴趣抽取并生成中间的语义query,用于后续的推荐召回。如下图所示,其主要分为两步:首先根据用户历史交互的商品和它们对应的标题,通过prompt格式化后,使用GPT2来生成可以表征用户多个兴趣的“search query”。然后将GPT2生成的query提供给搜索引擎,以检索要推荐的商品,从而提高推荐召回的相关性和多样性。


GPT4Rec:query生成+搜索引擎


  方式2:LLM as 推荐


与融合方式1不同,这个范式的目标是直接将预训练的LLM转换为一个强大的推荐模型,用来替换推荐系统(召回->粗排->精排->重排)的一个或者全部模块。输入序列通常包括简介描述、行为提示和任务指示,输出就是最终的推荐结果。"LLM as 推荐"是一种非常理想的推荐范式,极其依赖于LLM模型强大的语言理解、逻辑推理和文本生成能力。


  • LLM as Ranker


此类工作[7][8]将推荐问题形式化为给定条件的排序任务,其中用户的历史交互作为条件,推荐系统召回得到的商品作为候选。通过设计合适的prompt模版,结合条件、候选、排序指令,使得LLM为候选的商品进行打分或者排序。实验证明,LLM在Zero-Shot场景具有较好的零样本排序能力,但在排序时不可避免地有position bias和popularity bias问题。


基于LLM的“零样本”排序方法[7]


  • LLM as RecSys


以Chat-Rec[9]为例。Chat-Rec将LLM视作推荐系统的枢纽,通过prompt链接LLM和推荐各个模块,通过用户与LLM的多轮对话,不断缩小推荐候选范围,并最终给出精准的推荐结果和推荐理由。具体包括:将用户的行为足迹等转换为prompt,让LLM学习到用户偏好;然后进一步地将用户的推荐历史和推荐系统生成的候选集输入到LLM,让LLM执行过滤和排序,完成多轮推荐。


Chat-Rec:将LLM视作推荐系统的枢纽


算法方案


当前的LLM在精准性上和推荐模型相差甚远,同时受限于LLM模型极大的推理耗时,无法满足在线推荐系统毫秒级的时延限制,短期内不具备将LLM模型用于在线推理的条件。于是我们更多地采用"LLM + 推荐"的方式,去利用大模型的知识和推理能力,提高推荐模型对商品信息、上下文、用户行为序列的知识表达,包括:

  1. 借助LLM通用知识信息,构建类目搭配体系,引入推荐系统在推荐召回侧引入搭配I2I、排序侧进行类目兴趣扩展建模,提高推荐的多样性。

  2. 借助LLM文本推理能力,辅助商品/用户理解。我们使用LLM将电商Item冗余文本信息进行去噪提纯和改写;结合用户行为序列、上下文以及用户画像,进行用户行为sumarry总结。并通过预训练语言模型,将文本知识结果进行embedding向量化表征,与传统的推荐模型进行知识感知嵌入,提高模型的知识表达。


LLM在推荐的应用


  基于LLM知识能力的类目搭配推荐


经过多年的沉淀,电商平台已经拥有了一套完整的类目体系。这套类目体系通常采用树状结构,通过层层拆解,最终将一个商品映射到一个末级类目,不同末级类目之间相对独立。现有的类目体系无法体现出这类目之间存在的搭配信息,缺乏跨类目的搭配关系表达。同时,相较于品牌和卖家,类目可以更加显式地与用户兴趣进行聚合和映射。在推荐场景之中,给用户准确地推荐相关商品的同时,如果能够挖掘不同兴趣之间的隐藏关系,基于搭配进行发散推荐,将给用户带来新的惊喜感、实现用户需求和兴趣的扩展。


类目体系:休闲裤和衬衫分别属于一级类目(男装)下面的不同二级类目,而男帆布鞋又挂载在另一个一级类目(流行男鞋)上。


传统的类目关系挖掘往往基于知识图谱,采用距离度量、聚类、行业规则、协同过滤等方法。这些工作大都需要繁杂的数据清洗、算法挖掘和行业专家知识。LLM大模型的出现,让快速、高效的电商知识构建变成了现实。


  • LLM搭配类目

LLM搭配类目的整体生产链路如图所示,主要包括三个部分:1. 基于站内类目体系,设计prompt template;2. 批量调用LLM模型,请求LLM知识;3. 进行知识抽取和站内类目ID映射。


LLM搭配C2C的生产链路


prompt设计

LLM的最终效果非常依赖prompt的设计,设计prompt技巧可以参考吴恩达的课程[10]。以下是我们针对“LLM返回搭配类目”这个问题尝试的几种prompt效果。可以看到,当添加:"1.用逗号分隔,2.返回格式为'''类目1,类目2,类目3...''',3.不包含【cate_name】这个词,4.搭配类目丰富"这些限制后,LLM返回结果具有不错的效果,搭配类目的多样性也基本上能够符合预期。


LLM模型选择


业界主流的开源LLM模型/服务如下。最终我们选择通义千问模型,进行搭配信息的获取。

  1. LLaMA(Large Language Model Meta AI)[11]:由 Meta AI 发布的一个开放且高效的大型基础语言模型,其数据集来源都是公开数据集,无任何定制数据集。

  2. ChatGlm6B[12]:一个开源的、支持中英双语的对话语言模型,基于 General Language Model (GLM)架构,具有 62 亿参数。

  3. 通义千问:阿里云推出的一个中文LLM模型,功能包括多轮对话、文案创作、逻辑推理、多模态理解、多语言支持等。

  4. 百川13B:Baichuan-13B 是由百川智能继 Baichuan-7B 之后开发的包含 130 亿参数的开源可商用的大规模语言模型,在权威的中文和英文 benchmark 上均取得同尺寸最好的效果。

  5. chatgpt[13]:openAI基于GPT-3.5(Generative Pre-trained Transformer 3.5)架构开发的对话AI模型。


站内类目ID映射


由于LLM模型返回的是通用知识信息,存在与站内的类目体系无法完全对应的情况。为了便于后续推荐各个模块使用,兼容现有的电商推荐链路,我们进一步将LLM搭配类目映射成站内类目ID。站内类目ID映射可以采用以下两种方法:

  1. 基于文本相关性的向量召回。将LLM搭配类目和站内类目分别表征成文本embedding向量,然后通过向量召回的方式,选取与LLM搭配类目距离空间最近的top站内类目进行映射。

  2. 基于站内后验统计的query2cate映射。将搭配类目作为query,根据电商平台搜索query2cate的统计数据,使用该query下top的点击cate作为映射类目,实现LLM搭配到站内ID的映射。


  • 精排兴趣扩展


我们尝试在排序中引入搭配信息,从序列建模的角度进行优化从而实现兴趣拓展。

序列扩展建模:推荐排序模型通常使用target-attention对用户行为序列进行建模,当序列商品与target商品相关性越大时,会被赋予更大的权重。为了更好的表达用户的类目兴趣,我们在CTR预估模型中新增了一个类目点击序列,同时通过近邻类目表征的方式,实现类目兴趣的扩展。具体地,我们在target和序列侧的sideInfo分别新加一个搭配类目emb来进行信息扩展,搭配类目emb计算规则为:

其中,为target类目t的一个搭配类目。


序列兴趣扩展 


目前,基于LLM搭配类目的精排兴趣扩展模型已经在我们的推荐场景全量,ab效果:uctr+0.83%、人均ipv+2.58%、人均点击叶子类目数+2.06%。


  基于LLM文本能力的商品语义表征


描述商品的文本信息主要包括title、类目以及CPV属性数据。对于商品类目以及属性信息,通常将其通过multi-hot的方式进行编码转化成特征向量。得益于成熟的规范化的商品类目体系,采用这种方式对商品类目信息进行编码是符合直觉的。但是由于商品种类复杂,不同商品的属性往往千差万别,采用mutli-hot形式对商品属性进行编码可拓展性不高,容易产生数据稀疏问题。

同时,商品标题是商品固有的内容类数据,其往往是对属性类特征的延伸。为了最大化商品搜索流量,商家在命名商品标题时通常会添加一些与商品本身无关的修饰词(比如“特价”、“爆款”等),同时也包含一些冗余的类目词。商品标题语义上并不连贯,信息凌乱,直接进行mutli-hot或者文本编码难以得到很好的嵌入表示。


一种可行的解决方案是将对商品零散的信息转换成语义连贯的文本,然后通过pre-train语言模型进行编码。对此,我们借助LLM蕴含的强大的语言表达能力和逻辑推理能力从商品标题中抽取出关键信息,从而实现对商品标题的正则化,得到语义连贯的文本描述,再对其进行编码,从而丰富商品的特征。


  • 商品正则化


我们尝试使用LLM对商品标题进行正则化,并通过 困惑度 [14]衡量正则化后文本的语义连贯性。考虑到商品标题大多为相关词的组合,于是我们先将商品标题进行分词得到描述词列表,同时结合商品的属性列表,限制LLM选出关键词输出商品的简短描述。具体步骤如下图所示。

你现在是一个买家。给定商品的描述词【A】以及各种属性【B】,请根据关键词和关键属性描述出商品是什么。要求是只需要回答是什么,不要补充其他内容,尽量从A和B中选出词语进行描述,字数不超过40,回答模版为:这个商品是...。比如当A=['giyo', '公路', '山地车', '专用', '自行车', '单车', '专业', '骑行', '手套', '半指', '夏季', '男', '硅胶', '减震', '女'],B=['尺码': 'XXL', '类目': '自行车手套', '适用对象': '通用', '颜色分类': '弧光半指-黄色-双面透气+GEL硅胶+劲厚掌垫', '上市时间': '2016年夏季', '货号': '1183', '品牌': 'GIYO/集优', '款式': '半指手套'],输出:这个商品是GIYO牌的自行车半指手套。现在A=...,B=...


抽取部分样本结果如下表所示。


随机抽取100条样本统计平均困惑度,从下表可见,正则化后的商品描述文本困惑度显著下降,表明其语义程度比原始的商品标题更加连贯。



  • 商品语义向量-引入排序模型


借助Modelscope的CoROM模型[15],我们对正则化后的商品标题文本进行了向量化抽取,并作为特征加入基于双塔结构的DSSM粗排模型中[16]。我们分别做了以下几个实验:
  1. 实验1:模型结构不变,用corom向量替换mind[17]向量对itemid做初始化(包含序列特征+item Tower特征),其他向量重新初始化。

    • auc:0.73158 (-1pt)

  2. 实验2:模型结构不变,用corom向量替换mind向量对itemid做初始化(包含序列特征+item Tower特征),其他向量用base模型warmup。

    • auc:0.73434 (-0.7pt)

  3. 实验3、模型结构不变,在item tower额外添加一个新特征corom向量,原所有向量用base模型warmup。

    • auc:0.74233 (+0.064pt)


从实验结果中不难发现,用商品标题抽取的文本语义特征相比于用户行为学出来的ID类特征(mind向量)仍然处于劣势,但在mind基础上新增语义向量有着正向效果。因此,语义特征加入模型的较合理方式仍然是做为ID特征的补充而不是替换。此外,由于各种语言大模型中的embedding维度较高,加入模型需要占用大量的存储空间,因此embedding的降维也显得尤为重要,目前我们调研到的一种比较简单有效的降维方式是BERT-whitening[18],供大家参考。


总结展望


可以预见的是,随着LLM模型的发展和优化,LLM将从推荐系统的一种高效的辅助工具,逐渐成为推荐系统的一部分或作为推荐系统的骨干网络进行推荐内容的生成或排序。结合现阶段的LLM能力,我们将从以下几个方向继续探索:

  1. 多模态推荐:利用多模态LLM大模型的多模态信息抽取和表征能力,提取包括图片、文本、视频关键帧,视频语音文字等不同模态的语义化信息,并通过离线特征工程进行表征,使线上推荐模型能够真正完整地感知到各种电商模态信息,并实现对用户不同信息偏好和意图的理解。

  2. LLM推理加速:现阶段LLM存在推理时延过高的问题,无法满足推荐系统数十ms级别的rt要求,我们的LLM探索也止步于离校特征编码阶段。后续考虑通过蒸馏、剪枝、量化等手段,用一个小模型蒸馏出LLM的部分能力,从而降低推理的复杂性,使其能线上serving。

  3. LLM as 重排: 利用LLM丰富的知识领域扩展能力,在商品已有丰富的语义标签基础上,结合用户历史交互兴趣、选择偏好、序列生成规则 和 prompt template为用户从top排序集合中选取合适的商品或话题,生成推荐列表。


参考文献


[1] Hou, Yupeng, et al. "Large language models are zero-shot rankers for recommender systems." arXiv preprint arXiv:2305.08845 (2023).

[2] Qiu, Z., Wu, X., Gao, J., & Fan, W. (2021). U-BERT: Pre-training User Representations for Improved Recommendation. Proceedings of the AAAI Conference on Artificial Intelligence, 35(5), 4320-4327.  https://ojs.aaai.org/index.php/AAAI/article/view/16557

[3] Yupeng Hou, Shanlei Mu, Wayne Xin Zhao, Yaliang Li, Bolin Ding, and Ji-Rong Wen. 2022. Towards Universal Sequence Representation Learning for Recommender Systems. In Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD '22). Association for Computing Machinery, New York, NY, USA, 585–593. https://doi.org/10.1145/3534678.3539381

[4]Dingkun Long, Qiong Gao, Kuan Zou, Guangwei Xu, Pengjun Xie, Ruijie Guo, Jian Xu, Guanjun Jiang, Luxi Xing, and Ping Yang. 2022. Multi-CPR: A Multi Domain Chinese Dataset for Passage Retrieval. In Proceedings of the 45th International ACM SIGIR Conference on Research and Development in Information Retrieval (SIGIR '22). Association for Computing Machinery, New York, NY, USA, 3046–3056. https://doi.org/10.1145/3477495.3531736

[5] Liu, Q., Chen, N., Sakai, T., & Wu, X. (2023). A First Look at LLM-Powered Generative News Recommendation. ArXiv, abs/2305.06566.

[6] Li, J., Zhang, W., Wang, T., Xiong, G., Lu, A., & Medioni, G.G. (2023). GPT4Rec: A Generative Framework for Personalized Recommendation and User Interests Interpretation. ArXiv, abs/2304.03879.

[7] Yupeng Hou, Junjie Zhang, Zihan Lin, Hongyu Lu, Ruobing Xie, Julian McAuley, and Wayne Xin Zhao. Large Language Models are Zero-Shot Rankers for Recommender Systems. arXiv preprint arXiv:2305.08845, 2023.

[8] Dai, S., Shao, N., Zhao, H., Yu, W., Si, Z., Xu, C., Sun, Z., Zhang, X., & Xu, J. (2023). Uncovering ChatGPT's Capabilities in Recommender Systems. ArXiv, abs/2305.02182.

[9] Gao, Y., Sheng, T., Xiang, Y., Xiong, Y., Wang, H., & Zhang, J. (2023). Chat-REC: Towards Interactive and Explainable LLMs-Augmented Recommender System. ArXiv, abs/2303.14524.

[10] https://github.com/datawhalechina/prompt-engineering-for-developers

[11] https://ai.facebook.com/blog/large-language-model-llama-meta-ai/

[12] https://github.com/THUDM/ChatGLM-6B

[13] https://arxiv.org/pdf/2303.12712.pdf

[14] https://zhuanlan.zhihu.com/p/114432097

[15] https://www.modelscope.cn/models/damo/nlp_corom_sentence-embedding_chinese-base-ecom/summary

[16] https://www.microsoft.com/en-us/research/publication/learning-deep-structured-semantic-models-for-web-search-using-clickthrough-data/

[17] Li et al.(2019)]{2019arXiv190408030L} Li, C. and 9 colleagues 2019.\ Multi-Interest Network with Dynamic Routing for Recommendation at Tmall.\ arXiv e-prints. doi:10.48550/arXiv.1904.08030

[18] https://github.com/bojone/BERT-whitening


团队介绍

我们是淘天集团下FC技术部智能策略团队的推荐算法团队,主要负责手机天猫的推荐和广告算法的研发与优化工作,为用户提供更精准的推荐服务,提高用户体验和满意度。此外,团队还致力于AI技术的创新应用,如智能导购等领域,并积极探索创新性的业务实践。


¤  拓展阅读  ¤

3DXR技术 |  终端技术 |  音视频技术
服务端技术  |  技术质量 |  数据算法


本文分享自微信公众号 - 大淘宝技术(AlibabaMTT)。
如有侵权,请联系 [email protected] 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

Bun 发布 1.0 正式版本,Zig 编写的 JavaScript 运行时 Windows 文件资源管理器的神奇 bug,一秒提升性能 JetBrains 发布 Rust IDE:RustRover PHP 最新统计数据:市场份额超 7 成、CMS 中的王者 将 Python 程序移植到 Mojo,性能提升 250 倍、速度比 C 还快 .NET 8 性能大幅提升,比 .NET 7 遥遥领先 JS 三大运行时对比:Deno、Bun 和 Node.js Visual Studio Code 1.82 网易伏羲回应员工“因 BUG 被 HR 威胁”离世 Unity 引擎明年起根据游戏安装量收费 (runtime fee)
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4662964/blog/10110570