{"id":17767,"date":"2024-06-23T08:20:01","date_gmt":"2024-06-23T15:20:01","guid":{"rendered":"https:\/\/www.pingcap.com\/?post_type=article&#038;p=17767"},"modified":"2024-08-20T03:49:44","modified_gmt":"2024-08-20T10:49:44","slug":"build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector","status":"publish","type":"article","link":"https:\/\/www.pingcap.com\/ko\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/","title":{"rendered":"Build a Semantic Cache Service with Jina AI Embedding and TiDB Vector"},"content":{"rendered":"\n<p>In the rapidly evolving landscape of machine learning and database technologies, combining the strengths of different tools can lead to innovative solutions. One such powerful combination is using Jina AI&#8217;s embedding capabilities with TiDB&#8217;s vector search functionality. This blog will guide you through building a semantic cache service using Jina AI Embeddings and TiDB Vector.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_a_Semantic_Cache\"><\/span>What is a Semantic Cache?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A semantic cache stores the results of expensive queries and reuses them when the same or similar queries are made. This type of cache uses semantic understanding rather than exact key matching, making it particularly useful in applications requiring natural language processing or similar complex data retrieval tasks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Jina_AI_and_TiDB\"><\/span>Why Jina AI and TiDB?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/jina.ai\/embeddings\/\">Jina AI<\/a><\/strong>: Provides robust embedding capabilities, converting text into high-dimensional vectors that capture semantic meaning.<\/li>\n\n\n\n<li><strong><a href=\"https:\/\/tidb.cloud\/ai\">TiDB Vector<\/a><\/strong>: Extends the TiDB database to support efficient vector operations, enabling fast similarity searches on high-dimensional data.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Setting_Up_the_Environment\"><\/span>Setting Up the Environment<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>Prerequisites<\/strong><\/p>\n\n\n\n<p>Ensure you have the following installed:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Python 3.8 or higher<\/li>\n\n\n\n<li>TiDB Serverless cluster setup and running<\/li>\n\n\n\n<li>An API key from <a href=\"https:\/\/jina.ai\/embeddings\/\">Jina AI<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step-by-Step_Implementation\"><\/span>Step-by-Step Implementation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">1.Configuration<\/h4>\n\n\n\n<p>First, set up your environment configuration. Create a <code>.env<\/code> file to store your database URI and TTL (Time to Live) settings.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DATABASE_URI=mysql+pymysql:\/\/&lt;username&gt;:&lt;password&gt;@&lt;host&gt;:&lt;port&gt;\/&lt;database&gt;?ssl_mode=VERIFY_IDENTITY&amp;ssl_ca=\/etc\/ssl\/cert.pem\nTIME_TO_LIVE=604800  # Default is 1 week<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">2.Install Required Libraries<\/h4>\n\n\n\n<p>Install the necessary Python packages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install fastapi requests sqlmodel sqlalchemy python-dotenv tidb-vector<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.Define the Cache Model<\/h4>\n\n\n\n<p>Use <code>SQLModel<\/code> to define your cache model, incorporating vector fields and automatic timestamping.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from sqlmodel import SQLModel, Field, Column, DateTime, String, Text\nfrom sqlalchemy import func\nfrom tidb_vector.sqlalchemy import VectorType\nfrom typing import Optional\nfrom datetime import datetime\n\nclass Cache(SQLModel, table=True):\n    __table_args__ = {\n        # Setting the TTL (Time to Live) for the cache entries\n        'mysql_TTL': f'created_at + INTERVAL {TIME_TO_LIVE} SECOND',\n    }\n\n    id: Optional&#91;int] = Field(default=None, primary_key=True)\n    key: str = Field(sa_column=Column(String(255), unique=True, nullable=False))\n    key_vec: Optional&#91;list&#91;float]] = Field(\n        sa_column=Column(\n            VectorType(768),  # Define the vector type with 768 dimensions\n            default=None,\n            comment=\"hnsw(distance=l2)\",  # Using HNSW (Hierarchical Navigable Small World) algorithm for distance calculation\n            nullable=False,\n        )\n    )\n    value: Optional&#91;str] = Field(sa_column=Column(Text))\n    created_at: datetime = Field(\n        sa_column=Column(DateTime, server_default=func.now(), nullable=False)\n    )\n    updated_at: datetime = Field(\n        sa_column=Column(DateTime, server_default=func.now(), onupdate=func.now(), nullable=False)\n    )<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">4.Create the Database Engine<\/h4>\n\n\n\n<p>Create the engine and the database schema.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from sqlmodel import create_engine\n\n# Create the engine using the database URI\nengine = create_engine(DATABASE_URI)\n# Create all tables in the database\nSQLModel.metadata.create_all(engine)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">5.FastAPI Setup<\/h4>\n\n\n\n<p>Set up the FastAPI application and endpoints for setting and getting cache entries.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from fastapi import FastAPI, Depends\nfrom fastapi.security import HTTPBearer, HTTPAuthorizationCredentials\nfrom sqlmodel import Session, select\n\n# Initialize FastAPI app\napp = FastAPI()\nsecurity = HTTPBearer()\n\n@app.post(\"\/set\")\ndef set_cache(\n    credentials: HTTPAuthorizationCredentials = Depends(security),\n    cache: Cache\n):\n    # Generate embeddings for the given key using Jina AI\n    cache.key_vec = generate_embeddings(credentials.credentials, cache.key)\n    with Session(engine) as session:\n        session.add(cache)\n        session.commit()\n    return {'message': 'Cache has been set'}\n\n@app.get(\"\/get\/{key}\")\ndef get_cache(\n    credentials: HTTPAuthorizationCredentials = Depends(security),\n    key: str,\n    max_distance: Optional&#91;float] = 0.1,\n):\n    # Generate embeddings for the given key using Jina AI\n    key_vec = generate_embeddings(credentials.credentials, key)\n    # The max value of distance is 0.3\n    max_distance = min(max_distance, 0.3)\n\n    with Session(engine) as session:\n        result = session.exec(\n            select(\n                Cache,\n                Cache.key_vec.cosine_distance(key_vec).label('distance')\n            ).order_by(\n                'distance'\n            ).limit(1)\n        ).first()\n\n        if result is None:\n            return {\"message\": \"Cache not found\"}, 404\n\n        cache, distance = result\n        if distance &gt; max_distance:\n            return {\"message\": \"Cache not found\"}, 404\n\n        return {\n            \"key\": cache.key,\n            \"value\": cache.value,\n            \"distance\": distance\n        }<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">6.Generate Embeddings<\/h4>\n\n\n\n<p>Implement a function to get embeddings from <a href=\"https:\/\/jina.ai\/embeddings\/\">Jina AI<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import requests\nimport os\nfrom dotenv import load_dotenv\n\nload_dotenv()\n\ndef generate_embeddings(jinaai_api_key: str, 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'  # Use the Jina Embeddings model with 768 dimensions\n    }\n    response = requests.post(JINAAI_API_URL, headers=JINAAI_HEADERS, json=JINAAI_REQUEST_DATA)\n    # Extract and return the embedding from the response\n    return response.json()&#91;'data']&#91;0]&#91;'embedding']<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Use_This_App\"><\/span>How to Use This App<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>Prerequisites<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A running TiDB Serverless cluster with vector search enabled<\/li>\n\n\n\n<li>Python 3.8 or later<\/li>\n\n\n\n<li>Jina AI API key from <a href=\"https:\/\/jina.ai\/embeddings\/\">Jina AI<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Run the example<\/strong><\/p>\n\n\n\n<p><strong>1.Clone this repo<\/strong><\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/pingcap\/tidb-vector-python.git<\/code><\/pre>\n\n\n\n<p><strong>2.Create a virtual environment<\/strong><\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>cd tidb-vector-python\/examples\/semantic-cache\npython3 -m venv .venv\nsource .venv\/bin\/activate<\/code><\/pre>\n\n\n\n<p><strong>3.Install dependencies<\/strong><\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install -r requirements.txt<\/code><\/pre>\n\n\n\n<p><strong>4.Set the environment variables<\/strong><\/p>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<p>Get the <code>HOST<\/code>, <code>PORT<\/code>, <code>USERNAME<\/code>, <code>PASSWORD<\/code>, and <code>DATABASE<\/code> from the TiDB Cloud console, as described in the [Prerequisites](..\/README.md#prerequisites) section. Then set the following environment variables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>export DATABASE_URI=\"mysql+pymysql:\/\/&lt;USERNAME&gt;:&lt;PASSWORD&gt;@&lt;HOST&gt;:&lt;PORT&gt;\/&lt;DATABASE&gt;?ssl_ca=\/etc\/ssl\/cert.pem&amp;ssl_verify_cert=true&amp;ssl_verify_identity=true\"<\/code><\/pre>\n\n\n\n<p>or create a <code>.env<\/code> file with the above environment variables.<\/p>\n\n\n\n<p><strong>5.Run this example<\/strong><\/p>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<p><strong>Start the semantic cache server<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>uvicorn cache:app --reload<\/code><\/pre>\n\n\n\n<p><strong>6.Test the API<\/strong><\/p>\n\n\n\n<ol start=\"6\" class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<p>Get the Jina AI API key from the <a href=\"https:\/\/jina.ai\/embeddings\/\">Jina AI Embedding API<\/a> page, and save it somewhere safe for later use.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>POST \/set<\/code><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>curl --location ':8000\/set' \\\n--header 'Content-Type: application\/json' \\\n--header 'Authorization: Bearer &lt;your jina token&gt;' \\\n--data '{\n    \"key\": \"what is tidb\",\n    \"value\": \"tidb is a mysql-compatible and htap database\"\n}'<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>GET \/get\/&lt;key&gt;<\/code><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>curl --location ':8000\/get\/what%27s%20tidb%20and%20tikv?max_distance=0.5' \\\n--header 'Content-Type: application\/json' \\\n--header 'Authorization: Bearer &lt;your jina token&gt;'<\/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>By combining Jina AI&#8217;s powerful embedding capabilities with TiDB&#8217;s efficient vector operations, you can build a robust semantic cache service. This service is ideal for applications requiring fast, intelligent caching and retrieval of semantically similar data. Start experimenting with this setup to explore its full potential in your projects.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">More Demos<\/h3>\n\n\n\n<p>There are some examples to show how to use the tidb-vector-python to interact with TiDB Vector in different scenarios.<\/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, store them in TiDB Vector, and search for similar text.<\/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, store them in TiDB Vector, and search for similar images.<\/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\/tree\/main\/examples\/llamaindex-tidb-vector\">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\n\n\n<li><a href=\"https:\/\/github.com\/pingcap\/tidb-vector-python\/blob\/main\/examples\/jina-ai-embeddings-demo\/README.md\">Build RAG with Jina AI Embeddings<\/a>: use Jina AI to generate embeddings for text data, store the embeddings in TiDB Vector Storage, and search for similar embeddings.<\/li>\n<\/ul>\n\n\n\n<p>Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the rapidly evolving landscape of machine learning and database technologies, combining the strengths of different tools can lead to innovative solutions. One such powerful combination is using Jina AI&#8217;s embedding capabilities with TiDB&#8217;s vector search functionality. This blog will guide you through building a semantic cache service using Jina AI Embeddings and TiDB Vector. [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"template":"","class_list":["post-17767","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 a Semantic Cache Service with Jina AI Embedding and TiDB<\/title>\n<meta name=\"description\" content=\"By combining Jina AI&#039;s embedding capabilities with TiDB&#039;s efficient vector operations, you can build a robust semantic cache service.\" \/>\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 a Semantic Cache Service with Jina AI Embedding and TiDB\" \/>\n<meta property=\"og:description\" content=\"By combining Jina AI&#039;s embedding capabilities with TiDB&#039;s efficient vector operations, you can build a robust semantic cache service.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pingcap.com\/ko\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/\" \/>\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-08-20T10:49:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/static.pingcap.com\/files\/2024\/09\/11005522\/Homepage-Ad.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1440\" \/>\n\t<meta property=\"og:image:height\" content=\"714\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/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-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/\",\"url\":\"https:\/\/www.pingcap.com\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/\",\"name\":\"Build a Semantic Cache Service with Jina AI Embedding and TiDB\",\"isPartOf\":{\"@id\":\"https:\/\/www.pingcap.com\/#website\"},\"datePublished\":\"2024-06-23T15:20:01+00:00\",\"dateModified\":\"2024-08-20T10:49:44+00:00\",\"description\":\"By combining Jina AI's embedding capabilities with TiDB's efficient vector operations, you can build a robust semantic cache service.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pingcap.com\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pingcap.com\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pingcap.com\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/#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 a Semantic Cache Service with Jina AI Embedding and TiDB Vector\"}]},{\"@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 a Semantic Cache Service with Jina AI Embedding and TiDB","description":"By combining Jina AI's embedding capabilities with TiDB's efficient vector operations, you can build a robust semantic cache service.","robots":{"index":"noindex","follow":"follow"},"og_locale":"ko_KR","og_type":"article","og_title":"Build a Semantic Cache Service with Jina AI Embedding and TiDB","og_description":"By combining Jina AI's embedding capabilities with TiDB's efficient vector operations, you can build a robust semantic cache service.","og_url":"https:\/\/www.pingcap.com\/ko\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/","og_site_name":"TiDB","article_publisher":"https:\/\/facebook.com\/pingcap2015","article_modified_time":"2024-08-20T10:49:44+00:00","og_image":[{"width":1440,"height":714,"url":"https:\/\/static.pingcap.com\/files\/2024\/09\/11005522\/Homepage-Ad.png","type":"image\/png"}],"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-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/","url":"https:\/\/www.pingcap.com\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/","name":"Build a Semantic Cache Service with Jina AI Embedding and TiDB","isPartOf":{"@id":"https:\/\/www.pingcap.com\/#website"},"datePublished":"2024-06-23T15:20:01+00:00","dateModified":"2024-08-20T10:49:44+00:00","description":"By combining Jina AI's embedding capabilities with TiDB's efficient vector operations, you can build a robust semantic cache service.","breadcrumb":{"@id":"https:\/\/www.pingcap.com\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pingcap.com\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pingcap.com\/article\/build-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/#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 a Semantic Cache Service with Jina AI Embedding and TiDB Vector"}]},{"@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-a-semantic-cache-service-with-jina-ai-embedding-and-tidb-vector\/\">            <h3>Build a Semantic Cache Service with Jina AI Embedding and TiDB Vector<\/h3>            <p>In the rapidly evolving landscape of machine learning and database technologies, combining the strengths of different tools can lead to innovative solutions. One such powerful combination is using Jina AI&#8217;s embedding capabilities with TiDB&#8217;s vector search functionality. This blog will guide you through building a semantic cache service using Jina AI Embeddings and TiDB Vector. [&hellip;]<\/p>        <\/a>","_links":{"self":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/article\/17767","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=17767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}