Skip to main content

Calculate the BLEU, ROUGE, PPL scores of large models

Project description

BLEU ROUGE PPL 评分计算工具包

安装

pip install calculator_main

使用

from calculator_main.main import LLMAssessment

示例

# 示例:困惑度计算
sentences = [
    ['I', 'have', 'a', 'pen'],
    ['He', 'has', 'a', 'book'],
    ['She', 'has', 'a', 'cat']
]
unigram = {
    'I': 1 / 12, 'have': 1 / 12, 'a': 3 / 12, 'pen': 1 / 12,
    'He': 1 / 12, 'has': 2 / 12, 'book': 1 / 12, 'She': 1 / 12, 'cat': 1 / 12
}
perplexity = LLMAssessment.calculate_perplexity(sentences, unigram)
print("困惑度为:", perplexity)

# 示例:ROUGE分数计算
generated_text = "This is some generated text."
reference_text = "This is a reference text."
rouge_scores = LLMAssessment.calculate_rouge(generated_text, reference_text)
print("ROUGE分数:", rouge_scores)

# 示例:BLEU分数计算
candidate_text = ["This", "is", "some", "generated", "text"]
reference_texts = [
    ["This", "is", "a", "reference", "text"],
    ["This", "is", "another", "reference", "text"]
]
bleu_scores = LLMAssessment.calculate_bleu(reference_texts, candidate_text)
print("BLEU分数:", bleu_scores)

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

calculator_main-1.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

calculator_main-1.0.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file calculator_main-1.0.1.tar.gz.

File metadata

  • Download URL: calculator_main-1.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for calculator_main-1.0.1.tar.gz
Algorithm Hash digest
SHA256 273600602d7bc6fd3b316bfff7a95d00a583e14c3ba604cc2782926adb78a1c4
MD5 473a1613dd7b327d2c852392560b9876
BLAKE2b-256 cc3b09abcbb347fc6cb281f24aad1dd46bcd6ec92836fd15dcb4dac9e6ea3c93

See more details on using hashes here.

File details

Details for the file calculator_main-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for calculator_main-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc4dd55f03df71e0c13eb4d046a6789681c7e6b870bca769c8e562590f02c1f8
MD5 023049836cff97148bd2c727b7d6ff31
BLAKE2b-256 3147b8b6395fe165e3e2504fe5092c98aab3d52a8e24b76a0f148fd16398bd2f

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