Keyword index query engine
KeywordTableIndex
is a type of index in LlamaIndex, designed to extract keywords from your documents and organize them in a table-like structure. This structure makes it easier to query and retrieve relevant information based on specific keywords or topics. Once again, don’t think about this function as a simple list of extracted keywords. The extracted keywords are organized into a table-like format where each keyword is associated with an ID that points to the related nodes.
The program creates the keyword index in two lines of code:
from llama_index.core import KeywordTableIndex
keyword_index = KeywordTableIndex.from_documents(documents)
Let’s extract the data and create a pandas DataFrame to see how the index is structured:
# Extract data for DataFrame
data = []
for keyword, doc_ids in keyword_index.index_struct.table.items():
for doc_id in doc_ids:
data.append({"Keyword": keyword, "Document ID...