<a name="BigTitle"></a>
English | 快速上手 | Embedding应用 | 数据 | 赞助 | 人员 | 引用 | 鲁叔的讨论
骆驼嵌入是一个文本嵌入(text embedding)模型,由冷子昂、刘思诣、黄泓森、陈舒年、胡婧、孙骜、陈启源、李鲁鲁等开发
<details> <summary>每位作者均为第一作者,排序随机。(点击此处查看详情)</summary>李鲁鲁发起了项目,并完成了初步的验证,提出了KL散度Loss和Hard Negative挖掘。
刘思诣完成了初步训练框架的编写,以及支持了后续模型上传到hugging face的流程。
冷子昂完成了完整的大模型和小模型的训练,包括载入数据和损失函数的实现。
陈启源准备了CNewSum的数据,做了句子切分。
黄泓森负责爬取了OpenAI Embedding的数据。
陈舒年完成了几个重要的可视化。
孙骜(即将)用我们得到的Embedding,完成CoT的提升实验。
胡婧收集了周杰伦的歌词,并(即将)完成更多的定量实验。
</details>骆驼嵌入是Luotuo(骆驼)的子项目之一,后者由李鲁鲁、冷子昂、陈启源发起。
<p align="center"> <img src="https://yellow-cdn.veclightyear.com/ab5030c0/47f76cfa-442d-45b6-8ae0-e15adaa28c15.png"> </p>文本嵌入是指将一段文本转化为一定维度的向量(1536维),其中语义相近、主题相关的文本在向量空间中更接近。拥有一个良好的文本嵌入特征,对于文本可视化、检索、聚类、内容审核等下游任务具有重要意义。
如果您觉得这个项目有帮助,请为我们的主要仓库Luotuo(骆驼)点星,非常感谢!
如果您觉得这个页面对您有帮助,恳请您也去我们骆驼的主页点个star,非常感谢!
<a name="quickstart"></a>
中等规模模型已经发布,大型模型将在后续有空时发布。
Colab链接 | 详情 | |
---|---|---|
小型模型 | <a href="https://colab.research.google.com/github/LC1332/Luotuo-Text-Embedding/blob/main/notebook/Luotuo_Embedding_Visualization.ipynb" target="_parent"><img src="https://yellow-cdn.veclightyear.com/ab5030c0/00efda35-facd-4014-8c05-354007a42cca.svg" alt="Open In Colab"/></a> | BERT 110M带可视化验证 |
中等模型 | <a href="https://colab.research.google.com/github/LC1332/Luotuo-Text-Embedding/blob/main/notebook/Luotuo_Embedding_Visualization_Medium.ipynb" target="_parent"><img src="https://yellow-cdn.veclightyear.com/ab5030c0/00efda35-facd-4014-8c05-354007a42cca.svg" alt="Open In Colab"/></a> | BERT 352M带可视化验证 |
大型模型 | - | GLM-Encoder模型带可视化验证 |
小型模型简化版 | <a href="https://colab.research.google.com/github/LC1332/Luotuo-Text-Embedding/blob/main/notebook/Luotuo_Embedding_Demo.ipynb" target="_parent"><img src="https://yellow-cdn.veclightyear.com/ab5030c0/00efda35-facd-4014-8c05-354007a42cca.svg" alt="Open In Colab"/></a> | BERT 110M最简代码 |
中等模型简化版 | <a href="https://colab.research.google.com/github/LC1332/Luotuo-Text-Embedding/blob/main/notebook/Luotuo_Medium_Embedding_Demo.ipynb" target="_parent"><img src="https://yellow-cdn.veclightyear.com/ab5030c0/00efda35-facd-4014-8c05-354007a42cca.svg" alt="Open In Colab"/></a> | BERT 352M最简代码 |
大型模型简化版 | - | GLM-Encoder模型最简代码 |
<a name="application"></a>
所有应用示例都可以在以下Colab链接中体验 <a href="https://colab.research.google.com/github/LC1332/Luotuo-Text-Embedding/blob/main/notebook/Luotuo_Embedding_Visualization.ipynb" target="_parent"><img src="https://yellow-cdn.veclightyear.com/ab5030c0/00efda35-facd-4014-8c05-354007a42cca.svg" alt="Open In Colab"/></a>。
文本数据可视化 任意文本分类数据的可视化
文本相关性测试 周杰伦歌词之间的相关性测试
文本的模糊搜索 周鸿祎为什么喜欢穿红衣?
文本聚类 找呀找呀找朋友
少样本的分类学习 用embedding解决审核任务
<a name="sec-visual"></a>
对于任意多类的数据,围绕我们发布的Embedding模型,我们准备了一个特殊的可视化代码,可以将类别展示在二维平面,并抽样展示部分文本的内容。你可以直接在大模型链接/小 模型链接中运行体验。
<p align="center"> <img src="https://yellow-cdn.veclightyear.com/ab5030c0/b8961fec-18c4-4ef6-9bb7-31e95af8e9bd.png" height="350"> </p>通过可视化我们可以看到,OpenAI原论文的基本假设基本得到验证,即使是很抽象的歌词,在中间切开,去除重复文本之后,前段歌词和后段歌词仍然能够呈现很强的相关性。(除了周杰伦的《外婆》,其他的)歌曲的前后段在特征空间中都很接近。
<a name="sec-CSE"></a>
在OpenAI的论文(补充引用)中,使用了大量文本(补充数量)来进行自监督学习。其关键假设是,在切开的文本中,连续的两段长文本是相关的。在这个应用中,我们会在两个测试上验证这个假设。因为我们目前版本的模型的训练数据都是新闻,我们想找两批不同领域的语料,来验证模型的能力。
网文新闻数据:我们选取了15篇网文,并且加上了15篇数据集中不覆盖的新闻数据。并且寻找语料中的大段落,进行前后的切分。在网文数据中,为了增加挑战性,我们避免切分前后的数据出现过多重复的词汇。
周杰伦挑战:由于新闻数据前后文中会有一定数量重复的词汇,而网文叙述的连贯性也很强。所以我们想做一个更难的挑战,我们选取了3篇中学课文,2篇网文,5首王菲的歌,以及8首不同内容的周杰伦的歌。并且在这个挑战中,切分后的前文和后文中,我们人工去除了重复的短句(如副歌),并避免重复的词汇。
下面是周杰伦的第一张专辑中,一首Acid爵士风格的叙事歌曲《印第安老斑鸠》在切分后的前后歌词
前半句:沙漠之中怎么会有泥鳅 话说完飞过一只海鸥 大峡谷的风呼啸 而过 是谁说没有 有一条热昏头的响尾蛇 无力的躺在干枯的河 在等待雨季来临变沼泽 灰狼啃食着水鹿的骨头 秃鹰盘旋死盯着腐肉 草原上两只敌对野牛 在远方决斗
后半句:在一处被废弃的白蚁丘 站着一只饿昏的老斑鸠 印地安老斑鸠腿短毛不多 几天都没有喝水也能活 脑袋瓜有一点秀逗 猎物死了它比谁都难过 印地安斑鸠 会学人开口 仙人掌怕羞 蜥蝪横着走 这里什么奇怪的事都有 包括像猫的狗
<p align="center">
<img src="https://yellow-cdn.veclightyear.com/ab5030c0/78df665e-1e15-44e7-8ca4-c9ec8918337b.png" height="350">
</p>
我们对Luotuo-BERT在网文新闻30对的数据上进行了测试。我们额外编写了一个可视化,除了热图的展示,我们还抽样展示了热图中涉及数据的文本信息。可以看到:
OpenAI论文的假设被基本验证。即一个文本的前段和后段呈现很强的相关性。
由于我们的模型是在新闻上训练的,当前在新闻的表现上更好。
对于不同领域的文本,相关性矩阵会呈现分块对角的形式,甚至在不同类型的新闻,不同类型的网文之间,也有这样的特点。
根据我们的测试,当前的模型在其他领域的文本上,也能体现出良好的相关性。如果进一步补充其他领域的训练文本,可以使得这个特征有更好的不同领域的适应能力。
在周杰伦挑战中,我们对比了我们训练之前的基础模型,沈向洋老师IDEA团队的Tai-102M的BERT,以及我们训练后的Luotuo-BERT的结果,同时我们还展示了Hugging Face默认的BERT-base-Chinese模型的结果。(更大BERT的结果将在周一放出)
周杰伦挑战的图见一开始tSNE可视化。
<p align="center"> <img src="https://yellow-cdn.veclightyear.com/ab5030c0/77b07a7f-bbb4-4f56-8203-1fa7df5ff874.png" height="350"> </p>观察下图我们可以得出几个结论
Compared to online news tests, lyric tests are much more challenging. Even for humans observing the context, it's difficult to see obvious correlations.
Some songs by the same artist or with similar themes may show segmented correlations.
We also compared our results with OpenAI's. Through distillation learning, our LuotuoBERT can now achieve competitive results with OpenAI's API. Therefore, we are considering further strengthening the diagonal prior in the KL divergence loss, rather than simply targeting OpenAI's structure as the target probability.
More comparative results will be published in our upcoming report.
<a name="sec-IR"></a>
In our preliminary tests, LuotuoBERT has already demonstrated strong capabilities in fuzzy text search.
<p align="center"> <img src="https://yellow-cdn.veclightyear.com/ab5030c0/897c3db2-c1d8-4f37-ab83-04e39cfbd8cc.png" height="300"> </p>Of course, a more serious fuzzy search should further establish the correlation mapping from query features to answer text, and appropriately consider traditional keyword techniques.
<a name="sec-grouping"></a>
When category labels are not provided, our visualization tool automatically clusters the text.
<p align="center"> <img src="https://yellow-cdn.veclightyear.com/ab5030c0/6917b721-0b14-4e5b-a7d1-6016ebaddddf.png" height="300"> </p>This is a demonstration of clustering on news data.
<a name="sec-classification"></a>
During training, we used three loss components. The first is the MSE loss on OpenAI's features (I actually think L1 might be better); the second is the CSE loss, which calculates the similarity matrix for text pairs, then computes cross-entropy horizontally and vertically with the diagonal as ground truth labels; the third is the KL divergence loss, which calculates the KL divergence row-wise and column-wise between the correlation matrix P obtained from OpenAI and the current correlation matrix Q from the model.
For specific details, please refer to our report that we are currently writing. Once some quantitative experiments are completed, we will first post a Chinese version on arXiv for easier citation of our work. After adding more quantitative experiments, I will translate it into English.
For the BERT model, we added a fully connected layer to increase BERT's features to 1536 dimensions. We started with the Chinese CLIP model released by Dr. Shen Xiangyang's IDEA and trained for a total of 5 epochs on all data. We released the 102M small model over the weekend, and the 352M model should be released on Monday or Tuesday.
For the GLM model, for a sentence input, we obtain the hidden vector of each input token in GLM's last layer after tokenization, then pass this vector through a fully connected layer and input it into a BERT.
These details can be found in our report that we are currently writing.
<a name="data"></a>
In training the Luotuo embeddings, we used 234.5K CNewSum data. After cleaning the news data, splitting it, and calling OpenAI's text-embedding-ada-002 model, we obtained 1536-dimensional data for all text pairs.
We plan to release this dataset and are currently studying the data protocols of CNewSum and OpenAI. We are preparing to apply for sharing the spreadsheets and websites for this dataset, and will release it afterward.
Additionally, applying models trained on news data to other domains (such as Xianxia web novels) may have some limitations. It's best to further incorporate corresponding domain data for additional distillation training. If you have specific needs in this area and are willing to cover the costs of data and computing power, you can contact our team. (It would be even better if you're willing to make the training results with partial additional domain data public to the community)
<a name="sponsorship"></a>
In addition to using remote servers purchased with community-donated funds for training Luotuo embeddings,
We also used two weeks of A100 computing power donated by Soochow Securities. We express our gratitude for this!
If you are interested in sponsoring the Luotuo project, please click on the main project or view the sponsorship form
If you are interested in sponsoring the Luotuo Project, please click on the major project or view the sponsorship form.
<a name="contributor"></a>
For more detailed information about the personnel involved in the entire Luotuo project, please check the Luotuo project homepage
Each author is a first author, and the order is random. Li Lulu initiated the project, completed initial validation, and proposed KL divergence Loss and Hard Negative mining.
Liu Siyi completed the initial training framework and supported the subsequent model upload to the Hugging Face pipeline.
Leng Ziang completed the full training of large and small models, including data loading and loss function implementation.
Chen Qiyuan prepared the CNewSum data and performed sentence segmentation.
Huang Hongsen was responsible for crawling OpenAI Embedding data.
Chen Shunian completed several important visualizations.
Sun Ao (will) use our obtained Embeddings to complete CoT enhancement experiments.
Hu Jing collected Jay Chou's lyrics and (will) complete more quantitative experiments.
<a name="cite"></a>
If you use our model, code, or data in your project, please cite the first article below.
Please cite the repo if you use the data or code in this repo.
@misc{alpaca,
author={Siyi Liu, Ziang Leng, Hongsen Huang, Shunian Chen, Jing Hu, Ao sun, Qiyuan Chen, Cheng Li},
title = {Luotuo Embedding: Generative Text Embedding Model distilled from OpenAI API},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/LC1332/Luotuo-Text-Embedding}},
}
@misc{alpaca,
author={Ziang Leng, Qiyuan Chen and Cheng Li},
title = {Luotuo: An Instruction-following Chinese Language model, LoRA tuning on LLaMA},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/LC1332/Luotuo-Chinese-LLM}},
}
<a name="discussion"></a>
Embedding is a more academic approach. The public has discussed a lot about the language generation results of generative models, but there's relatively little discussion about Embedding.
However, many applications, such as BingGPT or ChatPDF, actually need Embedding models when constructing. So it's necessary to build one.
I estimate that this work might not receive a lot of attention, but it's indeed a very important work for the entire community, so it's worth doing. Therefore, we've invested a lot of manpower and resources into doing this Embedding work, and I'd like to express my gratitude to them here. If you think this project is indeed meaningful or has truly helped you, you can go to our Luotuo main project to give it a star.
However, the lyrics visualization is quite interesting. Since many of the team members are born after 1995 and 2000 (should I say everyone except me?), they complained that the songs I chose were too old, older than them. This lyrics visualization is very interesting, and I want to make a gradio later that supports uploading 20 lines of lyrics and automatically calculates and generates a graph.
I wasn't very satisfied with the previous NLP work visualization tools, so we rewrote them all here. The visualization was mainly implemented by Chen Shunian.
I've said that the Luotuo project is our assignment project, aiming to revisit various NLP tasks using new large language models. So I don't want to struggle too much time on decoder fine-tuning alone, but rather want to do various tasks.
If you find that this embedding doesn't work very well in your application area, but the OpenAI API does, it means we need to increase data to cover your domain. Please contact us promptly. We ultimately hope that Luotuo-BERT is a good Text Embedding that everyone can use, without having to spend effort retraining themselves.
For QA, theoretically, we should make a conversion function between query and answer, but I estimate a linear function should be enough here.
Because the community attention to this work may not be high, we might as well write an arxiv paper after completing the tests later, which would be the first arxiv paper for the entire big project.
To be completed before Tuesday
See our in-writing report here
AI小说写作助手,一站式润色、改写、扩写
蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。
字节跳动发布的AI编程神器IDE
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
全能AI智能助手,随时解答生活与工作的多样问题
问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。
实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1
科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。
一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型
Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速 度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。
AI助力,做PPT更简单!
咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。
选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。
专业的AI公文写作平台,公文写作神器
AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。
最新AI工具、AI资讯
独家AI资源、AI项目落地
微信扫一扫关注公众号