APIQIKAPIQIK
Docs
Cookbook

Summarization and Information Extraction

Split long-document processing into chunking, extraction, merging, and validation to control context and costs.

Sending an entire long document in one request is not always best. Reliable production workflows usually include preprocessing, chunking, local processing, merging, and validation.

Summarization strategies

StrategyWhen to useMethod
DirectThe full text safely fits the context window.Use one request with explicit length, audience, and essential information.
ChunkedThe document is long or well structured.Summarize sections, then merge into a global summary.
IterativeContent streams in or changes continuously.Update the previous summary using new passages.
Query-focusedOnly one topic matters.Retrieve relevant passages, then summarize around the question.

Extraction request example

{
  "model": "qwen-turbo",
  "messages": [
    {
      "role": "system",
      "content": "Extract product, issue, and priority from the ticket. Use null when uncertain. Return only JSON."
    },
    {
      "role": "user",
      "content": "Our production chat API has timed out frequently since 10 a.m., affecting all users."
    }
  ],
  "temperature": 0,
  "response_format": {
    "type": "json_object"
  }
}

Reduce hallucinations

  • Explicitly require null for unknown fields rather than guesses.
  • Ask for source excerpts or character positions supporting extracted values.
  • Parse numbers, dates, amounts, and identifiers again with deterministic code.
  • Set confidence thresholds or human review for high-risk results.
  • Track field completeness and accuracy with regression samples.

Cost control

Remove HTML navigation, repeated headers and footers, and meaningless whitespace before sending content. Split long documents at natural section boundaries where possible, and cache unchanged intermediate summaries.