Table Indexο
Building the Keyword Table Index
Keyword Table Index Data Structures.
- class llama_index.indices.keyword_table.GPTKeywordTableIndex(nodes: Optional[Sequence[Node]] = None, index_struct: Optional[KeywordTable] = None, service_context: Optional[ServiceContext] = None, keyword_extract_template: Optional[KeywordExtractPrompt] = None, max_keywords_per_chunk: int = 10, use_async: bool = False, **kwargs: Any)ο
GPT Keyword Table Index.
This index uses a GPT model to extract keywords from the text.
- delete(doc_id: str, **delete_kwargs: Any) None ο
Delete a document from the index.
All nodes in the index related to the index will be deleted.
- Parameters
doc_id (str) β document id
- property docstore: BaseDocumentStoreο
Get the docstore corresponding to the index.
- classmethod from_documents(documents: Sequence[Document], storage_context: Optional[StorageContext] = None, service_context: Optional[ServiceContext] = None, **kwargs: Any) IndexType ο
Create index from documents.
- Parameters
documents (Optional[Sequence[BaseDocument]]) β List of documents to build the index from.
- property index_id: strο
Get the index struct.
- property index_struct: ISο
Get the index struct.
- index_struct_clsο
alias of
KeywordTable
- refresh(documents: Sequence[Document], **update_kwargs: Any) List[bool] ο
Refresh an index with documents that have changed.
This allows users to save LLM and Embedding model calls, while only updating documents that have any changes in text or extra_info. It will also insert any documents that previously were not stored.
- set_index_id(index_id: str) None ο
Set the index id.
NOTE: if you decide to set the index_id on the index_struct manually, you will need to explicitly call add_index_struct on the index_store to update the index store.
- Parameters
index_id (str) β Index id to set.
- update(document: Document, **update_kwargs: Any) None ο
Update a document.
This is equivalent to deleting the document and then inserting it again.
- Parameters
document (Union[BaseDocument, BaseGPTIndex]) β document to update
insert_kwargs (Dict) β kwargs to pass to insert
delete_kwargs (Dict) β kwargs to pass to delete
- class llama_index.indices.keyword_table.GPTRAKEKeywordTableIndex(nodes: Optional[Sequence[Node]] = None, index_struct: Optional[KeywordTable] = None, service_context: Optional[ServiceContext] = None, keyword_extract_template: Optional[KeywordExtractPrompt] = None, max_keywords_per_chunk: int = 10, use_async: bool = False, **kwargs: Any)ο
GPT RAKE Keyword Table Index.
This index uses a RAKE keyword extractor to extract keywords from the text.
- delete(doc_id: str, **delete_kwargs: Any) None ο
Delete a document from the index.
All nodes in the index related to the index will be deleted.
- Parameters
doc_id (str) β document id
- property docstore: BaseDocumentStoreο
Get the docstore corresponding to the index.
- classmethod from_documents(documents: Sequence[Document], storage_context: Optional[StorageContext] = None, service_context: Optional[ServiceContext] = None, **kwargs: Any) IndexType ο
Create index from documents.
- Parameters
documents (Optional[Sequence[BaseDocument]]) β List of documents to build the index from.
- property index_id: strο
Get the index struct.
- property index_struct: ISο
Get the index struct.
- index_struct_clsο
alias of
KeywordTable
- refresh(documents: Sequence[Document], **update_kwargs: Any) List[bool] ο
Refresh an index with documents that have changed.
This allows users to save LLM and Embedding model calls, while only updating documents that have any changes in text or extra_info. It will also insert any documents that previously were not stored.
- set_index_id(index_id: str) None ο
Set the index id.
NOTE: if you decide to set the index_id on the index_struct manually, you will need to explicitly call add_index_struct on the index_store to update the index store.
- Parameters
index_id (str) β Index id to set.
- update(document: Document, **update_kwargs: Any) None ο
Update a document.
This is equivalent to deleting the document and then inserting it again.
- Parameters
document (Union[BaseDocument, BaseGPTIndex]) β document to update
insert_kwargs (Dict) β kwargs to pass to insert
delete_kwargs (Dict) β kwargs to pass to delete
- class llama_index.indices.keyword_table.GPTSimpleKeywordTableIndex(nodes: Optional[Sequence[Node]] = None, index_struct: Optional[KeywordTable] = None, service_context: Optional[ServiceContext] = None, keyword_extract_template: Optional[KeywordExtractPrompt] = None, max_keywords_per_chunk: int = 10, use_async: bool = False, **kwargs: Any)ο
GPT Simple Keyword Table Index.
This index uses a simple regex extractor to extract keywords from the text.
- delete(doc_id: str, **delete_kwargs: Any) None ο
Delete a document from the index.
All nodes in the index related to the index will be deleted.
- Parameters
doc_id (str) β document id
- property docstore: BaseDocumentStoreο
Get the docstore corresponding to the index.
- classmethod from_documents(documents: Sequence[Document], storage_context: Optional[StorageContext] = None, service_context: Optional[ServiceContext] = None, **kwargs: Any) IndexType ο
Create index from documents.
- Parameters
documents (Optional[Sequence[BaseDocument]]) β List of documents to build the index from.
- property index_id: strο
Get the index struct.
- property index_struct: ISο
Get the index struct.
- index_struct_clsο
alias of
KeywordTable
- refresh(documents: Sequence[Document], **update_kwargs: Any) List[bool] ο
Refresh an index with documents that have changed.
This allows users to save LLM and Embedding model calls, while only updating documents that have any changes in text or extra_info. It will also insert any documents that previously were not stored.
- set_index_id(index_id: str) None ο
Set the index id.
NOTE: if you decide to set the index_id on the index_struct manually, you will need to explicitly call add_index_struct on the index_store to update the index store.
- Parameters
index_id (str) β Index id to set.
- update(document: Document, **update_kwargs: Any) None ο
Update a document.
This is equivalent to deleting the document and then inserting it again.
- Parameters
document (Union[BaseDocument, BaseGPTIndex]) β document to update
insert_kwargs (Dict) β kwargs to pass to insert
delete_kwargs (Dict) β kwargs to pass to delete
- class llama_index.indices.keyword_table.KeywordTableGPTRetriever(index: BaseGPTKeywordTableIndex, keyword_extract_template: Optional[KeywordExtractPrompt] = None, query_keyword_extract_template: Optional[QueryKeywordExtractPrompt] = None, max_keywords_per_query: int = 10, num_chunks_per_query: int = 10, **kwargs: Any)ο
Keyword Table Index GPT Retriever.
Extracts keywords using GPT. Set when using retriever_mode=βdefaultβ.
See BaseGPTKeywordTableQuery for arguments.
- retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore] ο
Retrieve nodes given query.
- Parameters
str_or_query_bundle (QueryType) β Either a query string or a QueryBundle object.
- class llama_index.indices.keyword_table.KeywordTableRAKERetriever(index: BaseGPTKeywordTableIndex, keyword_extract_template: Optional[KeywordExtractPrompt] = None, query_keyword_extract_template: Optional[QueryKeywordExtractPrompt] = None, max_keywords_per_query: int = 10, num_chunks_per_query: int = 10, **kwargs: Any)ο
Keyword Table Index RAKE Retriever.
Extracts keywords using RAKE keyword extractor. Set when retriever_mode=βrakeβ.
See BaseGPTKeywordTableQuery for arguments.
- retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore] ο
Retrieve nodes given query.
- Parameters
str_or_query_bundle (QueryType) β Either a query string or a QueryBundle object.
- class llama_index.indices.keyword_table.KeywordTableSimpleRetriever(index: BaseGPTKeywordTableIndex, keyword_extract_template: Optional[KeywordExtractPrompt] = None, query_keyword_extract_template: Optional[QueryKeywordExtractPrompt] = None, max_keywords_per_query: int = 10, num_chunks_per_query: int = 10, **kwargs: Any)ο
Keyword Table Index Simple Retriever.
Extracts keywords using simple regex-based keyword extractor. Set when retriever_mode=βsimpleβ.
See BaseGPTKeywordTableQuery for arguments.
- retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore] ο
Retrieve nodes given query.
- Parameters
str_or_query_bundle (QueryType) β Either a query string or a QueryBundle object.