-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_from_vdb.py
More file actions
31 lines (24 loc) · 983 Bytes
/
Copy pathread_from_vdb.py
File metadata and controls
31 lines (24 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import chromadb
from sentence_transformers import SentenceTransformer
# 1. Połącz z Chroma
client = chromadb.PersistentClient(path="chroma_store")
# 2. Wypisz kolekcje
print("Dostępne kolekcje:")
for col in client.list_collections():
print("📂", col.name)
# 3. Pobierz kolekcję (zmień nazwę jeśli inna!)
collection = client.get_collection(name="beir-msmarco-corpus")
# 4. Załaduj model (ten sam co przy zapisie!)
model = SentenceTransformer("all-MiniLM-L6-v2")
# 5. Zakoduj zapytanie
query_text = "What are the symptoms of Mycoplasma pneumoniae?"
query_embedding = model.encode(query_text).tolist()
# 6. Przeszukaj bazę
results = collection.query(query_embeddings=[query_embedding], n_results=5)
# 7. Wyświetl wyniki
for doc_id, doc_text, metadata in zip(
results["ids"][0], results["documents"][0], results["metadatas"][0]
):
print(f"\n🔎 ID: {doc_id}")
print(f"📘 Title: {metadata.get('title')}")
print(f"📝 Text: {doc_text[:300]}...")