indexers.dataclasses
indexers.dataclasses
Dataclasses for structuring and validating VectorStore input and output data.
This module defines DataFrame-like objects that validate input and output data for VectorStore search, reverse_search, and embedding operations in the ClassifAI framework. Each class wraps a pandas DataFrame and enforces a schema using pandera.
Typical usage example:
search_input = VectorStoreSearchInput({"id": ["1"], "query": ["hello"]})
embed_input = VectorStoreEmbedInput.from_data({"id": ["1"], "text": ["hello"]})
Classes
| Name | Description |
|---|---|
| VectorStoreEmbedInput | DataFrame-like object for forming and validating text data to be embedded. |
| VectorStoreEmbedOutput | DataFrame-like object for storing and validating embedded vectors. |
| VectorStoreReverseSearchInput | DataFrame-like object for forming and validating reverse search query input data. |
| VectorStoreReverseSearchOutput | DataFrame-like object for storing reverse search results. |
| VectorStoreSearchInput | DataFrame-like object for forming and validating search query input data. |
| VectorStoreSearchOutput | DataFrame-like object for storing and validating search results. |
VectorStoreEmbedInput
indexers.dataclasses.VectorStoreEmbedInput(data)DataFrame-like object for forming and validating text data to be embedded.
This class validates and represents input texts that will be converted to vector embeddings by the vector store.
Attributes
| Name | Type | Description |
|---|---|---|
| id | pd.Series | Unique identifier for each text item. |
| text | pd.Series | The text content to be embedded. |
Methods
| Name | Description |
|---|---|
| from_data | Create a validated VectorStoreEmbedInput from a dictionary or DataFrame. |
| validate | Validate an existing DataFrame and return a VectorStoreEmbedInput. |
from_data
indexers.dataclasses.VectorStoreEmbedInput.from_data(data)Create a validated VectorStoreEmbedInput from a dictionary or DataFrame.
Creates a new instance of VectorStoreEmbedInput by validating the input data against the defined schema.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | dict | pd.DataFrame | A dictionary or pandas DataFrame containing the input data. Must include ‘id’ and ‘text’ columns/keys. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreEmbedInput | VectorStoreEmbedInput | A validated instance of the class. |
validate
indexers.dataclasses.VectorStoreEmbedInput.validate(df)Validate an existing DataFrame and return a VectorStoreEmbedInput.
Validates the provided pandas DataFrame against the defined schema and returns a new instance of VectorStoreEmbedInput if validation is successful.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | A pandas DataFrame to validate. Must include ‘id’ and ‘text’ columns. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreEmbedInput | VectorStoreEmbedInput | A validated instance of the class. |
VectorStoreEmbedOutput
indexers.dataclasses.VectorStoreEmbedOutput(data)DataFrame-like object for storing and validating embedded vectors.
This class represents the output of embedding operations, containing the original text data, computed vector embeddings, and associated metadata.
Attributes
| Name | Type | Description |
|---|---|---|
| id | pd.Series | Unique identifier for each embedded item. |
| text | pd.Series | The original text that was embedded. |
| embedding | pd.Series | The computed vector embedding (numpy array). |
Methods
| Name | Description |
|---|---|
| from_data | Create a validated VectorStoreEmbedOutput from a dictionary or DataFrame. |
| validate | Validate an existing DataFrame and return a VectorStoreEmbedOutput. |
from_data
indexers.dataclasses.VectorStoreEmbedOutput.from_data(data)Create a validated VectorStoreEmbedOutput from a dictionary or DataFrame.
Creates a new instance of VectorStoreEmbedOutput by validating the input data against the defined schema.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | dict | pd.DataFrame | A dictionary or pandas DataFrame containing the input data. Must include ‘id’, ‘text’, and ‘embedding’ columns/keys. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreEmbedOutput | VectorStoreEmbedOutput | A validated instance of the class. |
validate
indexers.dataclasses.VectorStoreEmbedOutput.validate(df)Validate an existing DataFrame and return a VectorStoreEmbedOutput.
Validates the provided pandas DataFrame against the defined schema and returns a new instance of VectorStoreEmbedOutput if validation is successful.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | A pandas DataFrame to validate. Must include ‘id’, ‘text’, and ‘embedding’ columns. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreEmbedOutput | VectorStoreEmbedOutput | A validated instance of the class. |
VectorStoreReverseSearchInput
indexers.dataclasses.VectorStoreReverseSearchInput(data)DataFrame-like object for forming and validating reverse search query input data.
This class validates and represents input for reverse searches, which find similar documents to a given document in the vector store.
Attributes
| Name | Type | Description |
|---|---|---|
| id | pd.Series | Unique identifier for the reverse search query. |
| doc_label | pd.Series | The document ID to find similar documents for. |
Methods
| Name | Description |
|---|---|
| from_data | Create a validated VectorStoreReverseSearchInput from a dictionary or DataFrame. |
| validate | Validate an existing DataFrame and return a VectorStoreReverseSearchInput. |
from_data
indexers.dataclasses.VectorStoreReverseSearchInput.from_data(data)Create a validated VectorStoreReverseSearchInput from a dictionary or DataFrame.
Creates a new instance of VectorStoreReverseSearchInput by validating the input data against the defined schema.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | dict | pd.DataFrame | A dictionary or pandas DataFrame containing the input data. Must include ‘id’ and ‘doc_label’ columns/keys. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreReverseSearchInput | VectorStoreReverseSearchInput | A validated instance of the class. |
validate
indexers.dataclasses.VectorStoreReverseSearchInput.validate(df)Validate an existing DataFrame and return a VectorStoreReverseSearchInput.
Validates the provided pandas DataFrame against the defined schema and returns a new instance of VectorStoreReverseSearchInput if validation is successful.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | A pandas DataFrame to validate. Must include ‘id’ and ‘doc_label’ columns. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreReverseSearchInput | VectorStoreReverseSearchInput | A validated instance of the class. |
VectorStoreReverseSearchOutput
indexers.dataclasses.VectorStoreReverseSearchOutput(data)DataFrame-like object for storing reverse search results.
This class represents the output of vector store reverse search operations, containing knowledgebase examples with the same label as in the query.
Attributes
| Name | Type | Description |
|---|---|---|
| id | pd.Series | Identifier for the input label for lookup in the knowledgebase. |
| searched_doc_label | pd.Series | Identifier for the knowledgebase label being looked up. |
| doc_label | pd.Series | Identifier for the retrieved document with the same label. |
| doc_text | pd.Series | The text content of the retrieved example. |
Methods
| Name | Description |
|---|---|
| from_data | Create a validated VectorStoreReverseSearchOutput from a dictionary or DataFrame. |
| validate | Validate an existing DataFrame and return a VectorStoreReverseSearchOutput. |
from_data
indexers.dataclasses.VectorStoreReverseSearchOutput.from_data(data)Create a validated VectorStoreReverseSearchOutput from a dictionary or DataFrame.
Creates a new instance of VectorStoreReverseSearchOutput by validating the input data against the defined schema. If the output is empty, it creates a DataFrame with the correct schema.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | dict | pd.DataFrame | A dictionary or pandas DataFrame containing the input data. Must include ‘id’, ‘searched_doc_label’, ‘doc_label’, and ‘doc_text’ columns/keys. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreReverseSearchOutput | VectorStoreReverseSearchOutput | A validated instance of the class. |
validate
indexers.dataclasses.VectorStoreReverseSearchOutput.validate(df)Validate an existing DataFrame and return a VectorStoreReverseSearchOutput.
Validates the provided pandas DataFrame against the defined schema and returns a new instance of VectorStoreReverseSearchOutput if validation is successful.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | A pandas DataFrame to validate. Must include ‘id’, ‘searched_doc_label’, ‘doc_label’, and ‘doc_text’ columns. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreReverseSearchOutput | VectorStoreReverseSearchOutput | A validated instance of the class. |
VectorStoreSearchInput
indexers.dataclasses.VectorStoreSearchInput(data)DataFrame-like object for forming and validating search query input data.
This class validates and represents input queries for vector store search. Each row contains a unique query identifier and the associated query text.
Attributes
| Name | Type | Description |
|---|---|---|
| id | pd.Series | Unique identifier for each query. |
| query | pd.Series | The query text to search for. |
Methods
| Name | Description |
|---|---|
| from_data | Create a validated VectorStoreSearchInput from a dictionary or DataFrame. |
| validate | Validate an existing DataFrame and return a VectorStoreSearchInput. |
from_data
indexers.dataclasses.VectorStoreSearchInput.from_data(data)Create a validated VectorStoreSearchInput from a dictionary or DataFrame.
Creates a new instance of VectorStoreSearchInput by validating the input data against the defined schema.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | dict | pd.DataFrame | A dictionary or pandas DataFrame containing the input data. Must include ‘id’ and ‘query’ columns/keys. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreSearchInput | VectorStoreSearchInput | A validated instance of the class. |
validate
indexers.dataclasses.VectorStoreSearchInput.validate(df)Validate an existing DataFrame and return a VectorStoreSearchInput.
Validates the provided pandas DataFrame against the defined schema and returns a new instance of VectorStoreSearchInput if validation is successful.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | A pandas DataFrame to validate. Must include ‘id’ and ‘query’ columns. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreSearchInput | VectorStoreSearchInput | A validated instance of the class. |
VectorStoreSearchOutput
indexers.dataclasses.VectorStoreSearchOutput(data)DataFrame-like object for storing and validating search results.
This class represents the output of vector store search operations, containing query information, matched documents, scores, and similarity rankings.
Attributes
| Name | Type | Description |
|---|---|---|
| query_id | pd.Series | Identifier for the source query. |
| query_text | pd.Series | The original query text. |
| doc_label | pd.Series | Identifier for the retrieved document. |
| doc_text | pd.Series | The text content of the retrieved document. |
| rank | pd.Series | The ranking position of the result (0-indexed, non-negative). |
| score | pd.Series | The similarity score or relevance metric. |
Methods
| Name | Description |
|---|---|
| from_data | Create a validated VectorStoreSearchOutput from a dictionary or DataFrame. |
| validate | Validate an existing DataFrame and return a VectorStoreSearchOutput. |
from_data
indexers.dataclasses.VectorStoreSearchOutput.from_data(data)Create a validated VectorStoreSearchOutput from a dictionary or DataFrame.
Creates a new instance of VectorStoreSearchOutput by validating the input data against the defined schema.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | dict | pd.DataFrame | A dictionary or pandas DataFrame containing the input data. Must include ‘query_id’, ‘query_text’, ‘doc_label’, ‘doc_text’, ‘rank’, and ‘score’ columns/keys. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreSearchOutput | VectorStoreSearchOutput | A validated instance of the class. |
validate
indexers.dataclasses.VectorStoreSearchOutput.validate(df)Validate an existing DataFrame and return a VectorStoreSearchOutput.
Validates the provided pandas DataFrame against the defined schema and returns a new instance of VectorStoreSearchOutput if validation is successful.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | A pandas DataFrame to validate. Must include ‘query_id’, ‘query_text’, ‘doc_label’, ‘doc_text’, ‘rank’, and ‘score’ columns. | required |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreSearchOutput | VectorStoreSearchOutput | A validated instance of the class. |