> ## Documentation Index
> Fetch the complete documentation index at: https://llm-tools.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# HNSWLib

[HNSWLib](https://github.com/nmslib/hnswlib) is an high performance in-memory vectorstore.
It is great for testing since you do not need access to the file system or a cloud service.

## Install HNSWLib addon

```bash theme={null}
npm install @llm-tools/embedjs-hnswlib
```

## Usage

<CodeGroup>
  ```ts Example theme={null}
  import { RAGApplicationBuilder } from '@llm-tools/embedjs';
  import { OpenAiEmbeddings } from '@llm-tools/embedjs-openai';
  import { HNSWDb } from '@llm-tools/embedjs-hnswlib';
  import { WebLoader } from '@llm-tools/embedjs-loader-web';

  // set OPENAI_API_KEY in your env
  process.env.OPENAI_API_KEY = "sk-xxx";

  const app = await new RAGApplicationBuilder()
  .setEmbeddingModel(new OpenAiEmbeddings())
  .setModel(SIMPLE_MODELS.OPENAI_GPT4_O)
  .setVectorDatabase(new HNSWDb())
  .build();

  //add data source and start query it
  await app.addLoader(new WebLoader({ urlOrContent: 'https://www.forbes.com/profile/elon-musk' }));
  await app.query('Tell me about Elon Musk');
  ```
</CodeGroup>

<Snippet file="missing-vector-db-tip.mdx" />
