top of page

 

 

I successfully adapted DSPy.GEPA to function not only as a prompt optimizer but also as a context optimizer. The code, available at the link below, processed 198 state-level court rulings with an average of 14,239 tokens per document in approximately 19 minutes. This demonstrates that small to mid-sized businesses can apply these approaches to sentiment analysis under tight budget constraints.

I developed code pipelines to refine legal category descriptions and evaluate court case classification. Starting with original SBERT similarity scores comparing documents to predefined category paragraphs, I used GEPA and GPT-4o-mini to iteratively refine the explanatory paragraphs for four constitutional education categories, ensuring clarity, precision, and distinctiveness. The refined paragraphs were saved as JSON/CSV files for reproducibility. I then recomputed SBERT similarity scores between documents (chunked for long texts) and the refined paragraphs, classifying documents based on maximum similarity. Finally, I evaluated performance metrics (precision, recall, F1-score) to assess improvements over the baseline.
This workflow combines LLM-driven content refinement with embedding-based classification, enhancing both interpretability and automated analysis of legal documents.

Below, I provide the original and GEPA-refined instructions for computing similarity scores for the first two categories:

✅ Category 'equal protection' was refined.

Original:
Courts mandate state governments to equalize educational fund across local school districts based on constitution or law with equal protection clause.

Refined:
Courts require state governments to equalize educational funding across local school districts as mandated by the Constitution's Equal Protection Clause. This ensures that all students have access to the same level of educational resources, regardless of their district's wealth.

✅ Category 'education adequacy' was refined.

Original:
Courts mandate state governments to direct local school districts to provide quality education with improved teacher qualifications or classroom conditions or facility construction based on constitution or law with education clause. Quality education improves student performance or exam or test scores or potential.

Refined:
Courts direct state governments to ensure that local school districts provide a quality education. This includes improving teacher qualifications, classroom conditions, and facility construction, as required by the Constitution's Education Clause. A focus on quality education is linked to enhanced student performance, test scores, and overall potential.

bottom of page