5 Commits

Author SHA1 Message Date
  Quentin Lhoest 7c4656a407 ci again 1 month ago
  Quentin Lhoest 041ca0e709 again 1 month ago
  Quentin Lhoest 7969d534a5 support gradio 5 1 month ago
  Quentin Lhoest 3abbed9316 fix ci 1 month ago
  Quentin Lhoest a591e9efed Revert "Fix dependency hints on ImportError (#717)" 1 month ago
5 changed files with 24 additions and 13 deletions
Split View
  1. +2
    -2
      metrics/fever/README.md
  2. +10
    -2
      metrics/fever/fever.py
  3. +1
    -0
      metrics/fever/requirements.txt
  4. +9
    -7
      src/evaluate/loading.py
  5. +2
    -2
      src/evaluate/utils/gradio.py

+ 2
- 2
metrics/fever/README.md View File

@@ -1,7 +1,7 @@
---
title: FEVER
emoji: 🔥
colorFrom: orange
colorFrom: blue
colorTo: red
sdk: gradio
sdk_version: 3.19.1
@@ -147,7 +147,7 @@ print(results)
{
'label_accuracy': 1.0,
'fever_score': 1.0,
'evidence_precision': 0.5,
'evidence_precision': 1.0,
'evidence_recall': 0.5,
'evidence_f1': 0.5
}


+ 10
- 2
metrics/fever/fever.py View File

@@ -62,8 +62,16 @@ Example:
>>> references = [{"label": "SUPPORTED", "evidence_sets": [["E1", "E2"], ["E3", "E4"]]}]
>>> fever = evaluate.load("fever")
>>> results = fever.compute(predictions=predictions, references=references)
>>> print(results)
{'label_accuracy': 1.0, 'fever_score': 1.0, 'evidence_precision': 1.0, 'evidence_recall': 1.0, 'evidence_f1': 1.0}
>>> print(results["label_accuracy"])
1.0
>>> print(results["fever_score"])
1.0
>>> print(results["evidence_precision"])
1.0
>>> print(results["evidence_recall"])
0.5
>>> print(round(results["evidence_f1"], 3))
0.667
"""




+ 1
- 0
metrics/fever/requirements.txt View File

@@ -0,0 +1 @@
git+https://github.com/huggingface/evaluate@{COMMIT_PLACEHOLDER}

+ 9
- 7
src/evaluate/loading.py View File

@@ -243,7 +243,7 @@ def _download_additional_modules(
elif import_type == "external":
url_or_filename = import_path
else:
raise ValueError(f"Wrong import_type: {import_type!r}. Expected 'library', 'internal', or 'external'.")
raise ValueError("Wrong import_type")

local_import_path = cached_path(
url_or_filename,
@@ -255,18 +255,20 @@ def _download_additional_modules(

# Check library imports
needs_to_be_installed = set()
for library_import_name, _ in library_imports:
for library_import_name, library_import_path in library_imports:
try:
importlib.import_module(library_import_name) # noqa F841
lib = importlib.import_module(library_import_name) # noqa F841
except ImportError:
library_import_name = "scikit-learn" if library_import_name == "sklearn" else library_import_name
library_import_path = "scikit-learn" if library_import_path == "sklearn" else library_import_path
library_import_name = "absl-py" if library_import_name == "absl" else library_import_name
needs_to_be_installed.add(library_import_name)
library_import_path = "absl-py" if library_import_path == "absl" else library_import_path
needs_to_be_installed.add((library_import_name, library_import_path))
if needs_to_be_installed:
missing = sorted(needs_to_be_installed)
raise ImportError(
f"To be able to use {name}, you need to install these dependencies: "
f"{', '.join(missing)} using the command 'pip install {' '.join(missing)}'."
f"To be able to use {name}, you need to install the following dependencies "
f"{[lib_name for lib_name, lib_path in needs_to_be_installed]} using 'pip install "
f"{' '.join([lib_path for lib_name, lib_path in needs_to_be_installed])}' for instance."
)
return local_imports



+ 2
- 2
src/evaluate/utils/gradio.py View File

@@ -111,13 +111,13 @@ def launch_gradio_widget(metric):

iface = gr.Interface(
fn=compute,
inputs=gr.inputs.Dataframe(
inputs=gr.Dataframe(
headers=feature_names,
col_count=len(feature_names),
row_count=1,
datatype=json_to_string_type(gradio_input_types),
),
outputs=gr.outputs.Textbox(label=metric.name),
outputs=gr.Textbox(label=metric.name),
description=(
metric.info.description + "\nIf this is a text-based metric, make sure to wrap you input in double quotes."
" Alternatively you can use a JSON-formatted list as input."


Loading…
Cancel
Save
Baidu
map