Retrievers¶
Base Retriever.
BaseRetriever
¶
Bases: BaseModel
, ABC
Base Retriever Class.
This abstract class provides the interface for creating Retriever objects that encode strings into numerical vector representations.
Source code in src/fed_rag/base/retriever.py
encoder
abstractmethod
property
¶
PyTorch model associated with the encoder associated with retriever.
query_encoder
abstractmethod
property
¶
PyTorch model associated with the query encoder associated with retriever.
context_encoder
abstractmethod
property
¶
PyTorch model associated with the context encoder associated with retriever.
encode_query
abstractmethod
¶
Encode a string query into a torch.Tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str | list[str]
|
The query or list of queries to encode. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: The vector representation(s) of the encoded query/queries. |
Source code in src/fed_rag/base/retriever.py
encode_context
abstractmethod
¶
Encode a string context into a torch.Tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
str | list[str]
|
The context or list of contexts to encode. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: The vector representation(s) of the encoded context(s). |