Download efficient_context/retrieval/base.py from biswanathroul/efficient-context: direct link, hf CLI and curl.
- Browser
- Download file 960 Bytes
-
https://huggingface.co/biswanathroul/efficient-context/resolve/main/efficient_context/retrieval/base.py
- Command line
-
hf download hf://biswanathroul/efficient-context/efficient_context/retrieval/base.py
-
curl -L -o base.py https://huggingface.co/biswanathroul/efficient-context/resolve/main/efficient_context/retrieval/base.py
960 Bytes
| """ | |
| Base classes for retrieval components. | |
| """ | |
| from abc import ABC, abstractmethod | |
| from typing import List, Optional | |
| from efficient_context.chunking.base import Chunk | |
| class BaseRetriever(ABC): | |
| """Base class for content retrieval components.""" | |
| def index_chunks(self, chunks: List[Chunk]) -> None: | |
| """ | |
| Index chunks for future retrieval. | |
| Args: | |
| chunks: Chunks to index | |
| """ | |
| pass | |
| def retrieve(self, query: str, top_k: Optional[int] = None) -> List[Chunk]: | |
| """ | |
| Retrieve chunks relevant to a query. | |
| Args: | |
| query: Query to retrieve chunks for | |
| top_k: Number of chunks to retrieve | |
| Returns: | |
| chunks: List of retrieved chunks | |
| """ | |
| pass | |
| def clear(self) -> None: | |
| """Clear all indexed chunks.""" | |
| pass | |