How it works
When you run Ask:Understands your query
TopK 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.
Query:Based on the acquisition agreement and recent SEC filings, what are the main risks to the Vertex deal closing on time?Answer:
- The European Commission’s approval is conditional on divestiture of the logistics subsidiary within 90 days of closing, creating a tight execution window. 0_0 1_0
- The $1.8B consideration is subject to an unresolved working capital adjustment mechanism that could delay closing if the parties fail to agree on the final figure. 0_1
- An 18-month earnout tied to Vertex’s ARR targets introduces post-close execution risk; if milestones are missed, the deal economics shift materially for both parties. 2_0
- 0_0 — “Buyer shall procure the divestiture of the European logistics subsidiary no later than ninety (90) days following the Closing Date…” vertex-acquisition-agreement.pdf
- 0_1 — Consideration structure and working capital adjustment table, p. 4 vertex-acquisition-agreement.pdf
- 1_0 — “The European Commission has indicated that approval is contingent upon structural remedies including divestiture of logistics assets…” sec-filing-8k.html
- 2_0 — Closing timeline and earnout milestone diagram deal-timeline.png
- answering questions over internal knowledge bases
- comparing facts across reports, contracts, or policies
- grounding agents in private document context
- summarizing what your documents say about a topic
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
- facts — individual statements answering the query, backed by source citations
- refs — citations associated with each fact, linking back to the supporting documents
Scoping the query
Query across multiple datasets or apply document filters to narrow the scope of the query.Scoping to specific datasets
This is useful when you want:- More targeted answers
- Less ambiguity across unrelated document sets
- Tighter control over what context an agent is allowed to use
- 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. For example, if you uploaded documents with metadata such asdepartment, year, doc_type, or author, you can use those fields to limit what Ask is allowed to retrieve.
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 user is permitted to access
Python SDK
JavaScript SDK
Retrieving documents metadata
You may also want to retrieve metadata on the cited documents, such as title, author, date, category, or any custom metadata fields you attached during upload. That is especially useful when you want to:- Show document titles alongside facts
- Group answers by source attributes like year, author, or department
- Let agents carry document metadata into downstream workflows
- Render richer citations in a UI
- CLI
Python SDK
JavaScript SDK
Use
--field (repeatable) flag to include metadata field(s):Understanding citations
Citations are the evidence trail for the answer. They link each fact back to the original document passages that support it. A citation helps you identify:- Which document supported the claim
- Which passage, section, or chunk was used
- Any returned metadata you asked TopK to include
- Verify that an answer is correct
- Open the original document and inspect the relevant section
- Compare how strongly different sources support a claim
- Decide whether there is enough evidence to proceed
- Attach evidence to downstream actions or reports
- Ask follow-up questions against the cited documents