恭喜你!

使用 LangChain 與 Neo4j 的 Graph RAG

Adam Cowley

Manager, Developer Education at Neo4j

第 1 章

文字 向量嵌入
He's just a city boy born [0.12, -0.34, 0.56, 0.78, ..., -0.91]
born and raised in South Detroit [0.22, 0.45, -0.67, 0.11, ..., 0.33]
He took the midnight train [-0.55, 0.89, 0.12, -0.44, ..., 0.67]
going anywhere [0.78, -0.23, 0.45, 0.91, ..., -0.12]

圖:顯示歌曲「Don't stop believing」歌詞中的實體關係圖。包含「小鎮男孩」,與 South Detroit 的 BORN 與 RAISED 關係

使用 LangChain 與 Neo4j 的 Graph RAG

第 1 章

節點圖:包含 Book 與兩個連到作者的 WRITTEN_BY 關係,示範節點可有多個關係。

使用 LangChain 與 Neo4j 的 Graph RAG

第 1 章

將查詢結果注入提示中,準備送到 LLM

使用 LangChain 與 Neo4j 的 Graph RAG

第 2 章

階層圖:文件與多個頁面的 1 對多關係,每頁連結多個 chunk 節點

act_splitter = RecursiveCharacterTextSplitter(
    # Split text into acts
    separators=[ r"\n\nTHE PROLOGUE.",  r"\n\nACT",
                 r"\n\n\*\*\* END"],
    is_separator_regex=True
)

scene_splitter = RecursiveCharacterTextSplitter(
    # Split act into scenes
    separators=[r"\nSCENE "],
    is_separator_regex=True
)
使用 LangChain 與 Neo4j 的 Graph RAG

第 2 章

以節點上的文字屬性建立嵌入

使用 LangChain 與 Neo4j 的 Graph RAG

第 2 章

範例網域圖:一個人在公司任職,公司位於某地址。此人持有信用卡,並在同一地點的公司下訂單

使用 LangChain 與 Neo4j 的 Graph RAG

第 3 章

entity_resolution5.jpg

使用 LangChain 與 Neo4j 的 Graph RAG

第 3 章

 

ragas.png

 

  • Context Precision:衡量擷取文件中「相關區塊比例」
  • Noise Sensitivity:衡量擷取文件中的「不相關資訊量」
使用 LangChain 與 Neo4j 的 Graph RAG

第 3 章

使用 LangChain 與 Neo4j 的 Graph RAG

graph_academy.png

1 https://graphacademy.neo4j.com/
使用 LangChain 與 Neo4j 的 Graph RAG

一起來練習吧!

使用 LangChain 與 Neo4j 的 Graph RAG

Preparing Video For Download...