Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs to reflect new metric structure #145

Merged
merged 4 commits into from
Oct 8, 2024
Merged
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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ assert langcheck.metrics.fluency(generated_outputs) > 0.5

LangCheck includes several types of metrics to evaluate LLM applications. Some examples:

| Type of Metric | Examples | Languages |
| ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | ------------- |
| [Reference-Free Text Quality Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#reference-free-text-quality-metrics) | `toxicity(generated_outputs)`<br>`sentiment(generated_outputs)`<br>`ai_disclaimer_similarity(generated_outputs)` | EN, JA, ZH, DE |
| [Reference-Based Text Quality Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#reference-based-text-quality-metrics) | `semantic_similarity(generated_outputs, reference_outputs)`<br>`rouge2(generated_outputs, reference_outputs)` | EN, JA, ZH, DE |
| [Source-Based Text Quality Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#source-based-text-quality-metrics) | `factual_consistency(generated_outputs, sources)` | EN, JA, ZH, DE |
| [Text Structure Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#text-structure-metrics) | `is_float(generated_outputs, min=0, max=None)`<br>`is_json_object(generated_outputs)` | All Languages |
| [Pairwise Text Quality Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#pairwise-text-quality-metrics) | `pairwise_comparison(generated_outputs_a, generated_outputs_b, prompts)` | EN, JA |
| Type of Metric | Examples | Languages |
| ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | -------------- |
| [Reference-Free Text Quality Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#reference-free-text-quality-metrics) | `toxicity(generated_outputs)`<br>`sentiment(generated_outputs)`<br>`ai_disclaimer_similarity(generated_outputs)` | EN, JA, ZH, DE |
| [Reference-Based Text Quality Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#reference-based-text-quality-metrics) | `semantic_similarity(generated_outputs, reference_outputs)`<br>`rouge2(generated_outputs, reference_outputs)` | EN, JA, ZH, DE |
| [Source-Based Text Quality Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#source-based-text-quality-metrics) | `factual_consistency(generated_outputs, sources)` | EN, JA, ZH, DE |
| [Query-Based Text Quality Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#query-based-text-quality-metrics) | `answer_relevance(generated_outputs, prompts)` | EN, JA |
| [Text Structure Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#text-structure-metrics) | `is_float(generated_outputs, min=0, max=None)`<br>`is_json_object(generated_outputs)` | All Languages |
| [Pairwise Text Quality Metrics](https://langcheck.readthedocs.io/en/latest/metrics.html#pairwise-text-quality-metrics) | `pairwise_comparison(generated_outputs_a, generated_outputs_b, prompts)` | EN, JA |

### Visualize Metrics

Expand Down
8 changes: 8 additions & 0 deletions docs/langcheck.metrics.custom_text_quality.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

langcheck.metrics.custom\_text\_quality
=======================================

.. automodule:: langcheck.metrics.custom_text_quality
:members:
:undoc-members:
:show-inheritance:
8 changes: 8 additions & 0 deletions docs/langcheck.metrics.de.query_based_text_quality.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

langcheck.metrics.de.query\_based\_text\_quality
================================================

.. automodule:: langcheck.metrics.de.query_based_text_quality
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/langcheck.metrics.de.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ langcheck.metrics.de
:hidden:
:maxdepth: 4

langcheck.metrics.de.query_based_text_quality
langcheck.metrics.de.reference_based_text_quality
langcheck.metrics.de.reference_free_text_quality
langcheck.metrics.de.source_based_text_quality
8 changes: 8 additions & 0 deletions docs/langcheck.metrics.en.query_based_text_quality.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

langcheck.metrics.en.query\_based\_text\_quality
================================================

.. automodule:: langcheck.metrics.en.query_based_text_quality
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/langcheck.metrics.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ langcheck.metrics.en
:maxdepth: 4

langcheck.metrics.en.pairwise_text_quality
langcheck.metrics.en.query_based_text_quality
langcheck.metrics.en.reference_based_text_quality
langcheck.metrics.en.reference_free_text_quality
langcheck.metrics.en.source_based_text_quality
8 changes: 8 additions & 0 deletions docs/langcheck.metrics.ja.query_based_text_quality.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

langcheck.metrics.ja.query\_based\_text\_quality
================================================

.. automodule:: langcheck.metrics.ja.query_based_text_quality
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/langcheck.metrics.ja.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ langcheck.metrics.ja
:maxdepth: 4

langcheck.metrics.ja.pairwise_text_quality
langcheck.metrics.ja.query_based_text_quality
langcheck.metrics.ja.reference_based_text_quality
langcheck.metrics.ja.reference_free_text_quality
langcheck.metrics.ja.source_based_text_quality
5 changes: 5 additions & 0 deletions docs/langcheck.metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ There are several different types of metrics:
| | | |
| | ``rouge2(generated_outputs, reference_outputs)`` | |
+---------------------------------------------+----------------------------------------------------------------------------+----------------+
| :ref:`query-based-text-quality-metrics` | ``answer_relevance(generated_outputs, prompts)`` | EN, JA |
| | | |
| | ``answer_safety(generated_outputs, prompts)`` | |
+---------------------------------------------+----------------------------------------------------------------------------+----------------+
| :ref:`source-based-text-quality-metrics` | ``factual_consistency(generated_outputs, sources)`` | EN, JA, DE, ZH |
+---------------------------------------------+----------------------------------------------------------------------------+----------------+
| :ref:`text-structure-metrics` | ``is_float(generated_outputs, min=0, max=None)`` | All Languages |
Expand Down Expand Up @@ -67,6 +71,7 @@ There are several different types of metrics:
:hidden:
:maxdepth: 4

langcheck.metrics.custom_text_quality
langcheck.metrics.metric_value
langcheck.metrics.reference_based_text_quality
langcheck.metrics.text_structure
8 changes: 8 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ LangCheck metrics are categorized by metric type, which correspond to the kind o
| [Reference-Free Text Quality Metrics](#reference-free-text-quality-metrics) | `toxicity(generated_outputs)`<br>`sentiment(generated_outputs)`<br>`ai_disclaimer_similarity(generated_outputs)` | EN, JA, DE, ZH |
| [Reference-Based Text Quality Metrics](#reference-based-text-quality-metrics) | `semantic_similarity(generated_outputs, reference_outputs)`<br>`rouge2(generated_outputs, reference_outputs)` | EN, JA, DE, ZH |
| [Source-Based Text Quality Metrics](#source-based-text-quality-metrics) | `factual_consistency(generated_outputs, sources)` | EN, JA, DE, ZH |
| [Query-Based Text Quality Metrics](#query-based-text-quality-metrics) | `answer_relevance(generated_outputs, prompts)` | EN, JA |
| [Text Structure Metrics](#text-structure-metrics) | `is_float(generated_outputs, min=0, max=None)`<br>`is_json_object(generated_outputs)` | All Languages |
| [Pairwise Text Quality Metrics](#pairwise-text-quality-metrics) | `pairwise_comparison(generated_outputs_a, generated_outputs_b, prompts)` | EN, JA |

Expand All @@ -70,6 +71,13 @@ Source-based metrics require a "source" text. Sources are inputs, but references

An example metric is {func}`~langcheck.metrics.en.source_based_text_quality.factual_consistency`, which compares the factual consistency between the LLM's generated text and the source text as a score between 0 and 1.

(query-based-text-quality-metrics)=
### Query-Based Text Quality Metrics

Query-based metrics require the input query. For example, in a Q&A application, the query would be the user's question.

An example metric is {func}`~langcheck.metrics.en.query_based_text_quality.answer_relevance`, which computes how relevant the LLM's generated text is with respect to the input query as a score between 0 and 1.

(text-structure-metrics)=
### Text Structure Metrics

Expand Down
Loading