{"id":15464507,"url":"https://github.com/retzd-tech/genkitx-hnsw","last_synced_at":"2026-03-14T07:02:05.482Z","repository":{"id":238734436,"uuid":"797377904","full_name":"retzd-tech/genkitx-hnsw","owner":"retzd-tech","description":"Genkit AI framework plugin for HNSW vector database. get AI response enriched with additional context and knowledge with HNSW Vector Database using RAG Implementation","archived":false,"fork":false,"pushed_at":"2024-05-19T20:57:23.000Z","size":1317,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-23T23:47:49.319Z","etag":null,"topics":["ai","firebase","genai","genkit","genkit-plugin","genkitx","hnsw","plugin","rag","vector"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/genkitx-hnsw","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/retzd-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-07T17:58:47.000Z","updated_at":"2025-02-07T15:29:14.000Z","dependencies_parsed_at":"2024-05-07T19:47:06.163Z","dependency_job_id":"cd5371c9-6e4e-4283-8ef6-d1cdc1119f31","html_url":"https://github.com/retzd-tech/genkitx-hnsw","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"397249c1daa18958b39674b5b9a06e6c953cf3d8"},"previous_names":["retzd-tech/genkitx-hnsw"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retzd-tech%2Fgenkitx-hnsw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retzd-tech%2Fgenkitx-hnsw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retzd-tech%2Fgenkitx-hnsw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retzd-tech%2Fgenkitx-hnsw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/retzd-tech","download_url":"https://codeload.github.com/retzd-tech/genkitx-hnsw/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535098,"owners_count":21446505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","firebase","genai","genkit","genkit-plugin","genkitx","hnsw","plugin","rag","vector"],"created_at":"2024-10-02T00:38:00.532Z","updated_at":"2026-03-14T07:02:05.434Z","avatar_url":"https://github.com/retzd-tech.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Genkit Plugin HNSW Vector Database\n\n![Genkit HNSW Logo](https://github.com/retzd-tech/genkitx-hnsw/blob/main/assets/genkit-hnsw-logo.png?raw=true)\n\nYou can contribute to this plugin in this [Repository](https://github.com/retzd-tech/genkitx-hnsw).\n\n## Description\nHNSW is Vector Database Hierarchical Navigable Small World (HNSW) graphs are among the top-performing indexes for vector similarity search. HNSW is a hugely popular technology that time and time again produces state-of-the-art performance with super fast search speeds and fantastic recall. learn more about [HNSW](https://www.pinecone.io/learn/series/faiss/hnsw).\n\nYou can prefer this vector database if you prefer\n- A simple vector database setup\n- Handle and manage your own vector index on your own server\n- Managing vector index as a File\n- Small size but fast performance\n\nWith this you can achieve a high performing Retrieval Augmentation Generation (RAG) in Generative AI so you do not need to build your own AI Model or retrain the AI Model to get more context or knowledge, instead you can add additional layer of context so that your AI Model can understand more knowledge than what the base AI Model knows. this is useful if you want to get more context or more knowledge based on specific informations or knowledge that you define.\n\n### Example use case :\nYou have Restaurant application or website, you can add specific information about your restaurants, address, food menu list with its price and the other specific things, so that when your customer ask something to the AI about your Restaurant, your AI can answer it accurately. this can remove your effort to build a Chatbot, instead you can use Generative AI enriched with specific knowledge.\n\nExample conversation :\n\n`You` : What is the price list of my restaurant in Surabaya City ?\n\n`AI` : Price list :\n- Rawon Setan - Rp. 15.000\n- Lontong Balap - Rp.12.000\n- Rendang - Rp.15.000\n\n## Installation\nBefore installing the plugin, ensure you have the following prerequisites installed:\n- [Node.js](https://nodejs.org/) (version 12 or higher)\n- [npm](https://www.npmjs.com/) (usually comes with Node.js installation)\n- [TypeScript](https://www.typescriptlang.org/) (you can install it globally via npm: `npm install -g typescript`)\n\nTo install this plugin, you can run this command or with your prefered package manager\n\n```bash\nnpm install genkitx-hnsw\n```\n\n## Plugin List\nThis plugin has several functionality as below :\n- `HNSW Indexer`\n  Used to create a Vector Index based on all the data and information you provided. this Vector Index will be used as a knowledge reference of HNSW Retriever.\n- `HNSW Retriever`\n  Used to get Generative AI response with Gemini Model as a base enriched with additional knowledge and context based on your Vector Index.\n\n## Usage\n\n## Usage HNSW Indexer plugin\nThis is a usage of Genkit plugin flow to save data into vector store with HNSW Vector Store, Gemini Embedder and Gemini LLM.\n\n#### Data preparations\nPrepare your data or documents in a Folder\n![Restaurants data](https://github.com/retzd-tech/genkitx-hnsw/blob/main/assets/restaurants-data.png?raw=true)\n\n#### Register HNSW Indexer Plugin\nImport the plugin into your Genkit project\n```bash\nimport { hnswIndexer } from \"genkitx-hnsw\";\n\nexport default configureGenkit({\n  plugins: [\n    hnswIndexer({ apiKey: \"GOOGLE_API_KEY\" })\n  ]\n});\n```\n\n#### Genkit UI HNSW Indexer flow running\nOpen Genkit UI and choose the registered plugin `HNSW Indexer`\n\nExecute the flow with Input and Output required parameter\n- `dataPath` : Your data and other documents path to be learned by the AI\n- `indexOutputPath` : Your expected output path for your Vector Store Index that is processed based on the data and documents you provided\n\n![Genkit UI HNSW Indexer Flow](https://github.com/retzd-tech/genkitx-hnsw/blob/main/assets/hnsw-indexer-flow.png?raw=true)\n\n#### Vector Store Index Result\n![HNSW Vector](https://github.com/retzd-tech/genkitx-hnsw/blob/main/assets/hnsw-indexer-result.png?raw=true)\nVector store will be saved in the defined output path. this index will be used for the prompt generation process with the HNSW Retriever plugin. you can continue the implementation by using the HNSW Retriever plugin \n\n### Optional Parameter\n  - `chunkSize: number`\n  How much data is processed at a time. It's like breaking a big task into smaller pieces to make it more manageable. By setting the chunk size, we decide how much information the AI handles in one go, which can affect both the speed and accuracy of the AI's learning process.\n\n    `default value : 12720`\n  - `separator: string`\n  During the creation of a vector index is a symbol or character used to separate different pieces of information in the input data. It helps the AI understand where one unit of data ends and another begins, enabling it to process and learn from the data more effectively.\n\n    `default value : \"\\n\"`\n\n## Usage HNSW Retriever plugin\nThis is a usage of Genkit plugin flow to process your prompt with Gemini LLM Model enriched with additional and specific information or knowledge within the HNSW Vector Database you provided. with this plugin you will get LLM response with additional specific context.\n\n\n#### Register HNSW Retriever Plugin\nImport the plugin into your Genkit project\n```bash\nimport { googleAI } from \"@genkit-ai/googleai\";\nimport { hnswRetriever } from \"genkitx-hnsw\";\n\nexport default configureGenkit({\n  plugins: [\n    googleAI(),\n    hnswRetriever({ apiKey: \"GOOGLE_API_KEY\" })\n  ]\n});\n```\nMake sure you import the GoogleAI plugin for the Gemini LLM Model provider, currently this plugin only supports Gemini, will provide more model soon!\n\n#### Genkit UI HNSW Retriever flow running\nOpen Genkit UI and choose the registered Plugin `HNSW Retriever`\nExecute the flow with the required parameter\n- `prompt` : Type your prompt where you will get answers with more enriched context based on the vector you provided.\n- `indexPath` : Define folder Vector Index path you wanna use as a knowledge reference, where you get this files path from HNSW Indexer plugin.\n\nIn this example, Let's try to ask about the price list information of a restaurant in Surabaya city, where it has been provided within the Vector Index.\n\nWe can type the prompt and run it, after the flow finished, you will get response enriched with specific knowledge based on your Vector Index.\n\n![Genkit UI Prompt Result](https://github.com/retzd-tech/genkit-hnsw/blob/main/assets/hnsw-retriever-flow.png?raw=true)\n\n### Optional Parameter\n  - `temperature: number`\n  temperature controls the randomness of the generated output. Lower temperatures result in more deterministic output, with the model selecting the most likely token at each step. Higher temperatures increase the randomness, allowing the model to explore less probable tokens, potentially generating more creative but less coherent text.\n\n    `default value : 0.1`\n  - `maxOutputTokens: number`\n  This parameter specifies the maximum number of tokens (words or subwords) the model should generate in a single inference step. It helps control the length of the generated text.\n\n    `default value : 500`\n  - `topK: number`\n  Top-K sampling restricts the model's choices to the top K most likely tokens at each step. This helps prevent the model from considering overly rare or unlikely tokens, improving the coherence of the generated text.\n\n    `default value : 1`\n  - `topP: number`\n  Top-P sampling, also known as nucleus sampling, considers the cumulative probability distribution of tokens and selects the smallest set of tokens whose cumulative probability exceeds a predefined threshold (often denoted as P). This allows for dynamic selection of the number of tokens considered at each step, depending on the likelihood of the tokens.\n\n    `default value : 0`\n  - `stopSequences: string[]`\n  These are sequences of tokens that, when generated, signal the model to stop generating text. This can be useful for controlling the length or content of the generated output, such as ensuring the model stops generating after reaching the end of a sentence or paragraph.\n\n    `default value : []`\n\nLicense : Apache 2.0","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretzd-tech%2Fgenkitx-hnsw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fretzd-tech%2Fgenkitx-hnsw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretzd-tech%2Fgenkitx-hnsw/lists"}