Revert to v1.0-working (score 0.5094) — Lotus params don't generalize to our data

This commit is contained in:
q 2026-04-18 20:59:45 +03:00
parent 2bb595e452
commit f6d66854b9
2 changed files with 12 additions and 21 deletions

View file

@ -1,7 +1,6 @@
import asyncio
import logging
import os
from contextlib import asynccontextmanager
from functools import lru_cache
from typing import Any
@ -74,7 +73,7 @@ class SparseVector(BaseModel):
values: list[float]
CHUNK_SIZE = 384
CHUNK_SIZE = 256
OVERLAP_SIZE = 128
SPARSE_MODEL_NAME = "Qdrant/bm25"
FASTEMBED_CACHE_PATH = "/models/fastembed"
@ -102,9 +101,6 @@ def render_message(message: Message) -> str:
else:
parts_list.append(part_text)
if message.mentions:
parts_list.append(" ".join(message.mentions))
if message.file_snippets:
parts_list.append(f"[Файл]: {message.file_snippets}")
@ -190,13 +186,7 @@ def build_chunks(
return result
@asynccontextmanager
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 = FastAPI(title="Index Service", version="0.1.0")
@app.get("/health")

View file

@ -148,10 +148,11 @@ def get_sparse_model() -> SparseTextEmbedding:
@asynccontextmanager
async def lifespan(app: FastAPI):
await asyncio.to_thread(get_sparse_model)
limits = httpx.Limits(max_connections=100, max_keepalive_connections=20)
app.state.http = httpx.AsyncClient(timeout=30.0, limits=limits)
app.state.qdrant = AsyncQdrantClient(url=QDRANT_URL, api_key=API_KEY)
app.state.http = httpx.AsyncClient()
app.state.qdrant = AsyncQdrantClient(
url=QDRANT_URL,
api_key=API_KEY,
)
try:
yield
finally:
@ -161,10 +162,10 @@ async def lifespan(app: FastAPI):
app = FastAPI(title="Search Service", version="0.1.0", lifespan=lifespan)
DENSE_PREFETCH_K = 50
SPARSE_PREFETCH_K = 150
RETRIEVE_K = 100
RERANK_LIMIT = 15
DENSE_PREFETCH_K = 80
SPARSE_PREFETCH_K = 200
RETRIEVE_K = 150
RERANK_LIMIT = 10
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)
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_vectors = [dense_vector]