Skip to main content

Evaluating environmental contamination summaries

Project description

ECSEval is a Python package designed to evaluate AI-generated summaries against human-curated (SME) summaries and reference data. It focuses on metrics like factual accuracy, relevance, and completeness while leveraging Natural Language Inference (NLI) and Large Language Models (LLMs) for advanced text analysis.

Installation

Use the package manager pip to install ECSEval.

pip install ECSEval

Example Usage

from ECSEval.summary_evaluator import SummaryEvaluator, Document

# invoking the LLM model
from langchain.chat_models import AzureChatOpenAI
from langchain.chains.question_answering import load_qa_chain

llm = AzureChatOpenAI(deployment_name=OPENAI_DEPLOYMENT_NAME,
                      model_name=OPENAI_MODEL_NAME,
                      openai_api_base=OPENAI_DEPLOYMENT_ENDPOINT,
                      openai_api_version=OPENAI_DEPLOYMENT_VERSION,
                      openai_api_key=OPENAI_API_KEY,
                      request_timeout=60)

# calling the SummaryEvaluator
evaluator = SummaryEvaluator(llm=llm)

# example Input data
reference_data = """The report discusses the presence of chemical contaminants, including lead and arsenic, 
in water samples from the region. It specifies the regulatory standards set by the Environmental Protection Agency (EPA), 
such as a maximum allowable lead level of 15 ppb. The analysis reveals that some samples exceed these regulatory thresholds, 
with lead levels reaching as high as 25 ppb in certain areas. Recommendations include immediate remediation efforts 
and stricter monitoring protocols."""
sme_summary = """The report highlights the presence of chemical contaminants like lead and arsenic in water samples. 
It mentions the EPA's regulatory standards, such as the maximum allowable lead level of 15 ppb, and states that some samples 
exceed these thresholds, with lead levels reaching 25 ppb. Remediation and monitoring efforts are recommended."""
ai_summary = """The report outlines water quality issues in the region, noting the presence of various chemicals. 
It emphasizes the need for better monitoring but does not provide details on contaminants, 
regulatory standards, or whether these standards are exceeded."""

# Evaluate summaries
metrics = evaluator.evaluate(reference_data, sme_summary, ai_summary)
print(metrics)

Batch data processing

import json
import pandas as pd
df = pd.read_excel('sample_data.xlsx') # dataframe containing Reference data, SME created summary and AI generated summary

metrics_list = []
for i in range(0, len(df)):
    metrics_dict  = evaluator.evaluate(df['reference text'].iloc[i], df['sme summary'].iloc[i], df['ai summary'].iloc[i])
    
    # to beautify the dict output in excel (optional)
    metrics_json = json.dumps(metrics_dict, indent=4)
    metrics_json = metrics_json.replace(r'\n', '\n')  
    
    metrics_list.append(metrics_json)

df['metrics'] = metrics_list

df.to_excel("sample_data_out.xlsx", index=False, engine='openpyxl')

About

This package is built as part of our ongoing research on evaluating large language models for Environmental data. For more details about this work please refer to our research paper: "Evaluating the Evaluators: A Deep Dive into Metrics for Large Language Models on Environmental Data" which will be submitted to the MLDS 2025 Conference (https://mlds.analyticsindiamag.com/)

If you use this work, Please cite us and star at:https://github.com/dreji18/ECSEval

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecseval-0.0.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ECSEval-0.0.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file ecseval-0.0.3.tar.gz.

File metadata

  • Download URL: ecseval-0.0.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for ecseval-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e70430171346a8be5c0979b24e9d6aa8350c1b5679eaaba2d6cec71b5b2e873d
MD5 24a8c2dda125cb409f40cbd608d746c4
BLAKE2b-256 b5425911f62adffaa8d33c71d3d5a249df4e729cb36ec6ec6975f1cd87a8897f

See more details on using hashes here.

File details

Details for the file ECSEval-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: ECSEval-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for ECSEval-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6fe5dd5cd41c534229b637f109e42957a69f9867b77d63074abe63751c2763dd
MD5 922a6502cef334fd5c391a30c99d6fc5
BLAKE2b-256 38c37c26fda131e39f5388164f6649fa1e4a6535f7698d7ca45f32bf2d9666d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page