Retrieval Augmented Generation RAG Using Hugging Face Embeddings
1.0.0
該項目演示瞭如何使用擁抱的面部嵌入和Chromadb實施檢索型發電機(RAG)管道,以進行有效的語義搜索。解決方案讀取,處理和嵌入文本數據,使用戶能夠對數據進行準確而快速的查詢。
BAAI/bge-base-en-v1.5 )將文本塊轉換為矢量表示。在運行筆記本之前,請確保安裝必要的庫:
pip install chromadb
pip install llama-index您還需要克隆所需的數據集,如果您只想檢查一下並測試工作:):
git clone https://huggingface.co/datasets/NahedAbdelgaber/evaluating-student-writing
git clone https://huggingface.co/datasets/transformersbook/emotion-train-split加載數據集:
嵌入創建:
BAAI/bge-base-en-v1.5模型,將文本塊轉換為向量嵌入。您可以任何喜歡的型號。Chromadb整合:
語義搜索:
要使用代碼,請在安裝依賴項並克隆所需的數據集後運行筆記本。以下命令可用於查詢存儲的嵌入:
query_collection ( "Your search query here" , n_results = 1 )這將根據提供的查詢返回最相關的文本塊。
query_collection (
"Even though the planet is very similar to Earth, there are challenges to get accurate data because of the harsh conditions on the planet." ,
n_results = 1
)這裡有2個文件。簡單的一個只需創建一個單個文件的矢量數據庫,並且一個可以在具有不同擴展的多個文件上使用的,並創建它們的矢量數據庫,您也可以在文本模型上對其進行測試。
該存儲庫是根據MIT許可證獲得許可的。