ScaleDown Team • February 2025 • 10 min readLegal teams spend hours reading through multi-page contracts to find specific clauses. A RAG-powered contract analyzer can answer questions like “What’s the termination clause?” or “What are our liability caps?” in seconds. Traditionally you’d need a vector database to index every contract. With ScaleDown, you don’t.Feed the contract as context, ask your question as prompt, and ScaleDown compresses away the irrelevant sections before the LLM sees them.
This example builds a contract Q&A tool that answers clause-specific questions from legal agreements. No vector database, no embeddings.
Contracts are long, dense, and full of boilerplate. When a lawyer asks “What’s the liability cap?”, the LLM doesn’t need to read 15 pages of definitions, recitals, and signature blocks. It needs the one paragraph that matters.ScaleDown’s query-aware compression handles this well. It keeps the clauses relevant to the question and compresses everything else.
Here’s a realistic software licensing agreement with multiple clauses:
Sample contract text
Copy
contract = """SOFTWARE LICENSE AGREEMENTEffective Date: January 15, 2025Parties: Acme Corp ("Licensor") and Beta Industries ("Licensee")1. DEFINITIONS"Software" means the Acme Analytics Platform v4.2 and all associated documentation."Licensed Users" means employees of Licensee authorized to access the Software,not to exceed 500 users. "Confidential Information" means any non-public technical,business, or financial information disclosed by either party.2. GRANT OF LICENSELicensor grants Licensee a non-exclusive, non-transferable license to use theSoftware for internal business purposes only. Licensee may not sublicense,distribute, or make the Software available to any third party. The licenseis valid for the Territory defined as the United States and Canada only.3. FEES AND PAYMENTLicensee shall pay an annual license fee of $240,000, due within 30 days ofeach anniversary of the Effective Date. Late payments shall accrue interestat 1.5% per month. Licensor reserves the right to suspend access if paymentis more than 60 days overdue.4. TERM AND TERMINATIONThis Agreement has an initial term of 3 years from the Effective Date, withautomatic renewal for successive 1-year periods unless either party provideswritten notice of non-renewal at least 90 days prior to expiration. Eitherparty may terminate for cause if the other party materially breaches thisAgreement and fails to cure such breach within 30 days of written notice.Upon termination, Licensee must destroy all copies of the Software andcertify destruction in writing within 14 days.5. LIABILITY AND INDEMNIFICATIONLicensor's total aggregate liability under this Agreement shall not exceedthe fees paid by Licensee in the 12 months preceding the claim. In no eventshall either party be liable for indirect, incidental, special, or consequentialdamages, including lost profits. Licensee shall indemnify Licensor against anythird-party claims arising from Licensee's use of the Software in violationof this Agreement.6. CONFIDENTIALITYEach party agrees to maintain the confidentiality of the other party'sConfidential Information for a period of 5 years following disclosure.Confidential Information does not include information that: (a) is or becomespublicly available, (b) was known prior to disclosure, (c) is independentlydeveloped, or (d) is disclosed pursuant to legal requirement.7. DATA PROTECTIONLicensor shall implement and maintain industry-standard security measures,including SOC 2 Type II compliance, AES-256 encryption at rest, and TLS 1.3for data in transit. Licensor will notify Licensee of any data breach within72 hours of discovery. Licensee retains ownership of all data processedthrough the Software.8. GOVERNING LAW AND DISPUTESThis Agreement shall be governed by the laws of the State of Delaware.Any disputes shall be resolved through binding arbitration administeredby the American Arbitration Association in Wilmington, Delaware."""
The contract has 8 sections. The user only cares about one or two. ScaleDown figures out which.
Copy
question = "What is the liability cap and are there any exclusions?"# ScaleDown keeps liability-related clauses, compresses the restresponse = requests.post( SCALEDOWN_URL, headers=SCALEDOWN_HEADERS, json={ "context": contract, "prompt": question, "model": "gpt-4o", "scaledown": {"rate": "auto"} })result = response.json()compressed = result["compressed_prompt"]print(f"Original: {result['original_prompt_tokens']} tokens")print(f"Compressed: {result['compressed_prompt_tokens']} tokens")# Original: 620 tokens# Compressed: 95 tokens
The contract has 8 clauses totaling ~620 tokens. ScaleDown compressed it to ~95 tokens by keeping Section 5 (Liability) and dropping definitions, payment terms, confidentiality, and governing law, since none of those answer the question.
3
Get the answer from your LLM
Copy
response = openai_client.chat.completions.create( model="gpt-4o", messages=[ { "role": "system", "content": ( "You are a legal assistant. Answer the question using " "ONLY the provided contract context. Cite specific " "sections when possible. If the answer is not in the " "context, say so." ) }, { "role": "user", "content": f"Contract context:\n{compressed}\n\nQuestion: {question}" } ], temperature=0.1)print(response.choices[0].message.content)
Example output:
Per Section 5, the Licensor’s total aggregate liability is capped at the fees paid by Licensee in the 12 months preceding the claim. Neither party is liable for indirect, incidental, special, or consequential damages, including lost profits.
The answer cites the correct section, states the exact cap, and lists the exclusions. All from the compressed context.
def ask_contract(contract_text: str, question: str) -> str: """Query a legal contract using ScaleDown compression.""" # Compress: keeps clauses relevant to the question compress_resp = requests.post( SCALEDOWN_URL, headers=SCALEDOWN_HEADERS, json={ "context": contract_text, "prompt": question, "model": "gpt-4o", "scaledown": {"rate": "auto"} } ) compressed = compress_resp.json()["compressed_prompt"] # Generate: LLM answers from compressed context ai_resp = openai_client.chat.completions.create( model="gpt-4o", messages=[ { "role": "system", "content": ( "You are a legal assistant. Answer using ONLY the " "provided contract context. Cite sections when possible." ) }, { "role": "user", "content": f"Contract:\n{compressed}\n\nQuestion: {question}" } ], temperature=0.1 ) return ai_resp.choices[0].message.content# Example queriesprint(ask_contract(contract, "Can we sublicense the software to partners?"))print(ask_contract(contract, "What happens if we pay late?"))print(ask_contract(contract, "How much notice do we need to cancel?"))print(ask_contract(contract, "What security standards does the vendor meet?"))
Legal answers need to cite specific clauses. By compressing away irrelevant sections, the LLM focuses on the right text, which means fewer hallucinated clause references.
Contracts are long
A typical enterprise contract is 10-30 pages. Compression cuts token costs by 70-85% per query while keeping the clauses that matter.
This tool is for informational purposes. Always have a qualified attorney review contract interpretations before making legal decisions.