🚀 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許可證發佈此模型。
🔜 引用說明
引用說明即將推出。