mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-09-11 04:01:32 +00:00
- Migrate from mint.json to docs.json (Mintlify v4) - Theme: maple, emerald green + near-black dark / cream light palette (#059669 primary, #0A0A0A dark bg, #FAF7F0 light bg) - Typography: Lexend headings, Inter body - 5-tab navigation: Documentation, Quick Start, API Reference, Cookbook, FAQ - Homepage: removed badge stickers, redundant h2, added blockquote tagline, full 27-module reference table with semantica.mcp_server added - quickstart.md: CodeGroup per pipeline step, pattern vs LLM options, AccordionGroup for patterns and troubleshooting - faq.md: full AccordionGroup structure across 5 sections - reference/explorer.md: NEW — FastAPI explorer, Ontology Hub, Distance Intelligence, CLI reference, REST API endpoints - reference/mcp_server.md: NEW — MCP stdio server, 12 tools with I/O examples, 3 resources, Claude Desktop/VS Code/Windsurf/Cline config - docs.json: explorer added to Output group, mcp_server to Utilities group - Chat, feedback (thumbs/suggest/raise), OG/Twitter metadata, search topbar - All reference pages reformatted with Mintlify JSX components Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
118 lines
2.8 KiB
Markdown
118 lines
2.8 KiB
Markdown
---
|
||
title: "Vector Store: High-Performance Usage"
|
||
description: "Parallel ingestion, batch processing, and performance tuning for the Semantica Vector Store."
|
||
icon: "bolt"
|
||
---
|
||
|
||
> High-performance batch ingestion with parallel embedding generation — 3–10× faster than sequential processing.
|
||
|
||
---
|
||
|
||
## Key Features
|
||
|
||
- **Parallel ingestion** — multi-threaded embedding generation and storage
|
||
- **Batch processing** — minimizes overhead by grouping documents into chunks
|
||
- **Unified API** — `add_documents` handles embedding generation and storage in one call
|
||
|
||
---
|
||
|
||
## Quick Start: Parallel Ingestion
|
||
|
||
```python
|
||
from semantica.vector_store import VectorStore
|
||
import time
|
||
|
||
store = VectorStore(backend="faiss", dimension=768)
|
||
|
||
documents = [f"This is document number {i} with some content." for i in range(1000)]
|
||
metadata = [{"source": "generated", "id": i} for i in range(1000)]
|
||
|
||
start = time.time()
|
||
ids = store.add_documents(
|
||
documents=documents,
|
||
metadata=metadata,
|
||
batch_size=64,
|
||
parallel=True, # default: True
|
||
)
|
||
print(f"Ingested {len(ids)} documents in {time.time() - start:.2f}s")
|
||
```
|
||
|
||
---
|
||
|
||
## Performance Comparison
|
||
|
||
**Old method (sequential loop)** — slower due to per-item overhead:
|
||
|
||
```python
|
||
for doc in documents:
|
||
emb = embedder.generate(doc)
|
||
store.store_vectors([emb], [{"text": doc}])
|
||
```
|
||
|
||
**New method (parallel batching)** — 3–10× faster:
|
||
|
||
```python
|
||
store.add_documents(documents, parallel=True)
|
||
```
|
||
|
||
---
|
||
|
||
## Configuration and Tuning
|
||
|
||
### `max_workers`
|
||
|
||
Number of concurrent threads for embedding generation.
|
||
|
||
- **Default**: 6 (optimized for most systems)
|
||
- Override only if you have very high core counts or specific throughput needs
|
||
|
||
```python
|
||
store = VectorStore(max_workers=16)
|
||
```
|
||
|
||
### `batch_size`
|
||
|
||
Number of documents processed in a single chunk.
|
||
|
||
- **Default**: 32
|
||
- **Local models**: 32–64 works well
|
||
- **API models (OpenAI, etc.)**: 100–200 reduces network latency overhead
|
||
|
||
```python
|
||
store.add_documents(documents, batch_size=100)
|
||
```
|
||
|
||
---
|
||
|
||
## Manual Batch Embedding
|
||
|
||
If you need embeddings without immediately storing them:
|
||
|
||
```python
|
||
vectors = store.embed_batch(texts=documents[:100])
|
||
print(f"Generated {len(vectors)} vectors")
|
||
```
|
||
|
||
---
|
||
|
||
## Best Practices
|
||
|
||
<Tip>
|
||
- **Metadata consistency** — ensure your `metadata` list is the same length as `documents`.
|
||
- **Error handling** — `add_documents` propagates exceptions if embedding fails; validate your data first.
|
||
- **Memory usage** — very large `batch_size` combined with high `max_workers` increases RAM usage. Monitor system resources for large corpora.
|
||
</Tip>
|
||
|
||
---
|
||
|
||
## See Also
|
||
|
||
<CardGroup cols={2}>
|
||
<Card title="Vector Store Reference" icon="vector-square" href="reference/vector_store">
|
||
Full VectorStore API with all backends.
|
||
</Card>
|
||
<Card title="Embeddings" icon="brain" href="reference/embeddings">
|
||
Embedding providers and GPU acceleration.
|
||
</Card>
|
||
</CardGroup>
|