Skip to main content

How to use

Our codes provide the ability to evaluate automatic metrics which concludes the ability to calculate automatic metrics. Please follow these steps to calculate automatic QG metrics and evaluate automatic metrics on our benchmark.

Enviroment

run pip install -r requirements.txt to install the required packages.

Calculate Automatic Metrics

  1. Prepare data

    Use the data we provided at ../data/scores.xlsx, or use your own data, which should provide passages, answers, and references.

  2. Calculate automatic metrics.

    • Download models at coming soon for metrics.

    • Update model path inside the codes. See QRelScore as an example.

      # update the path of mlm_model and clm_model
      def corpus_qrel(preds, contexts, device='cuda'):
          assert len(contexts) == len(preds)
          mlm_model = 'model/bert-base-cased'
          clm_model = 'model/gpt2'
          scorer = QRelScore(mlm_model=mlm_model,
                  clm_model=clm_model,
                  batch_size=16,
                  nthreads=4,
                  device=device)
          scores = scorer.compute_score_flatten(contexts, preds)
          return scores
      
    • Run python metrics.py to calculate your assigned metrics results by changing score_names in metrics.py. (data_path in each file should be changed into your own data path)

      # Run QRelScore and RQUGE based on our dataset
      # load data
      data_path = '../data/scores.xlsx'
      save_path = './result/metric_result.xlsx'
      data = pd.read_excel(data_path)
      hypos = data['prediction'].tolist()
      refs_list = [data['reference'].tolist()]
      contexts = data['passage'].tolist()
      answers = data['answer'].tolist()
      # scores to use
      score_names = ['QRelScore', 'RQUGE']
      
      # run metrics
      res = get_metrics(hypos, refs_list, contexts, answers, score_names=score_names)
      
      # handle results
      for k, v in res.items():
          data[k] = v
      print(data.columns)
      
      # save results
      data.to_excel(save_path, index=False)
      
    • or run the code file for specific metric to calculate. For example, run python qrel.py to calculate QRelScore results.

Evaluate Automatic Metrics

Run python coeff.py to obtain the Pearson, Spearman, and Kendall correlation coefficient between the generated results and the labeled results. For detailed process, please refer to readme of QGEval.

Metadata

Release files for QGEval-metrics 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for QGEval-metrics 1.1.0
File Size Uploaded
QGEval_metrics-1.1.0.tar.gz 11.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for QGEval-metrics 1.1.0
File Interpreter ABI Platform
QGEval_metrics-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 MB

Release files / QGEval_metrics-1.1.0.tar.gz

Download URL QGEval_metrics-1.1.0.tar.gz
Size 11.8 MB
Tags Source
SHA-256 checksum
How to use checksums
e825d57f8e6c0976eeab83f95035eee3a5c42fa5de459da418ad7f6f43d429bb
BLAKE2b-256 checksum
How to use checksums
e18dd88a99c29d1a9789c77b4ab3b9a624b481cb1336c38dafe5f5254f8fc587
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.10

Release files / QGEval_metrics-1.1.0-py3-none-any.whl

Download URL QGEval_metrics-1.1.0-py3-none-any.whl
Size 12.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a7efb61348c220758919c9695f40eb7f8d437789715ba38a815105d1e0b06925
BLAKE2b-256 checksum
How to use checksums
18f70133b7b129cee55e6e3c51c3a1c60d8f8d6865a469da688f7e66fe1ed502
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.10

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.1

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page