{"id":33843,"date":"2024-07-09T16:39:36","date_gmt":"2024-07-09T14:39:36","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=33843"},"modified":"2025-01-24T10:40:24","modified_gmt":"2025-01-24T09:40:24","slug":"exploring-vector-search-in-oracle-23c-ai","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/","title":{"rendered":"Exploring Vector Search in Oracle 23c AI"},"content":{"rendered":"\n<p>by Alexandre Nestor<\/p>\n\n\n\n<p>In our data-centric world, efficiently searching and retrieving information is crucial. Traditional search methods frequently fail with the surge of unstructured data. Oracle 23c AI addresses this challenge with a groundbreaking feature: vector search. This innovative tool transforms data handling and retrieval, particularly with complex, high-dimensional datasets. In this blog post, we&#8217;ll explore the concept of vector search, its implementation in Oracle 23c AI, and its transformative impact across various industries.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-understanding-vector-search-short\">Understanding Vector Search (short)<\/h2>\n\n\n\n<p>Vector search, also known as similarity search or nearest neighbor search, involves searching for data points in a vector space. Unlike traditional search methods that rely on exact keyword matches, vector search leverages mathematical representations of data (vectors) to find similarities. Each data point is encoded into a vector, capturing its essential features. The search process then identifies vectors that are closest to the query vector based on a chosen distance metric, such as Euclidean distance or cosine similarity.<\/p>\n\n\n\n<p>Oracle 23c AI integrates vector search capabilities, providing users with an advanced tool for data retrieval. Here\u2019s a closer look at how it works and its features:<\/p>\n\n\n\n<p><strong style=\"font-size: revert;color: initial;, sans-serif\">Seamless Integration:<\/strong><span style=\"font-size: revert;color: initial;, sans-serif\"> Oracle 23c AI&#8217;s vector search is integrated into the database, allowing users to perform vector searches without the need for external tools or complex workflows.<\/span><\/p>\n\n\n\n<p><strong style=\"font-size: revert;color: initial;, sans-serif\">High Performance:<\/strong><span style=\"font-size: revert;color: initial;, sans-serif\"> Leveraging Oracle&#8217;s robust infrastructure, vector search in 23c AI offers high-speed search capabilities even with large datasets. Advanced indexing and optimized algorithms ensure quick and accurate retrieval.<\/span><\/p>\n\n\n\n<p><strong style=\"font-size: revert;color: initial;, sans-serif\">Multi-Modal Data Support:<\/strong><span style=\"font-size: revert;color: initial;, sans-serif\"> Oracle 23c AI supports various data types, including text, images, audio, and more. This versatility makes it a powerful tool for applications across different domains.<\/span><\/p>\n\n\n\n<p><strong style=\"font-size: revert;color: initial;, sans-serif\">Customizable Distance Metrics:<\/strong><span style=\"font-size: revert;color: initial;, sans-serif\"> Users can choose from a variety of distance metrics based on their specific needs, enhancing the flexibility and accuracy of the search results.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-the-flow\">What is the flow<\/h2>\n\n\n\n<p><strong>Data Ingestion:<\/strong> Data is ingested into the Oracle 23c AI database, where it is preprocessed and converted into vectors. This step involves using machine learning models to encode the data&#8217;s features into numerical vectors.<\/p>\n\n\n\n<p><strong>Indexing:<\/strong> The vectors are indexed to facilitate efficient searching. Oracle 23c AI uses advanced indexing techniques, such as hierarchical navigable small world (HNSW) graphs, to enable fast and scalable searches.<\/p>\n\n\n\n<p><strong>Querying:<\/strong> When a query is made, it is also converted into a vector. The vector search algorithm then identifies the closest vectors in the database using the chosen distance metric.<\/p>\n\n\n\n<p><strong>Results:<\/strong> The search results are returned, showcasing the most similar data points to the query. These results can be further refined or analyzed based on the application\u2019s requirements.<\/p>\n\n\n\n<p>The classical example is the image search, and classification following some criteria. <\/p>\n\n\n\n<p>To achieve this goal Oracle can make benefit of ONNX (Open Neural Network Exchange) existent models. ONNX models offer a standardised format for representing deep learning models.<\/p>\n\n\n\n<p>Predefined ONNX models exist for free: <a href=\"https:\/\/github.com\/onnx\/models\">https:\/\/github.com\/onnx\/models<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-building-the-test-environment\">Building the test environment <\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>I use an OCI VM Oracle Linux Server 9.4<\/p>\n\n\n\n<p>I will use Python function to generate the ONNX model. <\/p>\n\n\n\n<p>First step is to create a virtual environnement using python:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n(venv) &#x5B;oracle@db23-134956 ~]$ pip freeze\ncertifi==2024.6.2\ncffi==1.16.0\ncharset-normalizer==3.3.2\ncoloredlogs==15.0.1\ncontourpy==1.2.1\ncryptography==42.0.8\ncycler==0.12.1\nfilelock==3.15.4\nflatbuffers==24.3.25\nfonttools==4.53.0\nfsspec==2024.6.1\nhuggingface-hub==0.23.4\nhumanfriendly==10.0\nidna==3.7\nimportlib_resources==6.4.0\nJinja2==3.1.4\njoblib==1.4.2\nkiwisolver==1.4.5\nMarkupSafe==2.1.5\nmatplotlib==3.9.0\nmpmath==1.3.0\nnetworkx==3.3\nnumpy==1.26.4\nnvidia-cublas-cu12==12.1.3.1\nnvidia-cuda-cupti-cu12==12.1.105\nnvidia-cuda-nvrtc-cu12==12.1.105\nnvidia-cuda-runtime-cu12==12.1.105\nnvidia-cudnn-cu12==8.9.2.26\nnvidia-cufft-cu12==11.0.2.54\nnvidia-curand-cu12==10.3.2.106\nnvidia-cusolver-cu12==11.4.5.107\nnvidia-cusparse-cu12==12.1.0.106\nnvidia-nccl-cu12==2.20.5\nnvidia-nvjitlink-cu12==12.5.82\nnvidia-nvtx-cu12==12.1.105\noml @ file:\/\/\/home\/oracle\/installer\/client\/oml-2.0-cp312-cp312-linux_x86_64.whl#sha256=0c1f7c83256f60c87f1f66b2894098bc8fefd8a60a03e67ba873661dd178b3c2\nonnx==1.16.1\nonnxruntime==1.18.1\nonnxruntime_extensions==0.11.0\noracledb==2.2.1\npackaging==24.1\npandas==2.2.2\npillow==10.4.0\nprotobuf==5.27.2\npycparser==2.22\npyparsing==3.1.2\npython-dateutil==2.9.0.post0\npytz==2024.1\nPyYAML==6.0.1\nregex==2024.5.15\nrequests==2.32.3\nsafetensors==0.4.3\nscikit-learn==1.5.0\nscipy==1.13.1\nsentencepiece==0.2.0\nsetuptools==70.2.0\nsix==1.16.0\nsympy==1.12.1\nthreadpoolctl==3.5.0\ntokenizers==0.19.1\ntorch==2.3.1\ntqdm==4.66.4\ntransformers==4.42.3\ntyping_extensions==4.12.2\ntzdata==2024.1\nurllib3==2.2.2\nzipp==3.19.2\n<\/pre><\/div>\n\n\n<p>I also use Oracle Database 23ai Free as docker image. <\/p>\n\n\n\n<p>To start the docker image I use this command, and I put datafiles and archivelogs on external mount point: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n(venv) &#x5B;oracle@db23-134956 ~]$ docker run  -it --name 23ai -p 1700:1521 \\\n-v \/u02\/data\/DB:\/opt\/oracle\/oradata \\\n-v \/u02\/reco\/DB:\/opt\/oracle\/reco \\\n-e ENABLE_ARCHIVELOG=true  \\\ncontainer-registry.oracle.com\/database\/free\n<\/pre><\/div>\n\n\n<p>Let&#8217;s get the ONX image  and built it for our usage: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n(venv) &#x5B;oracle@db23-134956 ~]$ python\nPython 3.12.1 (main, Feb 19 2024, 00:00:00) &#x5B;GCC 11.4.1 20231218 (Red Hat 11.4.1-3.0.1)] on linux\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\n&gt;&gt;&gt; from oml.utils import EmbeddingModel, EmbeddingModelConfig\n&gt;&gt;&gt; em = EmbeddingModel(model_name=&quot;sentence-transformers\/all-MiniLM-L6-v2&quot;)\n&gt;&gt;&gt; em.export2file(&quot;all-MiniLM-L6-v2&quot;, output_dir=&quot;.&quot;)\ntokenizer_config.json: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 350\/350 &#x5B;00:00&lt;00:00, 4.01MB\/s]\nvocab.txt: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 232k\/232k &#x5B;00:00&lt;00:00, 1.15MB\/s]\nspecial_tokens_map.json: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 112\/112 &#x5B;00:00&lt;00:00, 1.52MB\/s]\ntokenizer.json: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 466k\/466k &#x5B;00:00&lt;00:00, 1.55MB\/s]\nconfig.json: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 612\/612 &#x5B;00:00&lt;00:00, 8.23MB\/s]\nmodel.safetensors: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 90.9M\/90.9M &#x5B;00:00&lt;00:00, 304MB\/s]\n&gt;&gt;&gt; exit()\nl(venv) &#x5B;oracle@db23-134956 ~]$ ls\nall-MiniLM-L6-v2.onnx  venv\n<\/pre><\/div>\n\n\n<p>The ONNX generated file is <code>all-MiniLM-L6-v2.onnx<\/code><\/p>\n\n\n\n<p>Finally I copy the ONNX generated file to a shared directory to be able to import it to the database: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n(venv) &#x5B;oracle@db23-134956 ~]$ cp all-MiniLM-L6-v2.onnx \/u02\/data\/DB\/FREE\/FREEPDB1\/dump\/1AC27018093909F8E063020011AC7FF6\/\n<\/pre><\/div>\n\n\n<p>Let&#8217;s connect to the database and load the ONNX model into database:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n(venv) &#x5B;oracle@db23-134956 ~]$ sqlplus system\/oracle@localhost:1700\/freepdb1\n\nSQL*Plus: Release 23.0.0.0.0 - Production on Wed Jul 3 09:12:02 2024\nVersion 23.4.0.24.05\n\nSQL&gt; create or replace directory DATA_PUMP_DIR as &#039;\/opt\/oracle\/oradata\/FREE\/FREEPDB1\/dump&#039;;\n\nDirectory created.\n\nSQL&gt; begin\n  2  dbms_vector.load_onnx_model(\n  3  directory =&gt; &#039;DATA_PUMP_DIR&#039;\n  4  , file_name =&gt; &#039;all-MiniLM-L6-v2.onnx&#039;\n  5  , model_name =&gt; &#039;all_minilm_l6_v2&#039;\n  6  , metadata =&gt; json(&#039;{&quot;function&quot; : &quot;embedding&quot;, &quot;embeddingOutput&quot; : &quot;embedding&quot; , &quot;input&quot;: {&quot;input&quot;: &#x5B;&quot;DATA&quot;]}}&#039;)\n  7  );\n  8  end;\n  9  \/\n\nPL\/SQL procedure successfully completed.\n\n-- test the loaded model \nSQL&gt; select\n  model_name\n  , mining_function\n  , algorithm\n  , (model_size\/1024\/1024) as model_size_mb\nfrom user_mining_models\norder by model_name;  2    3    4    5    6    7\n\nMODEL_NAME\n--------------------------------------------------------------------------------\nMINING_FUNCTION \t       ALGORITHM\t\t      MODEL_SIZE_MB\n------------------------------ ------------------------------ -------------\nALL_MINILM_L6_V2\nEMBEDDING\t\t       ONNX\t\t\t\t 86.4376068\n\n<\/pre><\/div>\n\n\n<p>The test table contains a word, the description end the generated vector:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n-- create the table  \nSQL&gt; create table my_dictionary(\n id number generated always as identity\n  , word varchar2(100) not null\n  , description varchar2(500) not null\n  , word_vector vector not null\n   );\n\nTable created.\n\n-- create the trigger to generate the vector \nSQL&gt; create or replace trigger my_dict_vect_build\nbefore insert or update on my_dictionary\nfor each row\ndeclare\nbegin\n  :new.word_vector := dbms_vector_chain.utl_to_embedding(\n    data =&gt; :new.word\n    , params =&gt; json(q&#039;&#x5B;{&quot;provider&quot;: &quot;database&quot;,  2   &quot;model&quot;: &quot;&amp;model_name.&quot;}]&#039;)\n  );\nend;\n\/  3    4    5    6    7    8    9   10   11\nEnter value for model_name: all_minilm_l6_v2\nold   8:     , params =&gt; json(q&#039;&#x5B;{&quot;provider&quot;: &quot;database&quot;,  2   &quot;model&quot;: &quot;&amp;model_name.&quot;}]&#039;)\nnew   8:     , params =&gt; json(q&#039;&#x5B;{&quot;provider&quot;: &quot;database&quot;,  2   &quot;model&quot;: &quot;all_minilm_l6_v2&quot;}]&#039;)\n\nTrigger created.\n\n-- create and index on the table\nSQL&gt; create vector index my_dict_ivf_idx\n  on my_dictionary(word_vector)\n  organization neighbor partitions\n  distance cosine\n  with target accuracy 95;\n\nIndex created.\n<\/pre><\/div>\n\n\n<p>I download a dictionary from  the web in CSV mode as word | description from <a href=\"https:\/\/www.bragitoff.com\/2016\/03\/english-dictionary-in-csv-format\">https:\/\/www.bragitoff.com\/2016\/03\/english-dictionary-in-csv-format<\/a> and I formatted it to be somehow like this : <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nScore;q&#039;&#x5B;To engrave, as upon a shield.]&#039;\nScore;q&#039;&#x5B;To make a score of, as points, runs, etc., in a game.]&#039;\nScore;q&#039;&#x5B;To write down in proper order and arrangement  as, to score an overture for an orchestra. See Score, n., 9.]&#039;\nScore;q&#039;&#x5B;To mark with parallel lines or scratches  as, the rocks of New England and the Western States were scored in the drift epoch.]&#039;\nScorer;q&#039;&#x5B;One who, or that which, scores.]&#039;\n<\/pre><\/div>\n\n\n<p>The I loaded the dictionary into a table <code>dict<\/code> using <code>sqlldr<\/code>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nSQL&gt; \n\nSQL&gt; desc dict;\nName Null? Type\n\nWORD VARCHAR2(100)\nDESCRIPTION NOT NULL VARCHAR2(500)\n\nUsing these parameters files: \n\n&#x5B;oracle@0c97e3a7be16 ]$ cat ld.par\ncontrol=ld.ctl\nlog=ld.log\nbad=ld.bad\ndata=ld.csv\ndirect=true\nerrors=1000000\n\n&#x5B;oracle@0c97e3a7be16 ]$ cat ld.ctl \nload data into table dict\ninsert\nfields terminated by &quot;;&quot;\n(word,description\n)\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n&#x5B;oracle@0c97e3a7be16 1AC27018093909F8E063020011AC7FF6]$  sqlldr &#039;system\/&quot;Hello-World-123&quot;@freepdb1&#039; parfile=ld.par\n\nSQL*Loader: Release 23.0.0.0.0 - Production on Tue Jul 9 09:47:59 2024\nVersion 23.4.0.24.05\n\nCopyright (c) 1982, 2024, Oracle and\/or its affiliates.  All rights reserved.\n\nPath used:      Direct\n\nLoad completed - logical record count 54555.\n\nTable DICT:\n  19080 Rows successfully loaded.\n\nCheck the log file:\n  ld.log\nfor more information about the load.\n\nSQL&gt; select count(*) from dict;\n\n  COUNT(*)\n----------\n     19080\n\n<\/pre><\/div>\n\n\n<p>Finally insert into the final table my_dictionars. The trigger will build the vector information <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; insert into my_dictionary(word,DESCRIPTION)  select WORD,DESCRIPTION from dict;\n\n19080 rows created.\n\nSQL&gt; commit;\n\nCommit complete.\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-let-s-test-the-miraculous-ai\">Let&#8217;s test the miraculous AI.<\/h2>\n\n\n\n<p>The ONNX model used was designed to search words. Obviously more the model is complicates mode the research is precise, and more is expensive. <\/p>\n\n\n\n<p>The question is <em>what are the first x words from my build dictionary which are most closely to a given word<\/em>. As My dictionary contains words similar I used distinct to filter the final result. <\/p>\n\n\n\n<p>Let&#8217;s search the result for the word &#8220;Sun&#8221;: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; define search_term=&quot;Sun&quot;;\n\nselect distinct word from (\nwith subject as (\n  select to_vector(\n  vector_embedding(&amp;model_name. using &#039;&amp;search_term.&#039; as data)\n  ) as search_vector\n  )\n  select o.word from my_dictionary o, subject s order by cosine_distance(\n    o.word_vector, s.search_vector)\n  fetch approx first 50 rows only with target accuracy 80);  2    3    4    5    6    7    8    9\nold   4:   vector_embedding(&amp;model_name. using &#039;&amp;search_term.&#039; as data)\nnew   4:   vector_embedding(all_minilm_l6_v2 using &#039;Sun&#039; as data)\n\nWORD\n--------------------------------------------------------------------------------\nRadiant\nRadiate\nLight\nRadiancy\nEarth shine\nHeat\n\n6 rows selected.\n\n<\/pre><\/div>\n\n\n<p>Test for the word &#8220;Seed&#8221;: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nSQL&gt; define search_term=&quot;Seed&quot;;\nSQL&gt; \/\nold   4:   vector_embedding(&amp;model_name. using &#039;&amp;search_term.&#039; as data)\nnew   4:   vector_embedding(all_minilm_l6_v2 using &#039;Seed&#039; as data)\n\nWORD\n--------------------------------------------------------------------------------\nGerminate\nGermination\nFeeder\nGrow\nGerminal\nHeartseed\nGrass\nFertile\nFertilization\nGrass-grown\nHarvest\nFruit\nGrower\nPackfong\nPack\nAgnation\nGusset\n\n17 rows selected.\n<\/pre><\/div>\n\n\n<p>The result&#8217;s is pretty cool <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion <\/h2>\n\n\n\n<p>The AI is here, everyone is using it. We are going to use it more and more. Artificial Intelligence (AI) has rapidly evolved from a theoretical concept into a transformative force across numerous industries, redefining how we interact with technology and fundamentally altering societal structures.<\/p>\n\n\n\n<p>This example is limited, the ONNX model is simple, but shows how easy we can implemented a solution which can project into the AI world. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Exploring Vector Search in Oracle 23c AI<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[59],"tags":[2810,3404,135,96],"type_dbi":[3406,2728],"class_list":["post-33843","post","type-post","status-publish","format-standard","hentry","category-oracle","tag-ai","tag-artificial-inteligence","tag-cloud","tag-oracle","type-23ai","type-oracle"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Exploring Vector Search in Oracle 23c AI - dbi Blog<\/title>\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.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exploring Vector Search in Oracle 23c AI\" \/>\n<meta property=\"og:description\" content=\"Exploring Vector Search in Oracle 23c AI\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-09T14:39:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-24T09:40:24+00:00\" \/>\n<meta name=\"author\" content=\"Oracle Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oracle Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/\"},\"author\":{\"name\":\"Oracle Team\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"headline\":\"Exploring Vector Search in Oracle 23c AI\",\"datePublished\":\"2024-07-09T14:39:36+00:00\",\"dateModified\":\"2025-01-24T09:40:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/\"},\"wordCount\":814,\"commentCount\":0,\"keywords\":[\"ai\",\"Artificial inteligence\",\"Cloud\",\"Oracle\"],\"articleSection\":[\"Oracle\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/\",\"name\":\"Exploring Vector Search in Oracle 23c AI - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2024-07-09T14:39:36+00:00\",\"dateModified\":\"2025-01-24T09:40:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exploring Vector Search in Oracle 23c AI\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\",\"name\":\"Oracle Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"caption\":\"Oracle Team\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Exploring Vector Search in Oracle 23c AI - dbi Blog","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.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/","og_locale":"en_US","og_type":"article","og_title":"Exploring Vector Search in Oracle 23c AI","og_description":"Exploring Vector Search in Oracle 23c AI","og_url":"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/","og_site_name":"dbi Blog","article_published_time":"2024-07-09T14:39:36+00:00","article_modified_time":"2025-01-24T09:40:24+00:00","author":"Oracle Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Oracle Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/"},"author":{"name":"Oracle Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"headline":"Exploring Vector Search in Oracle 23c AI","datePublished":"2024-07-09T14:39:36+00:00","dateModified":"2025-01-24T09:40:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/"},"wordCount":814,"commentCount":0,"keywords":["ai","Artificial inteligence","Cloud","Oracle"],"articleSection":["Oracle"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/","url":"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/","name":"Exploring Vector Search in Oracle 23c AI - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2024-07-09T14:39:36+00:00","dateModified":"2025-01-24T09:40:24+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/exploring-vector-search-in-oracle-23c-ai\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Exploring Vector Search in Oracle 23c AI"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee","name":"Oracle Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","caption":"Oracle Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/33843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=33843"}],"version-history":[{"count":12,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/33843\/revisions"}],"predecessor-version":[{"id":36861,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/33843\/revisions\/36861"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=33843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=33843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=33843"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=33843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}