{"id":17768,"date":"2024-06-23T08:33:54","date_gmt":"2024-06-23T15:33:54","guid":{"rendered":"https:\/\/www.pingcap.com\/?post_type=article&#038;p=17768"},"modified":"2024-06-23T08:33:57","modified_gmt":"2024-06-23T15:33:57","slug":"build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage","status":"publish","type":"article","link":"https:\/\/www.pingcap.com\/ko\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/","title":{"rendered":"Build RAG with Jina.AI Embeddings API and TiDB Vector Storage"},"content":{"rendered":"<p>In this tutorial, we will walk through building a Retrieval-Augmented Generation (RAG) system using the Jina.AI embeddings API and TiDB&#8217;s Vector Storage. This combination allows for efficient handling of vectorized data and powerful retrieval capabilities. We will cover the following steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"1\">\n<li>Setting up your environment.<\/li>\n\n\n\n<li>Generating embeddings using Jina.AI.<\/li>\n\n\n\n<li>Connecting to TiDB and creating a vector-enabled table.<\/li>\n\n\n\n<li>Inserting and querying data in TiDB.<\/li>\n<\/ol>\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 we begin, ensure you have the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Python installed on your machine.<\/li>\n\n\n\n<li>Access to Jina.AI API and TiDB serverless instance.\n<ul class=\"wp-block-list\">\n<li>Please make sure you have created a TiDB Serverless cluster with vector support enabled. Join the waitlist for the private beta at <a href=\"https:\/\/tidb.cloud\/ai\">tidb.cloud\/ai<\/a>.\n<ul class=\"wp-block-list\">\n<li>Sign up <a href=\"https:\/\/tidbcloud.com\/\">TiDB Cloud<\/a><\/li>\n\n\n\n<li>Follow this <a href=\"https:\/\/docs.pingcap.com\/tidbcloud\/tidb-cloud-quickstart#step-1-create-a-tidb-cluster\">tutorial<\/a> to create a TiDB Serverless cluster with vector support enabled<\/li>\n\n\n\n<li>Navigate to the <a href=\"https:\/\/tidbcloud.com\/console\/clusters\">Clusters<\/a> page, and then click the name of your target cluster to go to its overview page<\/li>\n\n\n\n<li>Click Connect in the upper-right corner.<\/li>\n\n\n\n<li>In the connection dialog, select General from the Connect With dropdown and keep the default setting of the Endpoint Type as Public.<\/li>\n\n\n\n<li>If you have not set a password yet, click Create password to generate a random password.<\/li>\n\n\n\n<li>Save the connection parameters to a safe place. You will need them to connect to the TiDB Serverless cluster in the following steps.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Generate an API token for Jina.AI embeddings API\n<ul class=\"wp-block-list\">\n<li>Go to <a href=\"https:\/\/jina.ai\/embeddings\/\">https:\/\/jina.ai\/embeddings\/<\/a><\/li>\n\n\n\n<li>Scroll down to the API part, you will get a token for free with 1million tokens:<\/li>\n\n\n\n<li>Save this token for future use. If you exceed the free quota of 1 million tokens, you will need this token to charge for additional usage.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"800\" src=\"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png\" alt=\"Embedding API\" class=\"wp-image-17770\" style=\"width:706px;height:auto\" srcset=\"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png 1280w, https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API-300x188.png 300w, https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API-1024x640.png 1024w, https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API-768x480.png 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Required Python libraries installed (<code>requests<\/code>, <code>sqlalchemy<\/code>, <code>pymysql<\/code>, <code>dotenv<\/code>).<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Setting_Up_Your_Environment\"><\/span>Step 1: Setting Up Your Environment<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First, let&#8217;s set up our environment by loading the necessary credentials and libraries.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\nimport requests\nimport dotenv\nfrom sqlalchemy import Column, Integer, String, create_engine, URL\nfrom sqlalchemy.orm import Session, declarative_base\nfrom tidb_vector.sqlalchemy import VectorType\n\ndotenv.load_dotenv()\n\nJINAAI_API_KEY = os.getenv('JINAAI_API_KEY')\nTIDB_USERNAME = os.getenv('TIDB_USERNAME')\nTIDB_PASSWORD = os.getenv('TIDB_PASSWORD')\nTIDB_HOST = os.getenv('TIDB_HOST')\nTIDB_PORT = os.getenv('TIDB_PORT')\nTIDB_DATABASE = os.getenv('TIDB_DATABASE')<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Generating_Embeddings_with_JinaAI\"><\/span>Step 2: Generating Embeddings with Jina.AI<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We will generate text embeddings using the Jina.AI API. The embeddings will be stored in TiDB for efficient querying.<\/p>\n\n\n\n<p><strong>Define the Function to Generate Embeddings<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def generate_embeddings(text: str):\n    JINAAI_API_URL = 'https:\/\/api.jina.ai\/v1\/embeddings'\n    JINAAI_HEADERS = {\n        'Content-Type': 'application\/json',\n        'Authorization': f'Bearer {JINAAI_API_KEY}'\n    }\n    JINAAI_REQUEST_DATA = {\n        'input': &#91;text],\n        'model': 'jina-embeddings-v2-base-en'  # Dimensions: 768\n    }\n    response = requests.post(JINAAI_API_URL, headers=JINAAI_HEADERS, json=JINAAI_REQUEST_DATA)\n    return response.json()&#91;'data']&#91;0]&#91;'embedding']\n\nTEXTS = &#91;\n    'Jina AI offers best-in-class embeddings, reranker and prompt optimizer, enabling advanced multimodal AI.',\n    'TiDB is an open-source MySQL-compatible database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads.',\n]\n\ndata = &#91;]\nfor text in TEXTS:\n    embedding = generate_embeddings(text)\n    data.append({\n        'text': text,\n        'embedding': embedding\n    })<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Connecting_to_TiDB_and_Creating_a_Vector-Enabled_Table\"><\/span>Step 3: Connecting to TiDB and Creating a Vector-Enabled Table<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Next, we&#8217;ll connect to TiDB and create a table that can store text data and their corresponding embeddings.<\/p>\n\n\n\n<p><strong>Connect to TiDB and Define the Table<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>url = URL(\n    drivername=\"mysql+pymysql\",\n    username=TIDB_USERNAME,\n    password=TIDB_PASSWORD,\n    host=TIDB_HOST,\n    port=int(TIDB_PORT),\n    database=TIDB_DATABASE,\n    query={\"ssl_verify_cert\": True, \"ssl_verify_identity\": True},\n)\nengine = create_engine(url, pool_recycle=300)\nBase = declarative_base()\n\nclass Document(Base):\n    __tablename__ = \"jinaai_tidb_demo_documents\"\n\n    id = Column(Integer, primary_key=True)\n    content = Column(String(255), nullable=False)\n    content_vec = Column(\n        VectorType(dim=768),\n        comment=\"hnsw(distance=l2)\"\n    )\nBase.metadata.create_all(engine)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Inserting_Data_into_TiDB\"><\/span>Step 4: Inserting Data into TiDB<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now, we will insert the generated embeddings and their corresponding texts into the TiDB table.<\/p>\n\n\n\n<p><strong>Insert Data<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>with Session(engine) as session:\n    print('- Inserting Data to TiDB...')\n    for item in data:\n        print(f'  - Inserting: {item&#91;\"text\"]}')\n        session.add(Document(\n            content=item&#91;'text'],\n            content_vec=item&#91;'embedding']\n        ))\n    session.commit()<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_5_Querying_Data_from_TiDB\"><\/span>Step 5: Querying Data from TiDB<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Finally, let&#8217;s query the data from TiDB to find the most relevant document based on a sample query.<\/p>\n\n\n\n<p><strong>Query the Data<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>query = 'What is TiDB?'\nquery_embedding = generate_embeddings(query)\nwith Session(engine) as session:\n    print('- List All Documents and Their Distances to the Query:')\n    for doc, distance in session.query(\n        Document,\n        Document.content_vec.cosine_distance(query_embedding).label('distance')\n    ).all():\n        print(f'  - {doc.content}: {distance}')\n\n    print('- The Most Relevant Document and Its Distance to the Query:')\n    doc, distance = session.query(\n        Document,\n        Document.content_vec.cosine_distance(query_embedding).label('distance')\n    ).order_by(\n        'distance'\n    ).limit(1).first()\n    print(f'  - {doc.content}: {distance}')<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p>When you run the above script, you should see output similar to this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>- Inserting Data to TiDB...\n  - Inserting: Jina AI offers best-in-class embeddings, reranker and prompt optimizer, enabling advanced multimodal AI.\n  - Inserting: TiDB is an open-source MySQL-compatible database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads.\n- List All Documents and Their Distances to the Query:\n  - Jina AI offers best-in-class embeddings, reranker and prompt optimizer, enabling advanced multimodal AI.: 0.3585317326132522\n  - TiDB is an open-source MySQL-compatible database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads.: 0.10858658947444844\n- The Most Relevant Document and Its Distance to the Query:\n  - TiDB is an open-source MySQL-compatible database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads.: 0.10858658947444844<\/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>Congratulations! You have successfully built a RAG system using Jina.AI embeddings API and TiDB&#8217;s Vector Storage. This setup allows you to efficiently store and query vectorized data, enabling advanced search capabilities in your applications.<\/p>\n\n\n\n<p>Feel free to expand this tutorial by adding more functionalities, such as handling larger datasets, optimizing queries, and integrating with other machine learning models.<\/p>\n\n\n\n<p>Full demo: <a href=\"https:\/\/github.com\/pingcap\/tidb-vector-python\/tree\/main\/examples\/jina-ai-embeddings-demo\">https:\/\/github.com\/pingcap\/tidb-vector-python\/tree\/main\/examples\/jina-ai-embeddings-demo<\/a><\/p>\n\n\n\n<p>There are also more demos to demonstrate how to build AI apps, how to use TiDB as vector storage:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/pingcap\/tidb-vector-python\/blob\/main\/examples\/openai_embedding\/README.md\">OpenAI Embedding<\/a>: use the OpenAI embedding model to generate vectors for text data.<\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/pingcap\/tidb-vector-python\/blob\/main\/examples\/image_search\/README.md\">Image Search<\/a>: use the OpenAI CLIP model to generate vectors for image and text.<\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/pingcap\/tidb-vector-python\/blob\/main\/examples\/llamaindex-tidb-vector-with-ui\/README.md\">LlamaIndex RAG with UI<\/a>: use the LlamaIndex to build an <a href=\"https:\/\/docs.llamaindex.ai\/en\/latest\/getting_started\/concepts\/\">RAG(Retrieval-Augmented Generation)<\/a> application.<\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/pingcap\/tidb-vector-python\/blob\/main\/examples\/llamaindex-tidb-vector\/README.md\">Chat with URL<\/a>: use LlamaIndex to build an <a href=\"https:\/\/docs.llamaindex.ai\/en\/latest\/getting_started\/concepts\/\">RAG(Retrieval-Augmented Generation)<\/a> application that can chat with a URL.<\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/pingcap\/tidb-vector-python\/blob\/main\/examples\/graphrag-demo\/README.md\">GraphRAG<\/a>: 20 lines code of using TiDB Serverless to build a Knowledge Graph based RAG application.<\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/pingcap\/tidb-vector-python\/blob\/main\/examples\/graphrag-step-by-step-tutorial\/README.md\">GraphRAG Step by Step Tutorial<\/a>: Step by step tutorial to build a Knowledge Graph based RAG application with Colab notebook. In this tutorial, you will learn how to extract knowledge from a text corpus, build a Knowledge Graph, store the Knowledge Graph in TiDB Serverless, and search from the Knowledge Graph.<\/li>\n\n\n\n<li><a href=\"https:\/\/colab.research.google.com\/drive\/1LuJn4mtKsjr3lHbzMa2RM-oroUvpy83y?usp=sharing\">Vector Search Notebook with SQLAlchemy<\/a>: use <a href=\"https:\/\/www.sqlalchemy.org\/\">SQLAlchemy<\/a> to interact with TiDB Serverless: connect db, index&amp;store data and then search vectors.<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will walk through building a Retrieval-Augmented Generation (RAG) system using the Jina.AI embeddings API and TiDB&#8217;s Vector Storage. This combination allows for efficient handling of vectorized data and powerful retrieval capabilities. We will cover the following steps: Prerequisites Before we begin, ensure you have the following: Step 1: Setting Up Your [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"template":"","class_list":["post-17768","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>Build RAG with Jina.AI Embeddings API and TiDB Vector Storage<\/title>\n<meta name=\"description\" content=\"In this tutorial, we will build a RAG system using the Jina.AI embeddings API and TiDB&#039;s Vector Storage and SQLAlchemy with MySQL skills\" \/>\n<meta name=\"robots\" content=\"noindex, follow\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Build RAG with Jina.AI Embeddings API and TiDB Vector Storage\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we will build a RAG system using the Jina.AI embeddings API and TiDB&#039;s Vector Storage and SQLAlchemy with MySQL skills\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pingcap.com\/ko\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/\" \/>\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-23T15:33:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@PingCAP\" \/>\n<meta name=\"twitter:label1\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data1\" content=\"6\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/\",\"url\":\"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/\",\"name\":\"Build RAG with Jina.AI Embeddings API and TiDB Vector Storage\",\"isPartOf\":{\"@id\":\"https:\/\/www.pingcap.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png\",\"datePublished\":\"2024-06-23T15:33:54+00:00\",\"dateModified\":\"2024-06-23T15:33:57+00:00\",\"description\":\"In this tutorial, we will build a RAG system using the Jina.AI embeddings API and TiDB's Vector Storage and SQLAlchemy with MySQL skills\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#primaryimage\",\"url\":\"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png\",\"contentUrl\":\"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#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\":\"Build RAG with Jina.AI Embeddings API and TiDB Vector Storage\"}]},{\"@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":"Build RAG with Jina.AI Embeddings API and TiDB Vector Storage","description":"In this tutorial, we will build a RAG system using the Jina.AI embeddings API and TiDB's Vector Storage and SQLAlchemy with MySQL skills","robots":{"index":"noindex","follow":"follow"},"og_locale":"ko_KR","og_type":"article","og_title":"Build RAG with Jina.AI Embeddings API and TiDB Vector Storage","og_description":"In this tutorial, we will build a RAG system using the Jina.AI embeddings API and TiDB's Vector Storage and SQLAlchemy with MySQL skills","og_url":"https:\/\/www.pingcap.com\/ko\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/","og_site_name":"TiDB","article_publisher":"https:\/\/facebook.com\/pingcap2015","article_modified_time":"2024-06-23T15:33:57+00:00","og_image":[{"url":"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@PingCAP","twitter_misc":{"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"6\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/","url":"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/","name":"Build RAG with Jina.AI Embeddings API and TiDB Vector Storage","isPartOf":{"@id":"https:\/\/www.pingcap.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#primaryimage"},"image":{"@id":"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#primaryimage"},"thumbnailUrl":"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png","datePublished":"2024-06-23T15:33:54+00:00","dateModified":"2024-06-23T15:33:57+00:00","description":"In this tutorial, we will build a RAG system using the Jina.AI embeddings API and TiDB's Vector Storage and SQLAlchemy with MySQL skills","breadcrumb":{"@id":"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/"]}]},{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#primaryimage","url":"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png","contentUrl":"https:\/\/static.pingcap.com\/files\/2024\/06\/23083113\/Embedding-API.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pingcap.com\/article\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/#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":"Build RAG with Jina.AI Embeddings API and TiDB Vector Storage"}]},{"@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\/build-rag-with-jina-ai-embeddings-api-and-tidb-vector-storage\/\">            <h3>Build RAG with Jina.AI Embeddings API and TiDB Vector Storage<\/h3>            <p>In this tutorial, we will walk through building a Retrieval-Augmented Generation (RAG) system using the Jina.AI embeddings API and TiDB&#8217;s Vector Storage. This combination allows for efficient handling of vectorized data and powerful retrieval capabilities. We will cover the following steps: Prerequisites Before we begin, ensure you have the following: Step 1: Setting Up Your [&hellip;]<\/p>        <\/a>","_links":{"self":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/article\/17768","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=17768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}