TopK answers natural-language queries over your documents. It retrieves the most relevant parts of your documents and synthesizes a grounded answer with source citations.Documentation Index
Fetch the complete documentation index at: https://docs.topk.io/llms.txt
Use this file to discover all available pages before exploring further.
How it works
When you run an Ask, TopK:Understands your query
Interprets your question and organizes it into a clear sequence of answerable steps
Searches your documents
Your documents are searched to find the most relevant passages based on your query.
Returns answer with source citations
Returns a grounded answer with facts, citations, and a confidence score. See Understanding the answer.
Usage
Once a dataset is created and your documents are processed, you can start running agentic queries against your documents:- CLI
Python SDK
JavaScript SDK
Query:What was the total net income of Bank of America in 2024?Answer:
- Bank of America’s total net income for the fiscal year 2024 was $27,132 million. 1 2 3 4 5 6
- The 2024 net income of $27.1 billion represented an increase from the $26.5 billion reported in 2023. 3 4 6
- The increase in 2024 net income was driven by higher noninterest income, although this was partially offset by a higher provision for credit losses and lower net interest income. 3 6
- 1 Condensed Statement of Cash Flows showing net income of $27,132m (2024) vs $26,515m (2023)
bank_of_america_2024.pdf p. 170 - 2 Consolidated Statement of Comprehensive Income: net income line item for 2024–2022
bank_of_america_2024.pdf p. 92 - 3 Supporting figure from the filing (tabular financial excerpt)
boa-ask-ref-3-figure.jpg - 4 Key performance indicators—selected annual financial data (including net income)
bank_of_america_2024.pdf pp. 33–36 - 5 Segment results tying to total-corporation net income
bank_of_america_2024.pdf pp. 166–168 - 6 Executive summary—summary income statement and balance sheet excerpts
bank_of_america_2024.pdf pp. 29–30
Understanding the answer
The answer consists of three fields:facts— individual statements answering the query, each backed by one or more citationsrefs— a map from citation number to a Search Resultconfidence— a score between 0 and 100 indicating confidence in the answer
Citations
Citations are numbered. Each fact’sref_ids list points to entries in refs, where each key is a citation number and each value is a Search Result — the matched passage or image along with its document ID, file name, dataset, and any requested metadata.
Scoping the search
Query across specific datasets or apply document filters to narrow the scope of the query.Scoping to specific datasets
When running ask, you must specify at least one dataset to query against.- CLI
Python SDK
JavaScript SDK
To specify the datasets to query against, pass
--dataset or -d (repeatable):Document filtering
Sometimes a dataset might contain documents that should not be considered for the query. You can filter out documents that don’t match your criteria by providing a filter expression. These filter expressions operate on the metadata fields of documents. If your documents include metadata fields, you can use those fields to narrow down the search scope. This is useful when you want to query:- Documents within a specific time range
- Documents matching a particular category or type
- Documents associated with a specific group or owner
- Documents the end user is permitted to access
Python SDK
JavaScript SDK
Retrieving metadata
By default, metadata fields are not included in citations. Pass the field names you want returned and they will appear on each cited Search Result.- CLI
Python SDK
JavaScript SDK
Use
--field (repeatable) and --output json to include metadata field(s) in the output:Example output