Vector embeddings have become ubiquitous tools for many language-related tasks. A leading embedding model is OpenAI's text-ada-002 which can embed approximately 6,000 words into a 1,536-dimensional vector. While powerful, text-ada-002 is not open source and is only available via API. We trained a simple neural network to convert open-source 768-dimensional MPNet embeddings into text-ada-002 embeddings. We compiled a subset of 50,000 online food reviews. We calculated MPNet and text-ada-002 embeddings for each review and trained a simple neural network to for 75 epochs. The neural network was designed to predict the corresponding text-ada-002 embedding for a given MPNET embedding. Our model achieved an average cosine similarity of 0.932 on 10,000 unseen reviews in our held-out test dataset. We manually assessed the quality of our predicted embeddings for vector search over text-ada-002-embedded reviews. While not as good as real text-ada-002 embeddings, predicted embeddings were able to retrieve highly relevant reviews. Our final model, Vec2Vec, is lightweight (<80 MB) and fast. Future steps include training a neural network with a more sophisticated architecture and a larger dataset of paired embeddings to achieve greater performance. The ability to convert between and align embedding spaces may be helpful for interoperability, limiting dependence on proprietary models, protecting data privacy, reducing costs, and offline operations.
翻译:向量嵌入已成为许多语言相关任务中不可或缺的工具。领先的嵌入模型是OpenAI的text-ada-002,它能将约6000个词嵌入到1536维向量中。尽管功能强大,但text-ada-002并非开源,仅通过API使用。我们训练了一个简单的神经网络,将开源的768维MPNet嵌入转换为text-ada-002嵌入。我们编译了一个包含5万条在线食品评论的子集,为每条评论计算MPNet和text-ada-002嵌入,并训练一个简单的神经网络运行75个周期。该神经网络旨在根据给定的MPNet嵌入预测对应的text-ada-002嵌入。在我们的保留测试数据集上,模型对1万条未见评论实现了平均余弦相似度0.932。我们手动评估了预测嵌入在基于text-ada-002嵌入评论的向量搜索中的质量。尽管不如真实的text-ada-002嵌入,但预测嵌入能检索到高度相关的评论。最终模型Vec2Vec轻量(<80 MB)且快速。未来步骤包括使用更复杂的架构和更大配对嵌入数据集训练神经网络,以实现更高性能。嵌入空间之间的转换和对齐能力可能有助于互操作性、减少对专有模型的依赖、保护数据隐私、降低成本及离线操作。