We needed to condense patent-dispute response consulting reports averaging roughly 200 pages into one or two pages that a nonspecialist could understand. Document length was only part of the problem: the 20 samples ranged from 20 to more than 600 pages, used different patent-firm templates, and mixed English, Japanese, and Chinese.
Overcoming the context length limit
Under the company's requirements, we could not use a separate GPU instance, and the reports came from a Korea Institute of Patent Information (KIPI) support program, so we had to use a Naver API covered by an intermediate-level or higher public-sector Cloud Security Assurance Program (CSAP) certification. Open-source models were therefore not an option, and we used HyperCLOVA X, which met the requirements at the time.
HyperCLOVA X's maximum context was then 8,192 tokens, while the source reports averaged more than 100,000 characters. Because a report could not fit in one request, I first compared two approaches to long-document summarization.
| Approach | Operation | Limitation |
|---|---|---|
| Map Reduce | Summarize each chunk independently, then combine the results | Context breaks between chunks and output formats vary |
| Refine | Pass the previous chunk's summary into the next request | The growing summary leaves progressively less context for later chunks |
Refine preserved earlier context more effectively, but left less and less token capacity for the end of the document—for longer reports, too little context remained to summarize the later sections. Map Reduce divided long documents reliably, but produced fragmented summaries with inconsistent transitions between chunks. I used Map Reduce to summarize individual chunks, then added a stage that rewrote the combined summary for continuity and consistent formatting.
The resulting workflow converted each PDF to text, ran one or two summarization passes depending on length, and then rewrote the final summary to retain the patents at issue, response strategies, and country-specific details.
Vector document retrieval
After the summarization module was complete, the company requested embedding-based retrieval of related documents. I used an LLM to extract keywords from the final summaries and compared them with the existing TF-IDF results. I also implemented both TF-IDF and embedding-based vector retrieval, so that documents with exact term overlap could be found by the existing approach and documents containing synonyms or semantically related terms by vector search.
Results
I implemented the summaries—including patents at issue, response strategies, and country-specific details—and the document-retrieval feature. The project concluded after loading the results into the company's database and delivering the source code.