mirror of
https://gitverse.ru/kpa39l/infrastructure.git
synced 2026-09-29 10:05:03 +00:00
OpenSpec: разнести openspec по проектам
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
## Vector Database Setup Guide
|
||||
|
||||
### 1. Faiss (Similarity Search)
|
||||
Install: pip install faiss-cpu
|
||||
|
||||
```python
|
||||
import faiss
|
||||
import numpy as np
|
||||
|
||||
# Create index
|
||||
index = faiss.IndexFlatL2(128)
|
||||
|
||||
# Add vectors
|
||||
vectors = np.random.rand(100, 128).astype('float32')
|
||||
index.add(vectors)
|
||||
```
|
||||
|
||||
### 2. Weaviate
|
||||
Install: docker run -d -p 8000:8000 weaviate/weaviate
|
||||
|
||||
Connect with:
|
||||
```python
|
||||
from weaviate import Weaviate
|
||||
client = Weaviate.connect("http://localhost:8000")
|
||||
client.create_class("Vectors")
|
||||
```
|
||||
|
||||
### 3. Milvus
|
||||
Install: pip install pymilvus
|
||||
|
||||
Start server: milvus-standalone-server
|
||||
|
||||
Connect:
|
||||
```python
|
||||
from pymilvus import connections, Collection
|
||||
connections.connect("default", host="localhost", port="19530")
|
||||
coll = Collection("vector_collection")
|
||||
coll.insert([vectors])
|
||||
```
|
||||
|
||||
### 4. Neo4j (Graph Storage)
|
||||
Install: pip install neo4j
|
||||
|
||||
Connect:
|
||||
```python
|
||||
from neo4j import GraphDatabase
|
||||
driver = GraphDatabase.driver("neo4j://localhost:7687", auth=basic_auth("neo4j", "password"))
|
||||
with driver.session() as session:
|
||||
session.write_transaction(
|
||||
lambda tx: tx.run("CREATE (a:Vector {vector: $vector})", vector=vectors)
|
||||
)
|
||||
```
|
||||
|
||||
Each system has unique features - choose based on your needs: Faiss for similarity search, Weaviate for semantic vectors, Milvus for large-scale storage, or Neo4j for graph-based relationships.
|
||||
Reference in New Issue
Block a user