{"id":17396,"date":"2024-05-30T02:28:13","date_gmt":"2024-05-30T09:28:13","guid":{"rendered":"https:\/\/www.pingcap.com\/?post_type=article&#038;p=17396"},"modified":"2024-06-03T01:19:19","modified_gmt":"2024-06-03T08:19:19","slug":"building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database","status":"publish","type":"article","link":"https:\/\/www.pingcap.com\/ko\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/","title":{"rendered":"Building a GraphRAG from Wikipedia page Using DSPy, OpenAI and TiDB Vector Database"},"content":{"rendered":"<p>As GraphRAG is regarded as a better solution to the traditional RAG, <a href=\"https:\/\/tidb.cloud\/\">TiDB Serverless<\/a> &#8211; a MySQL compatible database but with <a href=\"https:\/\/www.pingcap.com\/ko\/blog\/integrating-vector-search-into-tidb-for-ai-applications\/\">built-in vector search<\/a> &#8211; is also experimenting GraphRAG with our own database. So recently we wrote a tutorials to teach people who are interested in building GraphRAG how to build a Knowledge Graph based RAG step by step, and we place the whole code to Google Colab:<\/p>\n\n\n\n<p>Try it in <a href=\"https:\/\/colab.research.google.com\/github\/pingcap\/tidb-vector-python\/blob\/main\/examples\/graphrag-step-by-step-tutorial\/example.ipynb\">Google Colab: GraphRAG Step by Step Tutorials<\/a>.<\/p>\n\n\n\n<p>In this blog, we will only explain some key section of this tutorial.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Dependencies\"><\/span>Dependencies<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In that <a href=\"https:\/\/colab.research.google.com\/github\/pingcap\/tidb-vector-python\/blob\/main\/examples\/graphrag-step-by-step-tutorial\/example.ipynb#scrollTo=8cM2hau4S3kO\">tutorial<\/a>, to start, we need to install the necessary Python libraries:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!pip install PyMySQL SQLAlchemy tidb-vector pydantic pydantic_core dspy-ai langchain-community wikipedia pyvis openai<\/code><\/pre>\n\n\n\n<p>In that tutorial, we will walk through how to create a Knowledge Graph from raw Wikipedia data and use it to generate answers to user queries. This method leverages the <a href=\"https:\/\/github.com\/stanfordnlp\/dspy\">DSPy<\/a> and OpenAI libraries to process and understand natural language. So the above Python packages should be installed<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Before diving into code, ensure that you have a basic understanding of Python, SQL databases, and natural language processing principles. Additionally, you will need access to OpenAI&#8217;s API and a TiDB serverless instance for storing the graph.<\/p>\n\n\n\n<p>Here is how to create a free TiDB Serverless cluster with built-in Vector Storage in it:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Join the waitlist and sign up an account: <a href=\"https:\/\/tidb.cloud\/ai\">https:\/\/tidb.cloud\/ai<\/a><\/li>\n\n\n\n<li>Then create a cluster: <a href=\"https:\/\/docs.google.com\/document\/d\/16zJADoPfmLNHP5tFqREOCslwmPUGhMIqXTL4QQ6vf2g\/edit#heading=h.ioilgixkp0q4\">Guide<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Core_Code\"><\/span>Core Code<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Part 1: Indexing<\/h3>\n\n\n\n<p><strong>1.Set Up DSPy and OpenAI<\/strong><\/p>\n\n\n\n<p>Configure the DSPy settings to use OpenAI&#8217;s GPT-4 model. We choose to use GPT-4o as the language model.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from google.colab import userdata\nopen_ai_client = dspy.OpenAI(model=\"gpt-4o\", api_key=userdata.get('OPENAI_API_KEY'), max_tokens=4096)\ndspy.settings.configure(lm=open_ai_client)<\/code><\/pre>\n\n\n\n<p><strong>2.Load Raw Wikipedia Page<\/strong><\/p>\n\n\n\n<p>There is no need to write the loader ourselves, so in order to load Wikipedia, we choose LangChain&#8217;s <code>WikipediaLoader<\/code> directly. It can help us to load any Wikipedia page with format <code>https:\/\/en.wikipedia.org\/wiki\/&lt;item&gt;<\/code><\/p>\n\n\n\n<p>For this example, let&#8217;s use &#8220;Elon Musk&#8221;&#8216;s Wikipedia page:<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"1\">\n<li><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>from langchain_community.document_loaders import WikipediaLoader\nwiki = WikipediaLoader(query=\"Elon Musk\").load()<\/code><\/pre>\n\n\n\n<p>In fact, it loads <code>https:\/\/en.wikipedia.org\/wiki\/Elon_Musk<\/code> to memory.<\/p>\n\n\n\n<p><strong>3.Extract Raw Wikipedia Page to Knowledge Graph<\/strong><\/p>\n\n\n\n<p>Use the loaded Wikipedia content to extract entities and relationships:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pred = extractor(text = wiki&#91;0].page_content)<\/code><\/pre>\n\n\n\n<p>Look at the demo row in database(exclude <code>description_vector<\/code> column as it has 1536 length of float):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql&gt; select id, name, description from entities limit 1 \\G\n*************************** 1. row ***************************\n         id: 1\n       name: Elon Reeve Musk\ndescription: A businessman and investor, founder, chairman, CEO, and CTO of SpaceX; angel investor, CEO, product architect, and former chairman of Tesla, Inc.; owner, executive chairman, and CTO of X Corp.; founder of The Boring Company and xAI; co-founder of Neuralink and OpenAI; and president of the Musk Foundation.\n1 row in set (0.16 sec)\n\nmysql&gt;<\/code><\/pre>\n\n\n\n<p><strong>4.Visualize the Graph<\/strong><\/p>\n\n\n\n<p>Show the graph using PyVis:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HTML(filename=jupyter_interactive_graph(pred.knowledge))<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"415\" src=\"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png\" alt=\"Show the graph using PyVis\" class=\"wp-image-17397\" srcset=\"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png 1280w, https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis-300x97.png 300w, https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis-1024x332.png 1024w, https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis-768x249.png 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/figure>\n\n\n\n<p>Note: we can see the <code>relationship<\/code> is different from the same concept in Graph database, in Graph databases, relationships between entities are typically represented with simple and concise labels, such as &#8220;have&#8221; or &#8220;belongs_to.&#8221; However, when defining relationships in TiDB Serverless, the representation is more complex and expansive. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql&gt; select * from relationships limit 1 \\G\n*************************** 1. row ***************************\n               id: 1\n source_entity_id: 1\n target_entity_id: 2\nrelationship_desc: Elon Musk is the founder, chairman, CEO, and CTO of SpaceX.\n1 row in set (0.17 sec)\n\nmysql&gt;<\/code><\/pre>\n\n\n\n<p><strong>5.Save Graph to TiDB Serverless<\/strong><\/p>\n\n\n\n<p>Persist the extracted knowledge graph to a TiDB serverless database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>save_knowledge_graph(pred.knowledge)<\/code><\/pre>\n\n\n\n<p>Done!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Part 2: Retrieve<\/h3>\n\n\n\n<p><strong>6.Ask a Question<\/strong><\/p>\n\n\n\n<p>Define a query, such as finding details about Elon Musk:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>question = \"Who is Elon Musk?\"<\/code><\/pre>\n\n\n\n<p><strong>7.Find Entities and Relationships<\/strong><\/p>\n\n\n\n<p>Retrieve entities and relationships related to the query from the database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>question_embedding = get_query_embedding(question)\nentities, relationships = retrieve_entities_relationships(question_embedding)<\/code><\/pre>\n\n\n\n<p>Still using SQL skills to search entity and relationship.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Part 3: Generate Answer<\/h3>\n\n\n\n<p><strong>8.Generate an Answer<\/strong><\/p>\n\n\n\n<p>Using the entities and relationships retrieved, generate a comprehensive answer:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>result = generate_result(question, entities, relationships)\nprint(result)<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Elon Reeve Musk is a prominent businessman and investor known for founding and leading several high-profile technology and space exploration companies. He is the founder, chairman, CEO, and CTO of SpaceX; the angel investor, CEO, product architect, and former chairman of Tesla, Inc.; the owner, executive chairman, and CTO of X Corp., which Twitter was rebranded into after its acquisition; the founder of The Boring Company and xAI; and the co-founder of Neuralink and OpenAI. He also serves as the president of the Musk Foundation...........<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This tutorial demonstrates a straightforward method to create a Knowledge Graph from Wikipedia data and utilize it to answer user queries using advanced natural language processing tools. The integration of DSPy with OpenAI and TiDB enables efficient processing and retrieval of information, making it a powerful tool for building intelligent applications.<\/p>\n\n\n\n<p>Feel free to adapt the code to different Wikipedia pages or queries to explore the capabilities of this approach further.<\/p>","protected":false},"excerpt":{"rendered":"<p>As GraphRAG is regarded as a better solution to the traditional RAG, TiDB Serverless &#8211; a MySQL compatible database but with built-in vector search &#8211; is also experimenting GraphRAG with our own database. So recently we wrote a tutorials to teach people who are interested in building GraphRAG how to build a Knowledge Graph based [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"template":"","class_list":["post-17396","article","type-article","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Building a GraphRAG Using DSPy, OpenAI and TiDB<\/title>\n<meta name=\"description\" content=\"Learn the key sections of building a GraphRAG step by step with DSPy and TiDB Serverless, the most advanced MySQL vector solution.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pingcap.com\/ko\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building a GraphRAG Using DSPy, OpenAI and TiDB\" \/>\n<meta property=\"og:description\" content=\"Learn the key sections of building a GraphRAG step by step with DSPy and TiDB Serverless, the most advanced MySQL vector solution.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pingcap.com\/ko\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/\" \/>\n<meta property=\"og:site_name\" content=\"TiDB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/pingcap2015\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-03T08:19:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@PingCAP\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/\",\"url\":\"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/\",\"name\":\"Building a GraphRAG Using DSPy, OpenAI and TiDB\",\"isPartOf\":{\"@id\":\"https:\/\/www.pingcap.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png\",\"datePublished\":\"2024-05-30T09:28:13+00:00\",\"dateModified\":\"2024-06-03T08:19:19+00:00\",\"description\":\"Learn the key sections of building a GraphRAG step by step with DSPy and TiDB Serverless, the most advanced MySQL vector solution.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#primaryimage\",\"url\":\"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png\",\"contentUrl\":\"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pingcap.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Articles\",\"item\":\"https:\/\/www.pingcap.com\/article\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Building a GraphRAG from Wikipedia page Using DSPy, OpenAI and TiDB Vector Database\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pingcap.com\/#website\",\"url\":\"https:\/\/www.pingcap.com\/\",\"name\":\"TiDB\",\"description\":\"TiDB | SQL at Scale\",\"publisher\":{\"@id\":\"https:\/\/www.pingcap.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pingcap.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pingcap.com\/#organization\",\"name\":\"PingCAP\",\"url\":\"https:\/\/www.pingcap.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png\",\"contentUrl\":\"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png\",\"width\":811,\"height\":232,\"caption\":\"PingCAP\"},\"image\":{\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/pingcap2015\",\"https:\/\/x.com\/PingCAP\",\"https:\/\/linkedin.com\/company\/pingcap\",\"https:\/\/youtube.com\/channel\/UCuq4puT32DzHKT5rU1IZpIA\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Building a GraphRAG Using DSPy, OpenAI and TiDB","description":"Learn the key sections of building a GraphRAG step by step with DSPy and TiDB Serverless, the most advanced MySQL vector solution.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pingcap.com\/ko\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/","og_locale":"ko_KR","og_type":"article","og_title":"Building a GraphRAG Using DSPy, OpenAI and TiDB","og_description":"Learn the key sections of building a GraphRAG step by step with DSPy and TiDB Serverless, the most advanced MySQL vector solution.","og_url":"https:\/\/www.pingcap.com\/ko\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/","og_site_name":"TiDB","article_publisher":"https:\/\/facebook.com\/pingcap2015","article_modified_time":"2024-06-03T08:19:19+00:00","og_image":[{"url":"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@PingCAP","twitter_misc":{"Est. reading time":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/","url":"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/","name":"Building a GraphRAG Using DSPy, OpenAI and TiDB","isPartOf":{"@id":"https:\/\/www.pingcap.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#primaryimage"},"image":{"@id":"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#primaryimage"},"thumbnailUrl":"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png","datePublished":"2024-05-30T09:28:13+00:00","dateModified":"2024-06-03T08:19:19+00:00","description":"Learn the key sections of building a GraphRAG step by step with DSPy and TiDB Serverless, the most advanced MySQL vector solution.","breadcrumb":{"@id":"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/"]}]},{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#primaryimage","url":"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png","contentUrl":"https:\/\/static.pingcap.com\/files\/2024\/05\/30021209\/Graph-using-PyVis.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pingcap.com\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pingcap.com\/"},{"@type":"ListItem","position":2,"name":"Articles","item":"https:\/\/www.pingcap.com\/article\/"},{"@type":"ListItem","position":3,"name":"Building a GraphRAG from Wikipedia page Using DSPy, OpenAI and TiDB Vector Database"}]},{"@type":"WebSite","@id":"https:\/\/www.pingcap.com\/#website","url":"https:\/\/www.pingcap.com\/","name":"\ud2f0DB","description":"TiDB | SQL at Scale","publisher":{"@id":"https:\/\/www.pingcap.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pingcap.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/www.pingcap.com\/#organization","name":"PingCAP","url":"https:\/\/www.pingcap.com\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/","url":"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png","contentUrl":"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png","width":811,"height":232,"caption":"PingCAP"},"image":{"@id":"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/pingcap2015","https:\/\/x.com\/PingCAP","https:\/\/linkedin.com\/company\/pingcap","https:\/\/youtube.com\/channel\/UCuq4puT32DzHKT5rU1IZpIA"]}]}},"card_markup":"        <a class=\"card-article\" href=\"https:\/\/www.pingcap.com\/ko\/article\/building-a-graphrag-from-wikipedia-page-using-dspy-openai-and-tidb-vector-database\/\">            <h3>Building a GraphRAG from Wikipedia page Using DSPy, OpenAI and TiDB Vector Database<\/h3>            <p>As GraphRAG is regarded as a better solution to the traditional RAG, TiDB Serverless &#8211; a MySQL compatible database but with built-in vector search &#8211; is also experimenting GraphRAG with our own database. So recently we wrote a tutorials to teach people who are interested in building GraphRAG how to build a Knowledge Graph based [&hellip;]<\/p>        <\/a>","_links":{"self":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/article\/17396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/types\/article"}],"author":[{"embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/users\/8"}],"wp:attachment":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/media?parent=17396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}