Optional parameters for configuring the index, passed as a dictionary.
Parameters by Index Type
IVFFlat
Parameter
Type
Default
Description
n_lists
int
1024
Number of inverted lists (clusters)
IVFPQ
Parameter
Type
Default
Description
n_lists
int
1024
Number of inverted lists (clusters)
pq_dim
int
8
Dimensionality after product quantization
pq_bits
int
8
Bits per quantized dimension (1-16)
IVFSQ
Parameter
Type
Default
Description
n_lists
int
1024
Number of inverted lists (clusters)
sq_bits
int
16
Bits per scalar quantized value
Tuning Guidelines
n_lists: Use √n where n is the expected number of vectors. Common values: 256, 512, 1024, 2048
pq_dim: Should divide the embedding dimension evenly. Lower values = more compression
pq_bits / sq_bits: 8 bits provides good balance. Lower = more compression, higher = better accuracy
Document
LangChain Document object used for storing text with metadata.
Attributes
Attribute
Type
Description
page_content
str
The text content of the document
metadata
dict
Optional metadata associated with the document
Example Usage
from langchain_core.documents import Document# Create a documentdoc = Document( page_content="This is the content of my document", metadata={ "source": "manual", "author": "John Doe", "timestamp": "2024-01-01" })# Add to vector storestore.add_documents([doc])
Filter Format
Metadata filters use a dictionary format for querying documents.
The Python SDK supports the same embedding types as the Embedded library:
Type
Description
Example
str
Model name string for SentenceTransformers
"sentence-transformers/all-MiniLM-L6-v2"
SentenceTransformer
SentenceTransformer model instance
SentenceTransformer("all-MiniLM-L6-v2")
Embeddings
Any LangChain Embeddings implementation
OpenAIEmbeddings(), HuggingFaceEmbeddings()
DistanceMetric
Same as Embedded:
"cosine": Cosine similarity (recommended for normalized embeddings)
"euclidean": Euclidean distance
"squared_euclidean": Squared Euclidean distance
Metric
Range
Best Match
Use Case
cosine
[0, 2]
0
Text embeddings, normalized vectors
euclidean
[0, ∞)
0
Raw feature vectors
squared_euclidean
[0, ∞)
0
When avoiding sqrt computation
IndexType
Same as Embedded:
Type
Description
Speed
Recall
Index Size
"ivfflat"
Inverted file with flat storage
Fast
Highest
Biggest
"ivfpq"
Inverted file with product quantization
Fast
High
Medium
"ivfsq"
Inverted file with scalar quantization
Fast
High
Small
Document
LangChain Document object used for storing text with metadata.
Attribute
Type
Description
page_content
str
The text content of the document
metadata
dict
Optional metadata associated with the document
from langchain_core.documents import Documentdoc = Document( page_content="This is the content of my document", metadata={"source": "manual", "author": "John Doe"})
Filter Format
Same filter format as Embedded. Metadata filters use a dictionary format:
(Optional) Additional index configuration parameters
dimension
number
-
(Optional) Embedding dimension (auto-inferred if not provided)
metric
string
"cosine"
(Optional) Distance metric
verifySsl
boolean
true
(Optional) SSL verification
All parameters use camelCase convention, consistent with JavaScript/TypeScript standards.
EmbeddingsInterface
The JS/TS SDK accepts any LangChain EmbeddingsInterface implementation:
import { OpenAIEmbeddings } from '@langchain/openai';import { HuggingFaceTransformersEmbeddings } from '@langchain/community/embeddings/hf_transformers';// OpenAI embeddingsconst embeddings = new OpenAIEmbeddings();// HuggingFace embeddingsconst embeddings = new HuggingFaceTransformersEmbeddings({ model: "all-MiniLM-L6-v2"});
Unlike the Python SDKs, the JS/TS SDK does not accept raw model name strings. You must pass a LangChain EmbeddingsInterface instance.
DistanceMetric
Same options as Python SDKs:
"cosine": Cosine similarity (recommended for normalized embeddings)
"euclidean": Euclidean distance
"squared_euclidean": Squared Euclidean distance
Document
LangChain Document object:
import { Document } from '@langchain/core/documents';const doc = new Document({ pageContent: "This is the content of my document", metadata: { source: "manual", author: "John Doe" }});