---
sidebar_class_name: node-only
---

import CodeBlock from "@theme/CodeBlock";

# Faiss

:::tip Compatibility
Only available on Node.js.
:::

[Faiss](https://github.com/facebookresearch/faiss) is a library for efficient similarity search and clustering of dense vectors.

Langchainjs supports using Faiss as a vectorstore that can be saved to file. It also provides the ability to read the saved file from [Python's implementation](https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html#saving-and-loading).

## Setup

Install the [faiss-node](https://github.com/ewfian/faiss-node), which is a Node.js bindings for [Faiss](https://github.com/facebookresearch/faiss).

```bash npm2yarn
npm install -S faiss-node
```

To enable the ability to read the saved file from [Python's implementation](https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html#saving-and-loading), the [pickleparser](https://github.com/ewfian/pickleparser) also needs to install.

```bash npm2yarn
npm install -S pickleparser
```

## Usage

### Create a new index from texts

import ExampleTexts from "@examples/indexes/vector_stores/faiss.ts";

<CodeBlock language="typescript">{ExampleTexts}</CodeBlock>

### Create a new index from a loader

import ExampleLoader from "@examples/indexes/vector_stores/faiss_fromdocs.ts";

<CodeBlock language="typescript">{ExampleLoader}</CodeBlock>

### Save an index to file and load it again

import ExampleSave from "@examples/indexes/vector_stores/faiss_saveload.ts";

<CodeBlock language="typescript">{ExampleSave}</CodeBlock>

### Load the saved file from [Python's implementation](https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html#saving-and-loading)

import ExamplePython from "@examples/indexes/vector_stores/faiss_loadfrompython.ts";

<CodeBlock language="typescript">{ExamplePython}</CodeBlock>
