Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Graph Databases: Data Storage with Context

Graph Databases: Data Storage with Context

In this connected world, traditional data stores often make it difficult to find valuable relationships. By making them a key component of the model, contextualizing a set of data becomes incredibly simple.
In this session, we will walk through what a graph database is and how it can transform your applications and data. We will explore creating, querying, and displaying data with tools to interact with the database. Then, we will look at how graphs are lending their strengths to the AI industry through vectors and GraphRAG.
Code: https://github.com/JMHReif/springai-goodreads

Jennifer Reif

January 09, 2025
Tweet

More Decks by Jennifer Reif

Other Decks in Technology

Transcript

  1. Graph Databases: Data Storage with Context Jennifer Reif [email protected] @JMHReif

    github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif Photo by Tomasz Frankowski on Unsplash
  2. Who is Jennifer Reif? Developer Advocate, Neo4j • Continuous learner

    • Technical speaker • Tech blogger, podcaster • Other: geek Jennifer Reif [email protected] @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif
  3. What is a graph? Degree Degree Company Jennifer Jacob School

    ATTENDED ATTENDED W ORKED_FOR WORKED_FOR EN RO LLED_IN ENROLLED_IN
  4. What is a graph? Adrian Degree Degree Company Jennifer Jacob

    School ATTENDED ATTENDED W ORKED_FOR WORKED_FOR EN RO LLED_IN ENROLLED_IN ENROLLED_IN Degree C O M PLETED COM PLETED
  5. What is a graph? Person Degree Degree Company Person Person

    School ATTENDED ATTENDED W ORKED_FOR WORKED_FOR EN RO LLED_IN ENROLLED_IN ENROLLED_IN Degree C O M PLETED COM PLETED Edward Jones Jacob Jennifer SIUE Music CMIS CS Adrian
  6. What is a graph? Answers through relationships • How many

    coworkers shared classes/degrees? • What are common degree journeys? • How many alumni re- enroll for higher degrees? • Who else went to a school and works for company? Person Degree Degree Company Person Person School ATTENDED ATTENDED W ORKED_FOR WORKED_FOR EN RO LLED_IN ENROLLED_IN ENROLLED_IN Degree C O M PLETED COM PLETED Edward Jones Jacob Jennifer SIUE Music CMIS CS Adrian
  7. Nodes (vertices) Objects or entities • Can have labels •

    May have properties Person Degree Degree Company Person Person School Degree Edward Jones Jacob Jennifer SIUE Music CMIS CS Adrian
  8. Relationships (edges) Connect entities • Must have type (label) •

    Must have direction • May have properties Person Degree Degree Company Person Person School ATTENDED ATTENDED W ORKED_FOR WORKED_FOR EN RO LLED_IN ENROLLED_IN ENROLLED_IN Degree C O M PLETED COM PLETED Edward Jones Jacob Jennifer SIUE Music CMIS CS Adrian
  9. Logistics • Where fi rst? • Depends on when ready

    to leave house Home School Opens: 08:00 Donation Opens: 09:00 Shipping Opens: 10:00 Grocery Opens: 07:00
  10. Logistics Criteria • Where is time critical? • Personal preferences

    for refrigerated food? • How long at each store? Music Home School Opens: 08:00 Donation Opens: 09:00 Shipping Opens: 10:00 Grocery Opens: 07:00 WENT_1 W ENT_2 WENT_3 WENT_4 W ENT_5 WENT_6
  11. Answer questions Habits/preferences • E ffi ciency improvements? • Adding

    stop? Where/time? • Share load across more people? • Distance and location calculations? Music Home School Opens: 08:00 Donation Opens: 09:00 Shipping Opens: 10:00 Grocery Opens: 07:00 WENT_1 W ENT_2 WENT_3 WENT_4 W ENT_5 WENT_6
  12. Other use cases • Fraud detection • Identity and access

    management • Recommendations • Supply chain
  13. Cypher GQL-compliant • Functional and visual • Based on ASCII

    art • Declarative • Focus on patterns A B LIKES MATCH (A)-[:LIKES]->(B)
  14. Cypher: write All about patterns Jennifer Neo4j WORKS_FOR CREATE (:Person

    { name: ‘Jennifer’}) -[:WORKS_FOR]-> (:Company { name: ‘Neo4j’}) NODE PROPERTY NODE PROPERTY LABEL LABEL
  15. Cypher: read All about patterns Jennifer Neo4j WORKS_FOR MATCH (:Person

    { name: ‘Jennifer’} ) -[:WORKS_FOR]-> ( whom ) RETURN whom
  16. Integrations Lots of options! • Cloud • Visualization • Data

    transportation • Data science • Applications • Administration, ops, monitoring
  17. Purchasing system Orders, products, suppliers, etc • Easily fi nd

    unusual patterns • Optimize routes network • Pass bits on to other systems • Pinpoint… • Improvements for inventory • Weak points in supply chain • In fl uential products/customers
  18. Financial Investments, ownership, etc • Easily track fi nancial holdings

    • Understand money movements • Monitor transactions • Pinpoint… • Suspicious activity • True ownership (transactions) • In fl uential, valuable holdings
  19. Other Social, interactions, etc • Easily navigate human interaction •

    Understand collaboration • Track behavior, journeys • Pinpoint… • User journeys, collabs • Communities • In fl uential people, events
  20. Throw an LLM at it Doesn’t often work • LLM

    strengths: • human-consumable data • general/public info • LLM weaknesses: • context/big picture • private knowledge • Solo LLM = great -> integrated LLM = more great?
  21. RAG architecture • Retrieval • Data retrieved from external source

    • Augmented • Augments response with facts • Generation • Response in natural language Prompt + Relevant Information LLM API LLM
 Chat API User Database Search Prompt Response Relevant Results / Documents 2 3 1 Database
  22. Embeddings / Vectors Convert data to a point in space

    • Series of numbers • 100s or 1000s of dimensions • Dimension = interesting feature / characteristic
  23. Vectors in the technical realm Kings and Queens king −

    man + woman ≈ queen king man wom an 1 king man wom an 2 queen? 3
  24. How do we search the vectors? Similarity search • Expensive

    queries (compare to every vector) • Approximate nearest neighbor (k-ANN) • Example: Library • Book classi fi cation - genre vs location of plot • Smaller search set = smaller retrieval time! Photo by Martin Adams on Unsplash
  25. GraphRAG Graph DB as a data source • Higher accuracy

    (more relevance in result) • Using existing, quality data • Explainability, veri fi ability
  26. Explainable AI Why graph with GenAI? • How did the

    LLM get this answer? • Graphs: • Incorporating siloed data into result • Add extra context/related info to graph • Better veri fi cation through understandable format Photo by No Revisions on Unsplash
  27. Resources • Github repository (today’s code): github.com/JMHReif/springai-goodreads • GraphAcademy LLM

    courses: graphacademy.neo4j.com/categories/llms/ • Docs for Spring AI: docs.spring.io/spring-ai/reference/api/vectordbs/neo4j.html • Knowledge graph ebook: https://neo4j.com/whitepapers/developers-guide-how- to-build-knowledge-graph/ Jennifer Reif [email protected] @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif