Revert to v1.0-working (score 0.5094) — Lotus params don't generalize to our data
This commit is contained in:
parent
2bb595e452
commit
f6d66854b9
2 changed files with 12 additions and 21 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from contextlib import asynccontextmanager
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
@ -74,7 +73,7 @@ class SparseVector(BaseModel):
|
||||||
values: list[float]
|
values: list[float]
|
||||||
|
|
||||||
|
|
||||||
CHUNK_SIZE = 384
|
CHUNK_SIZE = 256
|
||||||
OVERLAP_SIZE = 128
|
OVERLAP_SIZE = 128
|
||||||
SPARSE_MODEL_NAME = "Qdrant/bm25"
|
SPARSE_MODEL_NAME = "Qdrant/bm25"
|
||||||
FASTEMBED_CACHE_PATH = "/models/fastembed"
|
FASTEMBED_CACHE_PATH = "/models/fastembed"
|
||||||
|
|
@ -102,9 +101,6 @@ def render_message(message: Message) -> str:
|
||||||
else:
|
else:
|
||||||
parts_list.append(part_text)
|
parts_list.append(part_text)
|
||||||
|
|
||||||
if message.mentions:
|
|
||||||
parts_list.append(" ".join(message.mentions))
|
|
||||||
|
|
||||||
if message.file_snippets:
|
if message.file_snippets:
|
||||||
parts_list.append(f"[Файл]: {message.file_snippets}")
|
parts_list.append(f"[Файл]: {message.file_snippets}")
|
||||||
|
|
||||||
|
|
@ -190,13 +186,7 @@ def build_chunks(
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
app = FastAPI(title="Index Service", version="0.1.0")
|
||||||
async def lifespan(app: FastAPI):
|
|
||||||
await asyncio.to_thread(get_sparse_model)
|
|
||||||
yield
|
|
||||||
|
|
||||||
|
|
||||||
app = FastAPI(title="Index Service", version="0.1.0", lifespan=lifespan)
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/health")
|
@app.get("/health")
|
||||||
|
|
|
||||||
|
|
@ -148,10 +148,11 @@ def get_sparse_model() -> SparseTextEmbedding:
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
await asyncio.to_thread(get_sparse_model)
|
app.state.http = httpx.AsyncClient()
|
||||||
limits = httpx.Limits(max_connections=100, max_keepalive_connections=20)
|
app.state.qdrant = AsyncQdrantClient(
|
||||||
app.state.http = httpx.AsyncClient(timeout=30.0, limits=limits)
|
url=QDRANT_URL,
|
||||||
app.state.qdrant = AsyncQdrantClient(url=QDRANT_URL, api_key=API_KEY)
|
api_key=API_KEY,
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
finally:
|
finally:
|
||||||
|
|
@ -161,10 +162,10 @@ async def lifespan(app: FastAPI):
|
||||||
|
|
||||||
app = FastAPI(title="Search Service", version="0.1.0", lifespan=lifespan)
|
app = FastAPI(title="Search Service", version="0.1.0", lifespan=lifespan)
|
||||||
|
|
||||||
DENSE_PREFETCH_K = 50
|
DENSE_PREFETCH_K = 80
|
||||||
SPARSE_PREFETCH_K = 150
|
SPARSE_PREFETCH_K = 200
|
||||||
RETRIEVE_K = 100
|
RETRIEVE_K = 150
|
||||||
RERANK_LIMIT = 15
|
RERANK_LIMIT = 10
|
||||||
|
|
||||||
|
|
||||||
async def embed_dense(client: httpx.AsyncClient, text: str) -> list[float]:
|
async def embed_dense(client: httpx.AsyncClient, text: str) -> list[float]:
|
||||||
|
|
@ -353,7 +354,7 @@ async def search(payload: SearchAPIRequest) -> SearchAPIResponse:
|
||||||
sparse_query = build_sparse_query(question)
|
sparse_query = build_sparse_query(question)
|
||||||
|
|
||||||
dense_task = embed_dense(client, dense_query)
|
dense_task = embed_dense(client, dense_query)
|
||||||
sparse_task = asyncio.to_thread(embed_sparse_sync, sparse_query)
|
sparse_task = asyncio.to_thread(lambda: embed_sparse_sync(sparse_query))
|
||||||
dense_vector, sparse_vector = await asyncio.gather(dense_task, sparse_task)
|
dense_vector, sparse_vector = await asyncio.gather(dense_task, sparse_task)
|
||||||
|
|
||||||
dense_vectors = [dense_vector]
|
dense_vectors = [dense_vector]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue