Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ The latest tagged version is also available via PyPI:
pip install lm-polygraph
```

### Optional dependencies

Some features require additional packages that are not installed by default:

- **COMET metric** (translation evaluation): `unbabel-comet` pins `numpy<2.0` which may conflict with other packages (e.g., vLLM). Install via extras:
```shell
pip install lm-polygraph[comet]
```

## <a name="basic_usage"></a>Basic usage
1. Initialize the base model (encoder-decoder or decoder-only) and tokenizer from HuggingFace or a local file, and use them to initialize the WhiteboxModel for evaluation:
```python
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ classifiers = [
"Repository" = "https://github.com/IINemo/lm-polygraph"
"Documentation" = "https://lm-polygraph.readthedocs.io"

[project.optional-dependencies]
comet = ["unbabel-comet<3"]

[tool.setuptools]
script-files = [
"scripts/polygraph_eval",
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ matplotlib>=3.6
pandas>=1.3.5
torch>=2.6.0
bs4
transformers>=4.50.0
transformers>=4.50.0,<5
nltk>=3.6.5
sacrebleu>=1.5.0
sentencepiece>=0.2.1
Expand All @@ -29,10 +29,9 @@ openai>=1.52.0
wget
sentence-transformers
bert-score>=0.3.13
unbabel-comet<3
nltk>=3.7,<4
evaluate>=0.4.2
spacy>=3.4.0,<3.8.0
spacy>=3.4.0
fastchat
diskcache>=5.6.3
boostedprob
7 changes: 6 additions & 1 deletion src/lm_polygraph/generation_metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
from .model_score import ModelScoreSeqMetric, ModelScoreTokenwiseMetric
from .bart_score import BartScoreSeqMetric
from .accuracy import AccuracyMetric
from .comet import Comet

try:
from .comet import Comet
except ImportError:
Comet = None

from .alignscore import AlignScore
from .openai_fact_check import OpenAIFactCheck
from .bert_score import BertScoreMetric
Expand Down
3 changes: 2 additions & 1 deletion src/lm_polygraph/generation_metrics/comet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import re
import numpy as np
from evaluate import load

from typing import List, Dict
from .generation_metric import GenerationMetric
Expand All @@ -14,6 +13,8 @@ class Comet(GenerationMetric):

def __init__(self, source_ignore_regex=None, lang="en"):
super().__init__(["greedy_texts", "input_texts"], "sequence")
from evaluate import load

self.scorer = load("comet")
self.source_ignore_regex = (
re.compile(source_ignore_regex) if source_ignore_regex else None
Expand Down
Loading