Spaces:
Sleeping
Sleeping
Download Src/vectorstore/test.py from kanhacoderx/Documind-AI: direct link, hf CLI and curl.
- Browser
- Download file 664 Bytes
-
https://huggingface.co/spaces/kanhacoderx/Documind-AI/resolve/main/Src/vectorstore/test.py
- Command line
-
hf download hf://spaces/kanhacoderx/Documind-AI/Src/vectorstore/test.py
-
curl -L -o test.py https://huggingface.co/spaces/kanhacoderx/Documind-AI/resolve/main/Src/vectorstore/test.py
664 Bytes
| from Src.ingestion.data_loader import DataIngestion | |
| from Src.embeddings.embedder import Embedder | |
| from Src.vectorstore.faiss_store import FAISSStore | |
| # Step 1: Load and chunk documents | |
| ingestion = DataIngestion("") | |
| chunks = ingestion.ingest() | |
| # Step 2: Load embedding model | |
| embedder = Embedder() | |
| # Step 3: Create vector store | |
| faiss_store = FAISSStore(embedder.embedding_model) | |
| faiss_store.create_vector_store(chunks) | |
| # Step 4: Search | |
| results = faiss_store.similarity_search("What is the main topic of the document?", k=2) | |
| for i, doc in enumerate(results, 1): | |
| print(f"\nResult {i}:") | |
| print(doc.page_content[:500]) | |
| print("-" * 50) |