From 17f3fcf184ed45ef3d9afe9263e0162921485010 Mon Sep 17 00:00:00 2001 From: Jay Wang Date: Fri, 9 Feb 2024 04:45:35 -0500 Subject: [PATCH] Update readme Signed-off-by: Jay Wang --- LICENSE | 4 +- README.md | 120 +++++++++++++++++- examples/rag-playground/README.md | 1 + .../rag-playground/src/components/app/app.css | 4 + .../rag-playground/src/components/app/app.ts | 6 + .../src/components/playground/playground.ts | 12 +- 6 files changed, 138 insertions(+), 9 deletions(-) create mode 120000 examples/rag-playground/README.md diff --git a/LICENSE b/LICENSE index 72f1d35..8ae9d5b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023, Jay Wang and Polo Chau +Copyright (c) 2024, Jay Wang and Polo Chau Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index fa01a4c..d850e72 100644 --- a/README.md +++ b/README.md @@ -1 +1,119 @@ -# Matmul \ No newline at end of file +# MeMemo + +[![build](https://github.com/poloclub/mememo/actions/workflows/build.yml/badge.svg)](https://github.com/poloclub/mememo/actions/workflows/build.yml) +[![npm](https://img.shields.io/npm/v/mememo?color=orange)](https://www.npmjs.com/package/mememo) +[![license](https://img.shields.io/badge/License-MIT-blue)](https://github.com/poloclub/mememo/blob/main/LICENSE) + + + +A JavaScript library that brings vector search and RAG to your browser! + + + + + + + + + + + +
🤖 ML Paper Reviewer🌠 Prompt Enhancer🌱 Responsible AI Assistant
+ +## What is MeMemo? + +MeMemo is JavaScript library that adapts the state-of-the-art approximate nearest neighbor search technique HNSW to browser environments. +Developed with modern and native Web technologies, such as IndexedDB and Web Workers, our toolkit leverages client-side hardware capabilities to enable researchers and developers to efficiently search through millions of high-dimensional vectors in browsers. +MeMemo enables exciting new design and research opportunities, such as private and personalized content creation and interactive prototyping, as demonstrated in our example application RAG Playground.✨ + +## Getting Started + +### Installation + +MeMemo supports both browser and Node.js environments. To install MeMemo, you can use `npm`: + +```bash +npm install mememo +``` + +### Vector Search and Storage in Browsers + +Then, you can create a vector index and do an approximate nearest neighbor search through two functions: + +```typescript +// Import the HNSW class from the MeMemo module +import { HNSW } from 'mememo'; + +// Creating a new index +const index = new HNSW({ distanceFunction: 'cosine' }); + +// Inserting elements into our index in batches +let keys: string[]; +let values: number[][]; +await index.bulkInsert(keys, values); + +// Find k-nearest neighbors +let query: number[]; +const { keys, distances } = await index.query(query, k); +``` + +## Developing MeMemo + +Clone or download this repository: + +```bash +git clone git@github.com:poloclub/mememo.git +``` + +Install the dependencies: + +```bash +npm install +``` + +Use Vitest for unit testing: + +``` +npm run test +``` + +## Developing the RAG Playground Examples + +Clone or download this repository: + +```bash +git clone git@github.com:poloclub/mememo.git +``` + +Navigate to the example folder: + +```bash +cd ./examples/rag-playground +``` + +Install the dependencies: + +```bash +npm install +``` + +Then run Loan Explainer: + +``` +npm run dev +``` + +Navigate to localhost:3000. You should see three Explainers running in your browser :) + +## Credits + +MeMemo is created by Jay Wang and Polo Chau. + +## License + +The software is available under the [MIT License](https://github.com/poloclub/mememo/blob/main/LICENSE). + +## Contact + +If you have any questions, feel free to [open an issue](https://github.com/poloclub/mememo/issues/new) or contact [Jay Wang](https://zijie.wang). diff --git a/examples/rag-playground/README.md b/examples/rag-playground/README.md new file mode 120000 index 0000000..fe84005 --- /dev/null +++ b/examples/rag-playground/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/examples/rag-playground/src/components/app/app.css b/examples/rag-playground/src/components/app/app.css index d365cfa..b888408 100644 --- a/examples/rag-playground/src/components/app/app.css +++ b/examples/rag-playground/src/components/app/app.css @@ -174,6 +174,10 @@ button { width: 0px; } + a.tab { + text-decoration: none; + } + .tab { position: relative; display: inline-flex; diff --git a/examples/rag-playground/src/components/app/app.ts b/examples/rag-playground/src/components/app/app.ts index 13180c5..fda8554 100644 --- a/examples/rag-playground/src/components/app/app.ts +++ b/examples/rag-playground/src/components/app/app.ts @@ -210,6 +210,12 @@ export class MememoRagPlayground extends LitElement { 3k + +
+ + Add My Documents diff --git a/examples/rag-playground/src/components/playground/playground.ts b/examples/rag-playground/src/components/playground/playground.ts index 6176b96..8241515 100644 --- a/examples/rag-playground/src/components/playground/playground.ts +++ b/examples/rag-playground/src/components/playground/playground.ts @@ -83,8 +83,8 @@ const datasets: Record = { }, [Dataset.arXiv120k]: { - indexURL: STORE_ENDPOINT + 'ml-arxiv-papers-index-120k.json.gzip', - dataURL: STORE_ENDPOINT + 'ml-arxiv-papers-120k.ndjson.gzip', + indexURL: REMOTE_ENDPOINT + 'ml-arxiv-papers-index-120k.json.gzip', + dataURL: REMOTE_ENDPOINT + 'ml-arxiv-papers-120k.ndjson.gzip', datasetName: 'ml-arxiv-papers-120k', datasetNameDisplay: 'ML arXiv Abstracts (120k)' }, @@ -104,15 +104,15 @@ const datasets: Record = { }, [Dataset.DiffusionDB500k]: { - // indexURL: '/data/diffusiondb-prompts-index-1m.json.gzip', - dataURL: '/data/diffusiondb-prompt-500k.ndjson.gzip', + indexURL: REMOTE_ENDPOINT + 'diffusiondb-prompt-index-500k.json.gzip', + dataURL: REMOTE_ENDPOINT + 'diffusiondb-prompt-500k.ndjson.gzip', datasetName: 'diffusiondb-prompts-500k', datasetNameDisplay: 'DiffusionDB Prompts (500k)' }, [Dataset.DiffusionDB1m]: { - // indexURL: '/data/diffusiondb-prompts-index-1m.json.gzip', - dataURL: '/data/diffusiondb-prompt-1m.ndjson.gzip', + indexURL: REMOTE_ENDPOINT + 'diffusiondb-prompt-index-1m.json.gzip', + dataURL: REMOTE_ENDPOINT + 'diffusiondb-prompt-1m.ndjson.gzip', datasetName: 'diffusiondb-prompts-1m', datasetNameDisplay: 'DiffusionDB Prompts (1M)' },