๐ป ์์คํ ์ค์น ๋ฐ ์คํ ์๊ตฌ์ฌ์ (System Requirements)
์ต์ Weaviate Database v1.40.x ๋ฐ ๊ณต์ Python v4 ํด๋ผ์ด์ธํธ weaviate-client v4.25.0 ๊ธฐ์ค ์๊ตฌ์ฌ์์
๋๋ค.
| ๊ตฌ๋ถ | ์ต์ ์ฌ์ (Minimum) | ๊ถ์ฅ ์ฌ์ (Recommended) |
|---|---|---|
| ์ด์์ฒด์ (OS) | Linux, macOS, Windows (WSL2 / Docker Desktop) | Ubuntu 24.04 LTS (x86_64 AVX2+ ๋๋ ARM64) |
| CPU | 2 vCPU | 4 ~ 16+ vCPU (HNSW ๊ทธ๋ํ ๋น๋ ๋ฐ BM25 ์ญ์์ธ ๋ณ๋ ฌ ์ฒ๋ฆฌ) |
| ๋ฉ๋ชจ๋ฆฌ (RAM) | 2 GB (์๊ท๋ชจ ๊ฐ๋ฐ/ํ ์คํธ) | 8 GB ~ 64 GB+ (HNSW + PQ/BQ ์์ํ ์ ์ฉ ์ ๋ํญ ์ ๊ฐ) |
| ๋์คํฌ (Storage) | 5 GB ์ฌ์ ๊ณต๊ฐ | NVMe SSD (Dynamic/Disk ์ธ๋ฑ์ค ๋ฐ LSM ์คํ ๋ฆฌ์ง์ฉ) |
| ๋ฐํ์ / ํด๋ผ์ด์ธํธ | Python 3.11+ (weaviate-client>=4.25.0) | Python 3.12+ + Docker Compose v2 (REST :8080 / gRPC :50051) |
์ต์ ๋ฒ์ ์ค์น ๋ฐ ์คํ
# 1. Weaviate ์ต์ Docker ์ปจํ
์ด๋ ์คํ (์ต๋ช
๋ก์ปฌ ๊ฐ๋ฐ ๋ชจ๋)
docker run -d --name weaviate \
-p 8080:8080 -p 50051:50051 \
-e AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true \
-e PERSISTENCE_DATA_PATH=/var/lib/weaviate \
-v "$(pwd)/weaviate_data:/var/lib/weaviate" \
cr.weaviate.io/semitechnologies/weaviate:1.40.0
# 2. ํฌ์ค์ฒดํฌ
curl -s http://localhost:8080/v1/.well-known/ready
# 3. Python 3.11+ ๊ฐ์ํ๊ฒฝ ๋ฐ v4 ํด๋ผ์ด์ธํธ ์ค์น
python -m venv .venv
source .venv/bin/activate # Windows PowerShell: .venv\Scripts\Activate.ps1
pip install -U "weaviate-client[agents]"
๐ง Weaviate ๋ฉํ ๋ชจ๋ธ (Collection ยท HNSW ยท Inverted Index ยท Module)
Weaviate๋ ๋ฒกํฐ ์ธ๋ฑ์ค(HNSW/Flat/Dynamic) ์ BM25 ์ญ์์ธ(Inverted Index), ๊ทธ๋ฆฌ๊ณ ์๋ฒ ๋ฉ/์์ฑํ(RAG) ๋ชจ๋์ด ๋จ์ผ ์์ง ์์ ํตํฉ๋ AI ๋ค์ดํฐ๋ธ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋๋ค.
[Python Client v4 (gRPC :50051 + REST :8080)]
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Collection ("TechDocs") โ
โ โโ Properties (title: TEXT, category: TEXT, year: INT)โ
โ โโ Vector Index (HNSW + PQ/SQ/BQ ์์ํ) โ
โ โโ Inverted Index (BM25F ํค์๋ + ๋ฉํ๋ฐ์ดํฐ ํํฐ) โ
โ โโ Generative / Reranker Module (OpenAI, Ollama ๋ฑ) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ ๋จ๊ณ๋ณ ์ค์ ์ค์ต (Step-by-Step)
[1๋จ๊ณ] ํฌ๋ก์๋: v4 ํด๋ผ์ด์ธํธ ์ฐ๊ฒฐ, ์ปฌ๋ ์ ์์ฑ ๋ฐ ๋ฐ์ดํฐ ์ฝ์
weaviate-client v4๋ถํฐ๋ gRPC ๊ธฐ๋ฐ์ ํ์
์์ ํ collections API๋ฅผ ์ฌ์ฉํ๋ฉฐ, with ์ปจํ
์คํธ ๋งค๋์ ๋ก ์ฐ๊ฒฐ์ ์๋ ์ ๋ฆฌํฉ๋๋ค.
import weaviate
from weaviate.classes.config import Configure, Property, DataType
with weaviate.connect_to_local() as client:
# 1. ๊ธฐ์กด ์ปฌ๋ ์
์ด๊ธฐํ ํ ์์ฑ (์ธ๋ถ์์ ๋ฒกํฐ๋ฅผ ์ง์ ๋ฃ๊ฑฐ๋ vectorizer ์ง์ ๊ฐ๋ฅ)
if client.collections.exists("Article"):
client.collections.delete("Article")
articles = client.collections.create(
name="Article",
properties=[
Property(name="title", data_type=DataType.TEXT),
Property(name="body", data_type=DataType.TEXT),
Property(name="category", data_type=DataType.TEXT),
Property(name="year", data_type=DataType.INT),
],
# ๋ก์ปฌ ํ
์คํธ์ฉ BYOV(Bring Your Own Vectors) ๋๋ text2vec-ollama ๋ฑ ์ ํ
vector_config=Configure.Vectors.self_provided(),
)
# 2. ๋ฐ์ดํฐ ์ฝ์
(๋ฐฐ์น ๋๋ ๋จ๊ฑด)
articles.data.insert(
properties={"title": "Weaviate ํ์ด๋ธ๋ฆฌ๋ ๊ฒ์", "body": "BM25์ HNSW ๊ฒฐํฉ", "category": "ai", "year": 2026},
vector=[0.90, 0.12, 0.04, 0.01],
)
articles.data.insert(
properties={"title": "Kubernetes RBAC ๊ฐ์ด๋", "body": "์ต์ ๊ถํ ์์น", "category": "infra", "year": 2025},
vector=[0.10, 0.85, 0.15, 0.02],
)
print("์ปฌ๋ ์
์ ์ฅ ๊ฐ์ฒด ์:", len(articles))
์คํ ์์ ์ถ๋ ฅ:
์ปฌ๋ ์
์ ์ฅ ๊ฐ์ฒด ์: 2
[2๋จ๊ณ] ํต์ฌ ๊ธฐ๋ฅ: hybrid() ๊ฒ์ + Filter ์กฐ๊ฑด ํํฐ๋ง
Weaviate์ ๊ฐ์ ์ BM25 ํค์๋ ์ ์์ ๋ฒกํฐ ์ ์ฌ๋๋ฅผ alpha ๊ฐ์ค์น(0.0~1.0)๋ก ํ ๋ฒ์ ๊ฒฐํฉํ๋ query.hybrid()์
๋๋ค.
import weaviate
from weaviate.classes.query import Filter, HybridFusion, MetadataQuery
with weaviate.connect_to_local() as client:
articles = client.collections.use("Article")
# alpha=0.7 -> ๋ฒกํฐ 70% + BM25 ํค์๋ 30% ๋น์ค, Ranked Fusion ์ ์ฉ
response = articles.query.hybrid(
query="Weaviate BM25 ๊ฒ์",
vector=[0.88, 0.15, 0.05, 0.02],
alpha=0.7,
fusion_type=HybridFusion.RELATIVE_SCORE,
filters=Filter.by_property("year").greater_or_equal(2026),
limit=3,
return_metadata=MetadataQuery(score=True, explain_score=True),
)
for obj in response.objects:
print(f"score={obj.metadata.score:.4f} | {obj.properties['title']}")
[3๋จ๊ณ] ์ค๋ฌด ์์ฉ: ๋์ฉ๋ ๋์ ๋ฐฐ์น ์ ์ฌ & ๋ฉํฐํ ๋ํธ ๊ฒฉ๋ฆฌ
์์ญ๋ง ๊ฑด ์ด์์ ๋ฌธ์๋ฅผ ๋น ๋ฅด๊ฒ ์ ์ฌํ ๋๋ batch.dynamic()์ ์ฌ์ฉํ๊ณ , B2B SaaS ํ๊ฒฝ์์๋ Configure.multi_tenancy(enabled=True)๋ก ํ
๋ํธ๋ณ ์ค๋๋ฅผ ๋ฌผ๋ฆฌ์ ์ผ๋ก ๊ฒฉ๋ฆฌํฉ๋๋ค.
import weaviate
from weaviate.classes.config import Configure, Property, DataType
from weaviate.classes.tenants import Tenant
with weaviate.connect_to_local() as client:
if not client.collections.exists("TenantDocs"):
client.collections.create(
name="TenantDocs",
multi_tenancy_config=Configure.multi_tenancy(enabled=True),
properties=[Property(name="content", data_type=DataType.TEXT)],
vector_config=Configure.Vectors.self_provided(),
)
coll = client.collections.use("TenantDocs")
coll.tenants.create([Tenant(name="acme_corp"), Tenant(name="beta_inc")])
# ํน์ ํ
๋ํธ ์ปจํ
์คํธ๋ก ์ ํ ํ ๊ณ ์ ๋์ ๋ฐฐ์น ์ฝ์
acme_coll = coll.with_tenant("acme_corp")
with acme_coll.batch.dynamic() as batch:
for i in range(100):
batch.add_object(
properties={"content": f"ACME ์ฌ๋ด ๋ฌธ์ #{i}"},
vector=[0.1, 0.2, 0.3, 0.4],
)
if acme_coll.batch.failed_objects:
print("์คํจ ๊ฑด์:", len(acme_coll.batch.failed_objects))
else:
print("ACME ํ
๋ํธ 100๊ฑด ๋ฐฐ์น ์ ์ฌ ์๋ฃ")
๐ ๏ธ ์ฃผ์ v4 API & ์ค์ ์นํธ์ํธ
| ๊ธฐ๋ฅ | Python v4 ๋ฉ์๋ / ์ค์ | ์ค๋ช |
|---|---|---|
| ํ์ด๋ธ๋ฆฌ๋ ๊ฒ์ | coll.query.hybrid(query=..., alpha=0.5) | alpha=1(์์ ๋ฒกํฐ) ~ alpha=0(์์ BM25) ์กฐ์ |
| ์์ฑํ RAG | coll.generate.near_text(query=..., grouped_task=...) | ๊ฒ์๋ ์์ ๋ฌธ์๋ฅผ LLM์ ์ฆ์ ์ ๋ฌํด ์์ฝ/๋ต๋ณ ์์ฑ |
| ๋ฒกํฐ ์์ํ | Configure.VectorIndex.hnsw(quantizer=Configure.VectorIndex.Quantizer.bq()) | Binary/Product/Scalar ์์ํ๋ก RAM 4~32๋ฐฐ ์ ๊ฐ |
| ์ปค์ ํ์ด์ง๋ค์ด์ | coll.iterator(return_properties=[...]) | ์ ์ฒด ๊ฐ์ฒด ๋๋ ์ํ ์ ๋ฉ๋ชจ๋ฆฌ ์์ ์ดํฐ๋ ์ดํฐ ์ ๊ณต |
โ ์ค๋ฌด ์ฃผ์์ฌํญ & ํ๋ก๋์ ์ฒดํฌ๋ฆฌ์คํธ
- v3 vs v4 API ํผ์ฉ ๊ธ์ง: ๊ตฌ๋ฒ์
weaviate.Client(...)(REST ๊ธฐ๋ฐ v3)์ deprecated ๋์์ผ๋ฉฐ ์ฑ๋ฅ์ด ํฌ๊ฒ ๋จ์ด์ง๋๋ค. ๋ฐ๋์ gRPC ํฌํธ(50051)๊ฐ ์ด๋ฆฐ ์ํ์์weaviate.connect_to_local()/connect_to_custom()(v4)์ ์ฌ์ฉํ์ธ์. - ๋ฐฐ์น ์๋ฌ ๋ฐ๋์ ๊ฒ์ฆ:
batch.dynamic()์ ์์ธ๋ฅผ ์ฆ์ ๋์ง์ง ์๊ณ ๋ด๋ถ ํ์ ๋ชจ์ผ๋ฏ๋ก, ์ปจํ ์คํธ ๋ธ๋ก ์ข ๋ฃ ์งํcoll.batch.failed_objects๊ธธ์ด๋ฅผ ํ์ธํ๋ ๊ฒ์ด ํ์์ ๋๋ค. - ๊ณ ์ ํํฐ๋ง์ฉ Index ์ค์ : ํํฐ๋ง์ ์ฐ์ง ์๋ ๋์ฉ๋ ๋ณธ๋ฌธ ํ๋๋
skip_vectorization=True๋๋index_filterable=False๋ก ์ค์ ํ๋ฉด ๋์คํฌยท๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ ํฌ๊ฒ ์ค์ผ ์ ์์ต๋๋ค.
์๊ฒฌ ๋ฐ ์ง๋ฌธ
0์์ง ๋ฑ๋ก๋ ์๊ฒฌ์ด ์์ต๋๋ค. ์ฒซ ๋ฒ์งธ ๋๊ธ์ ๋จ๊ฒจ๋ณด์ธ์!
๋๊ธ ์์
๋๊ธ ์ญ์