🚀 FinLang/finance-embeddings-investopedia
这是FinLang团队为金融应用打造的Investopedia嵌入模型。该模型基于团队从https://huggingface.co/datasets/FinLang/investopedia-embedding-dataset 开源的金融数据集进行训练。
此模型是在BAAI/bge-base-en-v1.5基础上微调得到的嵌入模型。它能将句子和段落映射到768维的密集向量空间,可用于RAG应用中的聚类或语义搜索等任务。
本项目仅用于研究目的。第三方数据集可能需遵循其相关许可证下的额外条款和条件。
🚀 快速开始
本模型可通过不同方式使用,以下为你详细介绍:
LLamaIndex方式
在金融RAG应用的索引过程中,只需指定Finlang嵌入即可。
from llama_index.embeddings import HuggingFaceEmbedding
embed_model = HuggingFaceEmbedding(model_name="FinLang/investopedia_embedding")
Sentence-Transformers方式
若你已安装sentence-transformers(详见https://huggingface.co/sentence-transformers ),使用该模型会非常简单。
pip install -U sentence-transformers
然后你可以按如下方式使用模型:
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('FinLang/investopedia_embedding')
embeddings = model.encode(sentences)
print(embeddings)
代码测试示例
from sentence_transformers import SentenceTransformer, util
model = SentenceTransformer("FinLang/investopedia_embedding")
query_1 = "What is a potential concern with allowing someone else to store your cryptocurrency keys, and is it possible to decrypt a private key?"
query_2 = "A potential concern is that the entity holding your keys has control over your cryptocurrency in a custodial relationship. While it is theoretically possible to decrypt a private key, with current technology, it would take centuries or millennia for the 115 quattuorvigintillion possibilities. Most hacks and thefts occur in wallets, where private keys are stored."
embedding_1 = model.encode(query_1)
embedding_2 = model.encode(query_2)
scores = (embedding_1*embedding_2).sum()
print(scores)
✨ 主要特性
- 基于开源数据集训练:使用从https://huggingface.co/datasets/FinLang/investopedia-embedding-dataset 开源的金融数据集进行训练,保证数据的可获取性和透明度。
- 微调优化:在BAAI/bge-base-en-v1.5基础上进行微调,能更好地适应金融领域的应用需求。
- 多任务适用性:可将句子和段落映射到768维的密集向量空间,适用于聚类、语义搜索等多种任务。
📚 详细文档
评估结果
我们对模型在未见句子对的相似度以及未见打乱句子对的不相似度上进行了评估。评估套件包含来自以下来源的句子对:Investopedia(用于测试金融领域的熟练度),以及Gooaq、MSMARCO、stackexchange_duplicate_questions_title_title、yahoo_answers_title_answer(用于评估模型微调后避免遗忘的能力)。
未来计划
- 研究论文发布:研究论文即将发布。
- 模型升级:正在开发模型的v2版本,会增加金融数据的训练语料,并采用改进的嵌入训练技术。
📄 许可证
由于微调使用了非商业数据集,我们以cc-by-nc-4.0许可证发布此模型。
🔜 引用说明
引用说明即将推出。