{"id":20284178,"url":"https://github.com/clebert/embedix","last_synced_at":"2025-10-10T17:42:40.936Z","repository":{"id":221050628,"uuid":"753326312","full_name":"clebert/embedix","owner":"clebert","description":"A simple vector store written in TypeScript with a WASM backend.","archived":false,"fork":false,"pushed_at":"2024-02-15T09:11:20.000Z","size":288,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-13T11:27:19.722Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clebert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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-02-05T22:34:00.000Z","updated_at":"2024-02-05T23:03:20.000Z","dependencies_parsed_at":"2024-10-15T11:00:43.439Z","dependency_job_id":null,"html_url":"https://github.com/clebert/embedix","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"4b814df62730ecd8647727876618372ea8a1ddd3"},"previous_names":["clebert/embedix"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/clebert/embedix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clebert%2Fembedix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clebert%2Fembedix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clebert%2Fembedix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clebert%2Fembedix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clebert","download_url":"https://codeload.github.com/clebert/embedix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clebert%2Fembedix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004823,"owners_count":26083784,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-14T14:18:36.505Z","updated_at":"2025-10-10T17:42:40.919Z","avatar_url":"https://github.com/clebert.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Embedix\n\n\u003e A simple vector store written in TypeScript with a WASM backend.\n\n## Installation\n\n```sh\nnpm install embedix\n```\n\n## Usage Example\n\n```js\nimport { Store } from 'embedix';\nimport { readFile } from 'node:fs/promises';\nimport { fileURLToPath } from 'node:url';\n\nStore.wasmModule = await WebAssembly.compile(\n  await readFile(fileURLToPath(import.meta.resolve(`embedix/store.wasm`))),\n);\n\nconst state = Store.prepareState([\n  { document: `bar`, documentEmbedding: [4, 5, 6] },\n  { document: `qux`, documentEmbedding: [-1, -2, -3] },\n  { document: `foo`, documentEmbedding: [2, 4, 6] },\n  { document: `baz`, documentEmbedding: [6, -3, 0] },\n]);\n\nconst store = await Store.create(state.init);\n\nstore.documentEmbeddings.set(state.documentEmbeddings);\nstore.queryEmbedding.set([1, 2, 3]);\n\nconst queryResults = store.performQuery();\n\nconsole.log(queryResults);\n```\n\n```json\n[\n  { \"document\": \"foo\", \"distance\": 0 },\n  { \"document\": \"bar\", \"distance\": 0.025368094444274902 },\n  { \"document\": \"baz\", \"distance\": 1 },\n  { \"document\": \"qux\", \"distance\": 2 }\n]\n```\n\n## AWS Lambda: Best Practices\n\nEmbedix is designed to operate seamlessly within an AWS Lambda Node.js environment. The primary\nfocus is on reducing the cold start time by serializing the state prepared with the\n`Store.prepareState` function into two separate files. The resulting first file should comprise the\n`init` state in JSON format. This will facilitate rapid store initialization within the Lambda\nfunction. Simultaneously, a second file should encapsulate the `documentEmbeddings` state - a\nFloat32Array - saved as a binary file. This is designed to be directly loaded into the\n`store.documentEmbeddings` Float32Array. As a best practice, it is recommended to use the Node.js\n[`filehandle.read([options])`](https://nodejs.org/api/fs.html#filehandlereadoptions) function to\navoid redundant byte duplication at runtime.\n\nIt is also advisable to declare the store as a module scope variable outside of the handler function\nand initialize it lazily on the first handler call. This enables the reuse of the store instance for\nsubsequent calls as long as the Lambda function remains warm.\n\n## Performance\n\nAll results presented are based on the average of 1,000 query repetitions.\n\n| System                     | Node.js | Query Duration | Embedding Size | Document Count |\n| -------------------------- | ------- | -------------- | -------------- | -------------- |\n| Apple M1 Pro               | v20     | 2.28 ms        | 768            | 10,000         |\n| Apple M1 Pro               | v20     | 28.11 ms       | 768            | 100,000        |\n| Apple M1 Pro               | v20     | 32.36 ms       | 1,000          | 100,000        |\n| AWS Lambda (x86/1,769 MB)  | v20     | 5.94 ms        | 768            | 10,000         |\n| AWS Lambda (x86/10,240 MB) | v20     | 5.21 ms        | 768            | 10,000         |\n| AWS Lambda (ARM/1,769 MB)  | v20     | 8.70 ms        | 768            | 10,000         |\n\n**Note:** At 1,769 MB, an AWS Lambda function has the equivalent of one vCPU.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclebert%2Fembedix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclebert%2Fembedix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclebert%2Fembedix/lists"}