From 0eed6bfec1acab1c8ad7f2ce5d9ce38ec8101c0a Mon Sep 17 00:00:00 2001 From: William Lyon Date: Sun, 8 Dec 2024 17:09:45 -0700 Subject: [PATCH 1/2] cleanup instant vector search recipe --- README.md | 7 ++++--- instant-vector-search/README.md | 28 +++++++++++++++---------- instant-vector-search/assembly/index.ts | 9 ++++++++ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4ebcd78..4be6eee 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Code recipes for cooking with [Modus](https://github.com/hypermodeinc/modus), th ## 🚀 Getting started with Modus -For more infromation on getting started with Modus, check out [the docs](https://docs.hypermode.com/modus/overview). +For more information on getting started with Modus, check out [the docs](https://docs.hypermode.com/modus/overview). ## 📺 Video walkthroughs @@ -16,5 +16,6 @@ The following recipes have associated recorded content: | [modus-getting-started](modus-getting-started/) | [Getting Started With Modus video](https://www.youtube.com/watch?v=3CcJTXTmz88) | | [modushack-data-models](modushack-data-models/) | [ModusHack: Working With Data & AI Models livestream](https://www.youtube.com/watch?v=gB-v7YWwkCw&list=PLzOEKEHv-5e3zgRGzDysyUm8KQklHQQgi&index=3) | | [modus-press](modus-press/) | Coming soon | -| [dgraph-101](dgraph-101/) | [Working with Dgraph in Modus](https://youtu.be/Z2fB-nBf4Wo) | -| [function-calling](function-calling/) | [Use LLM function calling aka tools in Modus.](https://youtu.be/afFk7JzSIm0) | +| [dgraph-101](dgraph-101/) | [Working with Dgraph in Modus](https://youtu.be/Z2fB-nBf4Wo) | +| [function-calling](function-calling/) | [Use LLM function calling aka tools in Modus.](https://youtu.be/afFk7JzSIm0) | +| [instant-vector-search](instant-vector-search) | [Instant vector search with Modus & Hypermode](https://www.youtube.com/watch?v=4H_xPTUbwL8) | diff --git a/instant-vector-search/README.md b/instant-vector-search/README.md index 62e879b..c1d533a 100644 --- a/instant-vector-search/README.md +++ b/instant-vector-search/README.md @@ -1,32 +1,32 @@ # instant-vector-search -A simplified template demonstrating how to build instant vector search using Hypermode and Modus. This project showcases how to configure collections, embed data, and deploy APIs to perform real-time vector search with minimal setup. +A simplified example demonstrating how to build instant vector search using Hypermode and Modus. This project showcases how to configure collections, embed data, and deploy APIs to perform real-time vector search with minimal setup. ## Guide -Check out the guide on how to create a project using this template: -[Instant Vector Search Guide](TODO) +Check out the blog post on how to create a project using this example: +[How to Build an Instant Vector Search App using Hypermode & Modus](https://hypermode.com/blog/instant-vector-search-guide) ## Semantic Search in Action -This template demonstrates how instant vector search can enhance your application by generating embeddings from user queries and performing vector searches in less than 200ms. +This example demonstrates how instant vector search can enhance your application by generating embeddings from user queries and performing vector searches in less than 200ms. ## How to Use the Template Fork or clone this repository to get started: -``` -git clone https://github.com/hypermodeinc/instant-vector-search.git -cd instant-vector-search +```bash +git clone https://github.com/hypermodeinc/modus-recipes.git +cd modus-recipes/instant-vector-search ``` Install Modus CLI: -``` +```bash npm install -g @hypermode/modus-cli ``` -## Initialize and deploy your app: +## Initialize and deploy your app You can deploy using either the Hypermode Console or Hyp CLI. @@ -37,9 +37,15 @@ Option 1: Hypermode Console Option 2: Hyp CLI -- Run the following command to import and deploy your app: +- Install the Hyp CLI +```bash +npm install -g @hypermode/hyp-cli ``` + +- Run the following command to import and deploy your app: + +```bash hyp init ``` @@ -57,7 +63,7 @@ Once your data is in place, the embeddings will be generated automatically, and You can test the API via the Query page in the Hypermode Console. Run a sample vector search query: -``` +```GraphQL query { search(query: "your search term here") } diff --git a/instant-vector-search/assembly/index.ts b/instant-vector-search/assembly/index.ts index 03a3312..7dc17fb 100644 --- a/instant-vector-search/assembly/index.ts +++ b/instant-vector-search/assembly/index.ts @@ -6,6 +6,9 @@ const textsCollection = "texts"; const searchMethod = "searchMethod1"; const embeddingModelName = "minilm"; +/** + * Add text(s) to the collection + */ export function upsertTexts(ids: string[], texts: string[]): string[] { const errors: string[] = []; @@ -24,6 +27,9 @@ export function upsertTexts(ids: string[], texts: string[]): string[] { return ids; } +/** + * Perform a vector search using an embedding of the input string + */ export function search(query: string): string[] { const searchResults = collections.search( textsCollection, @@ -48,6 +54,9 @@ export function search(query: string): string[] { return searchTexts; } +/** + * Embed the input text(s) using the miniLM embedding model + */ export function miniLMEmbed(texts: string[]): f32[][] { const model = models.getModel(embeddingModelName); const input = model.createInput(texts); From d0070b85a4522b1ea6b22c019f8c1270d7a0ced5 Mon Sep 17 00:00:00 2001 From: William Lyon Date: Mon, 9 Dec 2024 08:40:02 -0700 Subject: [PATCH 2/2] Update instant-vector-search/README.md Co-authored-by: Ryan Fox-Tyler <60440289+ryanfoxtyler@users.noreply.github.com> --- instant-vector-search/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instant-vector-search/README.md b/instant-vector-search/README.md index c1d533a..4a5ae58 100644 --- a/instant-vector-search/README.md +++ b/instant-vector-search/README.md @@ -46,7 +46,7 @@ npm install -g @hypermode/hyp-cli - Run the following command to import and deploy your app: ```bash -hyp init +hyp link ``` ## Uploading Data