dmpantiu commited on
Commit
b1437d9
·
verified ·
1 Parent(s): 546b9c6

README: Qdrant quickstart — prebuilt embedded indexes + server load recipe

Browse files
Files changed (1) hide show
  1. README.md +84 -0
README.md CHANGED
@@ -43,6 +43,90 @@ scripts/ FULL pipeline, per component (see below)
43
  REBUILD.md full from-scratch rebuild / open-LLM swap guide
44
  ```
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  ## Rebuild scripts (`scripts/`)
47
 
48
  Everything needed to regenerate this dataset from the originals — or re-embed
 
43
  REBUILD.md full from-scratch rebuild / open-LLM swap guide
44
  ```
45
 
46
+ ## Quickstart — plug the RAG database into Qdrant
47
+
48
+ Two ways, depending on where you want Qdrant to run.
49
+
50
+ ### A) Prebuilt embedded indexes (fastest — no re-compute, no server)
51
+
52
+ The `indexes/*.tar.gz` are ready-to-serve **embedded-Qdrant** storage dirs
53
+ (this is exactly what the MCP server uses). Each tarball unpacks to a `qdrant_db/`:
54
+
55
+ ```bash
56
+ pip install "qdrant-client==1.18.0"
57
+ hf download dmpantiu/copernicus-rag-core --repo-type dataset \
58
+ --include "indexes/*" --local-dir .
59
+ for n in marine_and_cards cds_docs eqc_qa publications; do
60
+ mkdir -p rag/$n && tar xzf indexes/qdrant_$n.tar.gz -C rag/$n
61
+ done
62
+ ```
63
+
64
+ | dir (after untar) | collections inside | points |
65
+ |---|---|---|
66
+ | `rag/marine_and_cards/qdrant_db` | `marine_docs` + `copernicus_docs` | 29,249 + 1,418 |
67
+ | `rag/cds_docs/qdrant_db` | `cds_docs` | 23,341 |
68
+ | `rag/eqc_qa/qdrant_db` | `eqc_qa` | 1,274 |
69
+ | `rag/publications/qdrant_db` | `publications` | 430,066 |
70
+
71
+ ```python
72
+ from qdrant_client import QdrantClient
73
+ c = QdrantClient(path="rag/publications/qdrant_db") # embedded/local mode
74
+ print(c.get_collections()) # -> publications
75
+ print(c.count("publications")) # -> 430066
76
+ ```
77
+
78
+ Notes:
79
+ - Vectors are **named**: `dense` (768-d, cosine, `gemini-embedding-2-preview`,
80
+ L2-normalized) + `sparse` (BM25, IDF modifier) → hybrid dense+sparse queries work
81
+ out of the box. BM25 queries need no embedding model at all
82
+ (`fastembed` `Qdrant/bm25`); dense queries need the same Gemini model
83
+ (or re-embed — see `REBUILD.md`).
84
+ - Embedded mode holds a **single-process lock** per dir — one process at a time.
85
+ - These dirs are **local-mode storage only**; you cannot mount them into a
86
+ Qdrant docker server. For a server, use option B.
87
+ - The MCP server (`scripts/marine_rag/rag_server.py`) expects them at
88
+ `marine_rag/out/qdrant_db`, `deep_docs/qdrant_db`, `eqc_qa/qdrant_db`,
89
+ `pubs_rag/qdrant_db` relative to the repo root.
90
+
91
+ ### B) Into a running Qdrant server (docker / cloud)
92
+
93
+ Load from `embeddings/*.embedded.jsonl.gz` (text + payload + ready 768-d vectors):
94
+
95
+ ```bash
96
+ docker run -d -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant
97
+ hf download dmpantiu/copernicus-rag-core --repo-type dataset \
98
+ --include "embeddings/*" --local-dir .
99
+ ```
100
+
101
+ ```python
102
+ import gzip, json, uuid
103
+ from qdrant_client import QdrantClient, models
104
+
105
+ c = QdrantClient(url="http://localhost:6333")
106
+ c.create_collection("publications",
107
+ vectors_config={"dense": models.VectorParams(size=768, distance=models.Distance.COSINE)},
108
+ sparse_vectors_config={"sparse": models.SparseVectorParams(modifier=models.Modifier.IDF)})
109
+
110
+ buf = []
111
+ for line in gzip.open("embeddings/publications.embedded.jsonl.gz", "rt"):
112
+ d = json.loads(line)
113
+ emb = d.pop("embedding")
114
+ buf.append(models.PointStruct(
115
+ id=str(uuid.uuid5(uuid.NAMESPACE_DNS, d["chunk_id"])),
116
+ vector={"dense": emb}, payload=d))
117
+ if len(buf) >= 512:
118
+ c.upsert("publications", points=buf); buf = []
119
+ if buf:
120
+ c.upsert("publications", points=buf)
121
+ ```
122
+
123
+ Same recipe for the other four files (`marine_docs`, `cds_docs`, `eqc_qa`,
124
+ `cards_cds` → collection `copernicus_docs`). To also fill the BM25 `sparse`
125
+ vectors (recommended for hybrid), use the full loaders in `scripts/`
126
+ (`pubs_rag/load_pubs_qdrant.py`, `marine_rag/load_qdrant.py`, …) — they build
127
+ dense+sparse and all payload indexes; switching them from embedded to server
128
+ mode is a one-line change: `QdrantClient(path=...)` → `QdrantClient(url=...)`.
129
+
130
  ## Rebuild scripts (`scripts/`)
131
 
132
  Everything needed to regenerate this dataset from the originals — or re-embed