Spaces:
Sleeping
Sleeping
File size: 536 Bytes
8521f60 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
"""Abstract retriever interface."""
from __future__ import annotations
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List
@dataclass
class Context:
"""A retrieved passage or document."""
id: str
text: str
score: float
class Retriever(ABC):
"""Abstract base class for all retrievers."""
@abstractmethod
def retrieve(self, query: str, *, top_k: int = 5) -> List[Context]:
"""Return the top‑k contexts for a query."""
raise NotImplementedError
|