ragas 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ragas-0.2.2 → ragas-0.2.3}/DEVELOPMENT.md +6 -0
- {ragas-0.2.2 → ragas-0.2.3}/Makefile +22 -19
- {ragas-0.2.2/src/ragas.egg-info → ragas-0.2.3}/PKG-INFO +2 -2
- {ragas-0.2.2 → ragas-0.2.3}/docs/community/index.md +3 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/agents.md +6 -5
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/index.md +3 -1
- ragas-0.2.3/docs/concepts/metrics/available_metrics/multi_modal_faithfulness.md +50 -0
- ragas-0.2.3/docs/concepts/metrics/available_metrics/multi_modal_relevance.md +50 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/getstarted/rag_testset_generation.md +1 -1
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/applications/_cost.md +65 -6
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/applications/cost.ipynb +120 -16
- {ragas-0.2.2 → ragas-0.2.3}/pyproject.toml +1 -1
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/_version.py +2 -2
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/dataset_schema.py +10 -6
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/evaluation.py +3 -3
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/exceptions.py +2 -4
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/__init__.py +15 -11
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_answer_correctness.py +8 -1
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_context_precision.py +7 -3
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_factual_correctness.py +45 -11
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_goal_accuracy.py +6 -0
- ragas-0.2.3/src/ragas/metrics/_multi_modal_faithfulness.py +98 -0
- ragas-0.2.3/src/ragas/metrics/_multi_modal_relevance.py +106 -0
- ragas-0.2.2/src/ragas/metrics/_rogue_score.py → ragas-0.2.3/src/ragas/metrics/_rouge_score.py +3 -3
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_tool_call_accuracy.py +2 -2
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_topic_adherence.py +6 -1
- ragas-0.2.3/src/ragas/metrics/utils.py +22 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/prompt/__init__.py +3 -0
- ragas-0.2.3/src/ragas/prompt/multi_modal_prompt.py +214 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/prompt/pydantic_prompt.py +13 -11
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/synthesizers/base_query.py +5 -2
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/synthesizers/generate.py +81 -20
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/synthesizers/specific_query.py +2 -2
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/synthesizers/testset_schema.py +31 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/engine.py +4 -0
- {ragas-0.2.2 → ragas-0.2.3/src/ragas.egg-info}/PKG-INFO +2 -2
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas.egg-info/SOURCES.txt +6 -1
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_dataset_schema.py +4 -2
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_metric.py +1 -15
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_prompt.py +23 -0
- ragas-0.2.2/src/ragas/metrics/utils.py +0 -21
- {ragas-0.2.2 → ragas-0.2.3}/.dockerignore +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/.gitattributes +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/.github/ISSUE_TEMPLATE/question.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/.github/workflows/ci.yaml +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/.github/workflows/issue-manager.yaml +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/.github/workflows/python-publish.yml +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/.gitignore +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/.readthedocs.yml +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/LICENSE +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/README.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/Makefile +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/css/highlight_ipython3.css +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/css/highlight_ipython3_dark.css +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/css/highlight_ipython3_light.css +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/css/highlight_python.css +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/css/highlight_python_dark.css +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/css/highlight_python_light.css +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/css/ragas.css +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/favicon.ico +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/bar-graph.svg +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/compare-emb-results.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/compare-embeddings.jpeg +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/compare-llm-result.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/compare-llms-front.jpeg +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/compare-llms-testset.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/component-wise-metrics.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/eval-evolve.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/kg_rag.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/langsmith-tracing-faithfullness.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/langsmith-tracing-overview.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/logo-black.svg +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/logo.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/metrics_mindmap.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/question_types.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/quickstart-output.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/ragas-logo.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/ragas_workflow_white.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/scenario_rag.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/testset_output.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/imgs/trace-langsmith.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/js/header_border.js +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/js/mathjax.js +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/js/mendable_chat_bubble.js +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/js/octolane.js +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/js/toggle.js +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/langsmith-dataset.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/langsmith-evaluation.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/langsmith-feedback.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/langsmith-ragas-chain-trace.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/list-score-traces-ragas.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/_static/traces-score-ragas.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/alfred.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/components/eval_dataset.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/components/eval_sample.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/components/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/components/prompt.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/feedback/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/answer_correctness.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/answer_relevance.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/aspect_critic.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/context_entities_recall.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/context_precision.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/context_recall.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/factual_correctness.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/faithfulness.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/general_purpose.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/noise_sensitivity.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/rubrics_based.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/semantic_similarity.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/sql.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/summarization_score.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/available_metrics/traditional.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/metrics/overview/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/test_data_generation/agents.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/test_data_generation/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/concepts/test_data_generation/rag.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/conf.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/extra/components/choose_evaluator_llm.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/extra/components/choose_generator_llm.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/extra/fonts/Satoshi-Variable.ttf +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/extra/fonts/Satoshi-VariableItalic.ttf +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/extra/style.css +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/getstarted/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/getstarted/install.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/getstarted/rag_evaluation.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/getstarted/raga_evaluation_output.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/getstarted/testset_output.png +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/applications/add_to_ci.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/applications/compare_embeddings.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/applications/compare_llms.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/applications/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/_run_config.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/customize_models.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/metrics/_metrics_language_adaptation.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/metrics/_modifying-prompts-metrics.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/metrics/_write_your_own_metric.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/metrics/metrics_language_adaptation.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/metrics/modifying-prompts-metrics.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/metrics/tracing.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/metrics/write_your_own_metric.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/run_config.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/customizations/testgenerator/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_arize.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_athina.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_haystack.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_helicone.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_langchain.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_langfuse.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_langsmith.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_llamaindex.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_openlayer.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_opik.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_tonic-validate.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/_zeno.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/arize.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/athina.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/haystack.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/helicone.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/langchain.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/langfuse.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/langsmith.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/llamaindex.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/nyc_wikipedia/nyc_text.txt +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/openlayer.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/opik.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/tonic-validate.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/integrations/zeno.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/howtos/migrations/migrate_from_v01_to_v02.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/index.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/make.bat +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/embeddings.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/evaluate.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/evaluation_schema.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/executor.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/generate.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/graph.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/integrations.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/llms.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/metrics.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/prompt.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/run_config.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/synthesizers.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/testset_schema.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/docs/references/transforms.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/mkdocs.yml +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/references.md +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/requirements/dev.txt +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/requirements/docs.txt +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/requirements/test.txt +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/scripts/ipynb_to_md.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/setup.cfg +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/_analytics.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/async_utils.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/callbacks.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/cost.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/embeddings/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/embeddings/base.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/executor.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/experimental/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/integrations/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/integrations/helicone.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/integrations/langchain.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/integrations/langsmith.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/integrations/llama_index.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/integrations/opik.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/llms/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/llms/base.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/messages.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_answer_relevance.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_answer_similarity.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_aspect_critic.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_bleu_score.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_context_entities_recall.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_context_recall.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_datacompy_score.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_domain_specific_rubrics.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_faithfulness.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_instance_specific_rubrics.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_noise_sensitivity.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_simple_criteria.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_sql_semantic_equivalence.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_string.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/_summarization.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/metrics/base.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/prompt/base.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/prompt/mixin.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/prompt/utils.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/run_config.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/graph.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/synthesizers/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/synthesizers/abstract_query.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/synthesizers/base.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/synthesizers/prompts.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/synthesizers/utils.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/base.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/default.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/extractors/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/extractors/embeddings.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/extractors/llm_based.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/extractors/regex_based.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/relationship_builders/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/relationship_builders/cosine.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/splitters/__init__.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/testset/transforms/splitters/headline.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/utils.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas/validation.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas.egg-info/dependency_links.txt +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas.egg-info/requires.txt +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/src/ragas.egg-info/top_level.txt +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/benchmarks/Dockerfile +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/benchmarks/benchmark_eval.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/benchmarks/benchmark_testsetgen.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/benchmarks/utils.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/conftest.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/e2e/test_adaptation.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/e2e/test_amnesty_in_ci.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/e2e/test_evaluation_in_jupyter.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/e2e/test_fullflow.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/e2e/test_langsmith.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/e2e/test_testset_gen_in_jupyter.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/llms/test_llm.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/prompt/test_prompt_mixin.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/prompt/test_prompt_utils.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_analytics.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_cost.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_embeddings.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_executor.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_executor_in_jupyter.ipynb +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_import.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_run_config.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_simple.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_testset_schema.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_utils.py +0 -0
- {ragas-0.2.2 → ragas-0.2.3}/tests/unit/test_validation.py +0 -0
|
@@ -21,6 +21,7 @@ This document provides guidelines for developing and contributing to the ragas p
|
|
|
21
21
|
|
|
22
22
|
4. **Install Dependencies**
|
|
23
23
|
```
|
|
24
|
+
pip install -U setuptools # Required on newer Python versions (e.g., 3.11)
|
|
24
25
|
pip install -e ".[dev]"
|
|
25
26
|
```
|
|
26
27
|
|
|
@@ -57,6 +58,11 @@ You can run the following command to check for code style issues:
|
|
|
57
58
|
make run-ci
|
|
58
59
|
```
|
|
59
60
|
|
|
61
|
+
Adding a `V=1` option makes the output more verbose, showing normally hidden commands, like so:
|
|
62
|
+
```bash
|
|
63
|
+
make run-ci V=1
|
|
64
|
+
```
|
|
65
|
+
|
|
60
66
|
## Running Tests
|
|
61
67
|
|
|
62
68
|
To run the test suite:
|
|
@@ -1,56 +1,59 @@
|
|
|
1
1
|
GIT_ROOT ?= $(shell git rev-parse --show-toplevel)
|
|
2
2
|
|
|
3
|
+
# Optionally show commands being executed with V=1
|
|
4
|
+
Q := $(if $(V),,@)
|
|
5
|
+
|
|
3
6
|
help: ## Show all Makefile targets
|
|
4
|
-
|
|
7
|
+
$(Q)grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'
|
|
5
8
|
|
|
6
9
|
.PHONY: format lint type style clean run-benchmarks
|
|
7
10
|
format: ## Running code formatter: black and isort
|
|
8
11
|
@echo "(isort) Ordering imports..."
|
|
9
|
-
|
|
12
|
+
$(Q)isort .
|
|
10
13
|
@echo "(black) Formatting codebase..."
|
|
11
|
-
|
|
14
|
+
$(Q)black --config pyproject.toml src tests docs
|
|
12
15
|
@echo "(black) Formatting stubs..."
|
|
13
|
-
|
|
16
|
+
$(Q)find src -name "*.pyi" ! -name "*_pb2*" -exec black --pyi --config pyproject.toml {} \;
|
|
14
17
|
@echo "(ruff) Running fix only..."
|
|
15
|
-
|
|
18
|
+
$(Q)ruff check src docs tests --fix-only
|
|
16
19
|
lint: ## Running lint checker: ruff
|
|
17
20
|
@echo "(ruff) Linting development project..."
|
|
18
|
-
|
|
21
|
+
$(Q)ruff check src docs tests
|
|
19
22
|
type: ## Running type checker: pyright
|
|
20
23
|
@echo "(pyright) Typechecking codebase..."
|
|
21
24
|
PYRIGHT_PYTHON_FORCE_VERSION=latest pyright src/ragas
|
|
22
25
|
clean: ## Clean all generated files
|
|
23
26
|
@echo "Cleaning all generated files..."
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
$(Q)cd $(GIT_ROOT)/docs && $(MAKE) clean
|
|
28
|
+
$(Q)cd $(GIT_ROOT) || exit 1
|
|
29
|
+
$(Q)find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
|
|
27
30
|
test: ## Run tests
|
|
28
31
|
@echo "Running tests..."
|
|
29
|
-
|
|
32
|
+
$(Q)pytest --nbmake tests/unit $(shell if [ -n "$(k)" ]; then echo "-k $(k)"; fi)
|
|
30
33
|
test-e2e: ## Run end2end tests
|
|
31
34
|
echo "running end2end tests..."
|
|
32
|
-
|
|
35
|
+
$(Q)pytest --nbmake tests/e2e -s
|
|
33
36
|
run-ci: format lint type test ## Running all CI checks
|
|
34
37
|
|
|
35
38
|
# Docs
|
|
36
39
|
rewrite-docs: ## Use GPT4 to rewrite the documentation
|
|
37
40
|
@echo "Rewriting the documentation in directory $(DIR)..."
|
|
38
|
-
|
|
41
|
+
$(Q)python $(GIT_ROOT)/docs/python alphred.py --directory $(DIR)
|
|
39
42
|
ipynb-to-md: ## Convert ipynb files to md files
|
|
40
|
-
|
|
43
|
+
$(Q)python $(GIT_ROOT)/scripts/ipynb_to_md.py
|
|
41
44
|
docsite: ## Build and serve documentation
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
$(Q)$(MAKE) ipynb-to-md
|
|
46
|
+
$(Q)mkdocs serve
|
|
44
47
|
|
|
45
48
|
# Benchmarks
|
|
46
49
|
run-benchmarks-eval: ## Run benchmarks for Evaluation
|
|
47
50
|
@echo "Running benchmarks for Evaluation..."
|
|
48
|
-
|
|
51
|
+
$(Q)cd $(GIT_ROOT)/tests/benchmarks && python benchmark_eval.py
|
|
49
52
|
run-benchmarks-testset: ## Run benchmarks for TestSet Generation
|
|
50
53
|
@echo "Running benchmarks for TestSet Generation..."
|
|
51
|
-
|
|
54
|
+
$(Q)cd $(GIT_ROOT)/tests/benchmarks && python benchmark_testsetgen.py
|
|
52
55
|
run-benchmarks-in-docker: ## Run benchmarks in docker
|
|
53
56
|
@echo "Running benchmarks in docker..."
|
|
54
|
-
|
|
55
|
-
docker buildx build --build-arg OPENAI_API_KEY=$(OPENAI_API_KEY) -t ragas-benchmark -f $(GIT_ROOT)/tests/benchmarks/Dockerfile .
|
|
57
|
+
$(Q)cd $(GIT_ROOT)
|
|
58
|
+
docker buildx build --build-arg OPENAI_API_KEY=$(OPENAI_API_KEY) -t ragas-benchmark -f $(GIT_ROOT)/tests/benchmarks/Dockerfile .
|
|
56
59
|
docker inspect ragas-benchmark:latest | jq ".[0].Size" | numfmt --to=si
|
|
@@ -16,6 +16,9 @@ Meet some of our outstanding members who made significant contributions !
|
|
|
16
16
|
|
|
17
17
|
Explore insightful articles, tutorials, and stories written by and for our community members.
|
|
18
18
|
|
|
19
|
+
- [Luka Panić](https://www.linkedin.com/in/luka-pani%C4%87-20b671277/) shares his work on
|
|
20
|
+
- [Ragas Evaluation: In-Depth Insights | PIXION Blog](https://pixion.co/blog/ragas-evaluation-in-depth-insights): A detailed explanation of the metrics and how they are calculated.
|
|
21
|
+
- [RAG in practice - Test Set Generation | PIXION Blog](https://pixion.co/blog/rag-in-practice-test-set-generation): A tutorial on how to generate a test set using Ragas.
|
|
19
22
|
- [Shanthi Vardhan](https://www.linkedin.com/in/shanthivardhan/) shares how his team at [Atomicwork uses ragas](https://www.atomicwork.com/blog/ragas-improving-atom-accuracy) to improve their AI system's ability to accurately identify and retrieve more precise information for enhanced service management.
|
|
20
23
|
- [Pinecone's](https://pinecone.io/blog) study on how RAGs can enhance capabilities of LLMs in ["RAG makes LLMs better and equal"](https://www.pinecone.io/blog/rag-study/) uses ragas to proves context retrieval makes LLMs provide significantly better results, even when increasing the data size to 1 billion.
|
|
21
24
|
- [Aishwarya Prabhat](https://www.linkedin.com/in/aishwaryaprabhat/) shares her expertise on advanced RAG techniques in her comprehensive guide, ["Performing, Evaluating & Tracking Advanced RAG (ft. AzureML, LlamaIndex & Ragas)"](https://www.linkedin.com/pulse/performing-evaluating-tracking-advanced-rag-ft-azureml-prabhat-i1rkc/).
|
|
@@ -71,10 +71,9 @@ scorer = TopicAdherenceScore(mode="recall")
|
|
|
71
71
|
`ToolCallAccuracy` is a metric that can be used to evaluate the performance of the LLM in identifying and calling the required tools to complete a given task. This metric needs `user_input` and `reference_tool_calls` to evaluate the performance of the LLM in identifying and calling the required tools to complete a given task. The metric is computed by comparing the `reference_tool_calls` with the Tool calls made by the AI. The values range between 0 and 1, with higher values indicating better performance.
|
|
72
72
|
|
|
73
73
|
```python
|
|
74
|
+
from ragas.metrics import ToolCallAccuracy
|
|
74
75
|
from ragas.dataset_schema import MultiTurnSample
|
|
75
76
|
from ragas.messages import HumanMessage,AIMessage,ToolMessage,ToolCall
|
|
76
|
-
from ragas.metrics import ToolCallAccuracy
|
|
77
|
-
|
|
78
77
|
|
|
79
78
|
sample = [
|
|
80
79
|
HumanMessage(content="What's the weather like in New York right now?"),
|
|
@@ -89,7 +88,7 @@ sample = [
|
|
|
89
88
|
AIMessage(content="75°F is approximately 23.9°C.")
|
|
90
89
|
]
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
sample = MultiTurnSample(
|
|
93
92
|
user_input=sample,
|
|
94
93
|
reference_tool_calls=[
|
|
95
94
|
ToolCall(name="weather_check", args={"location": "New York"}),
|
|
@@ -98,7 +97,8 @@ sampl2 = MultiTurnSample(
|
|
|
98
97
|
)
|
|
99
98
|
|
|
100
99
|
scorer = ToolCallAccuracy()
|
|
101
|
-
|
|
100
|
+
scorer.llm = your_llm
|
|
101
|
+
await scorer.multi_turn_ascore(sample)
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
The tool call sequence specified in `reference_tool_calls` is used as the ideal outcome. If the tool calls made by the AI does not the the order or sequence of the `reference_tool_calls`, the metric will return a score of 0. This helps to ensure that the AI is able to identify and call the required tools in the correct order to complete a given task.
|
|
@@ -147,7 +147,8 @@ sample = MultiTurnSample(user_input=[
|
|
|
147
147
|
reference="Table booked at one of the chinese restaurants at 8 pm")
|
|
148
148
|
|
|
149
149
|
scorer = AgentGoalAccuracyWithReference()
|
|
150
|
-
|
|
150
|
+
scorer.llm = your_llm
|
|
151
|
+
await scorer.multi_turn_ascore(sample)
|
|
151
152
|
|
|
152
153
|
```
|
|
153
154
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Ragas provides a set of evaluation metrics that can be used to measure the performance of your LLM application. These metrics are designed to help you objectively measure the performance of your application. Metrics are available for different applications and tasks, such as RAG and Agentic workflows.
|
|
4
4
|
|
|
5
|
-
Each metric are essentially paradigms that
|
|
5
|
+
Each metric are essentially paradigms that are designed to evaluate a particular aspect of the application. LLM Based metrics might use one or more LLM calls to arrive at the score or result. One can also modify or write your own metrics using ragas.
|
|
6
6
|
|
|
7
7
|
## Retrieval Augmented Generation
|
|
8
8
|
- [Context Precision](context_precision.md)
|
|
@@ -11,6 +11,8 @@ Each metric are essentially paradigms that is designed to evaluate a particular
|
|
|
11
11
|
- [Noise Sensitivity](noise_sensitivity.md)
|
|
12
12
|
- [Response Relevancy](answer_relevance.md)
|
|
13
13
|
- [Faithfulness](faithfulness.md)
|
|
14
|
+
- [Multimodal Faithfulness](multi_modal_faithfulness.md)
|
|
15
|
+
- [Multimodal Relevance](multi_modal_relevance.md)
|
|
14
16
|
|
|
15
17
|
## Agents or Tool use cases
|
|
16
18
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
## MultiModalFaithfulness
|
|
2
|
+
|
|
3
|
+
`MultiModalFaithfulness` metric measures the factual consistency of the generated answer against both visual and textual context. It is calculated from the answer, retrieved textual context, and visual context. The answer is scaled to a (0,1) range, with higher scores indicating better faithfulness.
|
|
4
|
+
|
|
5
|
+
The generated answer is regarded as faithful if all the claims made in the answer can be inferred from either the visual or textual context provided. To determine this, the response is directly evaluated against the provided contexts, and the faithfulness score is either 0 or 1.
|
|
6
|
+
|
|
7
|
+
### Example
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from ragas.database_schema import SingleTurnSample
|
|
11
|
+
from ragas.metrics import MultiModalFaithfulness
|
|
12
|
+
|
|
13
|
+
sample = SingleTurnSample(
|
|
14
|
+
user_input="What about the Tesla Model X?",
|
|
15
|
+
response="Cats are cute.",
|
|
16
|
+
retrieved_contexts=[
|
|
17
|
+
"custom_eval/multimodal/images/tesla.jpg"
|
|
18
|
+
]
|
|
19
|
+
)
|
|
20
|
+
scorer = MultiModalFaithfulness()
|
|
21
|
+
await scorer.single_turn_ascore(sample)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### How It’s Calculated
|
|
25
|
+
|
|
26
|
+
!!! example
|
|
27
|
+
**Question**: What about the Tesla Model X?
|
|
28
|
+
|
|
29
|
+
**Context (visual)**:
|
|
30
|
+
- An image of the Tesla Model X (custom_eval/multimodal/images/tesla.jpg)
|
|
31
|
+
|
|
32
|
+
**High faithfulness answer**: The Tesla Model X is an electric SUV manufactured by Tesla.
|
|
33
|
+
|
|
34
|
+
**Low faithfulness answer**: Cats are cute.
|
|
35
|
+
|
|
36
|
+
Let's examine how faithfulness was calculated using the low faithfulness answer:
|
|
37
|
+
|
|
38
|
+
- **Step 1:** Evaluate the generated response against the given contexts.
|
|
39
|
+
- Response: "Cats are cute."
|
|
40
|
+
|
|
41
|
+
- **Step 2:** Verify if the response can be inferred from the given context.
|
|
42
|
+
- Response: No
|
|
43
|
+
|
|
44
|
+
- **Step 3:** Use the result to determine the faithfulness score.
|
|
45
|
+
|
|
46
|
+
$$
|
|
47
|
+
\text{Faithfulness} = 0
|
|
48
|
+
$$
|
|
49
|
+
|
|
50
|
+
In this example, the response "Cats are cute" cannot be inferred from the image of the Tesla Model X, so the faithfulness score is 0.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
## MultiModalRelevance
|
|
2
|
+
|
|
3
|
+
`MultiModalRelevance` metric measures the relevance of the generated answer against both visual and textual context. It is calculated from the user input, response, and retrieved contexts (both visual and textual). The answer is scaled to a (0,1) range, with higher scores indicating better relevance.
|
|
4
|
+
|
|
5
|
+
The generated answer is regarded as relevant if it aligns with the visual or textual context provided. To determine this, the response is directly evaluated against the provided contexts, and the relevance score is either 0 or 1.
|
|
6
|
+
|
|
7
|
+
### Example
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from ragas.database_schema import SingleTurnSample
|
|
11
|
+
from ragas.metrics import MultiModalRelevance
|
|
12
|
+
|
|
13
|
+
sample = SingleTurnSample(
|
|
14
|
+
user_input="What about the Tesla Model X?",
|
|
15
|
+
response="Cats are cute.",
|
|
16
|
+
retrieved_contexts=[
|
|
17
|
+
"custom_eval/multimodal/images/tesla.jpg"
|
|
18
|
+
]
|
|
19
|
+
)
|
|
20
|
+
scorer = MultiModalRelevance()
|
|
21
|
+
await scorer.single_turn_ascore(sample)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### How It’s Calculated
|
|
25
|
+
|
|
26
|
+
!!! example
|
|
27
|
+
**Question**: What about the Tesla Model X?
|
|
28
|
+
|
|
29
|
+
**Context (visual)**:
|
|
30
|
+
- An image of the Tesla Model X (custom_eval/multimodal/images/tesla.jpg)
|
|
31
|
+
|
|
32
|
+
**High relevance answer**: The Tesla Model X is an electric SUV manufactured by Tesla.
|
|
33
|
+
|
|
34
|
+
**Low relevance answer**: Cats are cute.
|
|
35
|
+
|
|
36
|
+
Let's examine how relevance was calculated using the low relevance answer:
|
|
37
|
+
|
|
38
|
+
- **Step 1:** Evaluate the generated response against the given contexts.
|
|
39
|
+
- Response: "Cats are cute."
|
|
40
|
+
|
|
41
|
+
- **Step 2:** Verify if the response aligns with the given context.
|
|
42
|
+
- Response: No
|
|
43
|
+
|
|
44
|
+
- **Step 3:** Use the result to determine the relevance score.
|
|
45
|
+
|
|
46
|
+
$$
|
|
47
|
+
\text{Relevance} = 0
|
|
48
|
+
$$
|
|
49
|
+
|
|
50
|
+
In this example, the response "Cats are cute" does not align with the image of the Tesla Model X, so the relevance score is 0.
|
|
@@ -99,7 +99,7 @@ Now we will enrich the knowledge graph with additional information using [Transf
|
|
|
99
99
|
But you can mix and match transforms or build your own as needed.
|
|
100
100
|
|
|
101
101
|
```python
|
|
102
|
-
from ragas.testset.transforms import default_transforms
|
|
102
|
+
from ragas.testset.transforms import default_transforms, apply_transforms
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
# define your LLM and Embedding Model
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# How to estimate Cost and Usage of evaluations
|
|
1
|
+
# How to estimate Cost and Usage of evaluations and testset generation
|
|
2
2
|
|
|
3
3
|
When using LLMs for evaluation and test set generation, cost will be an important factor. Ragas provides you some tools to help you with that.
|
|
4
4
|
|
|
@@ -34,7 +34,9 @@ get_token_usage_for_openai(llm_result)
|
|
|
34
34
|
|
|
35
35
|
You can define your own or import parsers if they are defined. If you would like to suggest parser for LLM providers or contribute your own ones please check out this [issue](https://github.com/explodinggradients/ragas/issues/1151) 🙂.
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
## Token Usage for Evaluations
|
|
38
|
+
|
|
39
|
+
Let's use the `get_token_usage_for_openai` parser to calculate the token usage for an evaluation.
|
|
38
40
|
|
|
39
41
|
|
|
40
42
|
```python
|
|
@@ -43,9 +45,14 @@ from datasets import load_dataset
|
|
|
43
45
|
|
|
44
46
|
dataset = load_dataset("explodinggradients/amnesty_qa", "english_v3")
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
eval_dataset = EvaluationDataset.from_hf_dataset(dataset["eval"])
|
|
47
49
|
```
|
|
48
50
|
|
|
51
|
+
Repo card metadata block was not found. Setting CardData to empty.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
You can pass in the parser to the `evaluate()` function and the cost will be calculated and returned in the `Result` object.
|
|
55
|
+
|
|
49
56
|
|
|
50
57
|
```python
|
|
51
58
|
from ragas import evaluate
|
|
@@ -54,7 +61,7 @@ from ragas.metrics import LLMContextRecall
|
|
|
54
61
|
from ragas.cost import get_token_usage_for_openai
|
|
55
62
|
|
|
56
63
|
result = evaluate(
|
|
57
|
-
|
|
64
|
+
eval_dataset,
|
|
58
65
|
metrics=[LLMContextRecall()],
|
|
59
66
|
llm=gpt4o,
|
|
60
67
|
token_usage_parser=get_token_usage_for_openai,
|
|
@@ -62,7 +69,7 @@ result = evaluate(
|
|
|
62
69
|
```
|
|
63
70
|
|
|
64
71
|
|
|
65
|
-
Evaluating: 0%| | 0/
|
|
72
|
+
Evaluating: 0%| | 0/20 [00:00<?, ?it/s]
|
|
66
73
|
|
|
67
74
|
|
|
68
75
|
|
|
@@ -73,7 +80,7 @@ result.total_tokens()
|
|
|
73
80
|
|
|
74
81
|
|
|
75
82
|
|
|
76
|
-
TokenUsage(input_tokens=
|
|
83
|
+
TokenUsage(input_tokens=25097, output_tokens=3757, model='')
|
|
77
84
|
|
|
78
85
|
|
|
79
86
|
|
|
@@ -92,3 +99,55 @@ result.total_cost(cost_per_input_token=5 / 1e6, cost_per_output_token=15 / 1e6)
|
|
|
92
99
|
1.1692900000000002
|
|
93
100
|
|
|
94
101
|
|
|
102
|
+
|
|
103
|
+
## Token Usage for Testset Generation
|
|
104
|
+
|
|
105
|
+
You can use the same parser for testset generation but you need to pass in the `token_usage_parser` to the `generate()` function. For now it only calculates the cost for the generation process and not the cost for the transforms.
|
|
106
|
+
|
|
107
|
+
For an example let's load an existing KnowledgeGraph and generate a testset. If you want to know more about how to generate a testset please check out the [testset generation](../../getstarted/rag_testset_generation.md#a-deeper-look).
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from ragas.testset.graph import KnowledgeGraph
|
|
112
|
+
|
|
113
|
+
# loading an existing KnowledgeGraph
|
|
114
|
+
# make sure to change the path to the location of the KnowledgeGraph file
|
|
115
|
+
kg = KnowledgeGraph.load("../../../experiments/scratchpad_kg.json")
|
|
116
|
+
kg
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
KnowledgeGraph(nodes: 47, relationships: 109)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
### Choose your LLM
|
|
127
|
+
|
|
128
|
+
--8<--
|
|
129
|
+
choose_generator_llm.md
|
|
130
|
+
--8<--
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from ragas.testset import TestsetGenerator
|
|
135
|
+
from ragas.llms import llm_factory
|
|
136
|
+
|
|
137
|
+
tg = TestsetGenerator(llm=llm_factory(), knowledge_graph=kg)
|
|
138
|
+
# generating a testset
|
|
139
|
+
testset = tg.generate(testset_size=10, token_usage_parser=get_token_usage_for_openai)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
# total cost for the generation process
|
|
145
|
+
testset.total_cost(cost_per_input_token=5 / 1e6, cost_per_output_token=15 / 1e6)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
0.20967000000000002
|
|
152
|
+
|
|
153
|
+
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"cell_type": "markdown",
|
|
5
5
|
"metadata": {},
|
|
6
6
|
"source": [
|
|
7
|
-
"# How to estimate Cost and Usage of evaluations\n",
|
|
7
|
+
"# How to estimate Cost and Usage of evaluations and testset generation\n",
|
|
8
8
|
"\n",
|
|
9
9
|
"When using LLMs for evaluation and test set generation, cost will be an important factor. Ragas provides you some tools to help you with that."
|
|
10
10
|
]
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
"cell_type": "code",
|
|
27
|
-
"execution_count":
|
|
27
|
+
"execution_count": 2,
|
|
28
28
|
"metadata": {},
|
|
29
29
|
"outputs": [
|
|
30
30
|
{
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"TokenUsage(input_tokens=9, output_tokens=9, model='')"
|
|
34
34
|
]
|
|
35
35
|
},
|
|
36
|
-
"execution_count":
|
|
36
|
+
"execution_count": 2,
|
|
37
37
|
"metadata": {},
|
|
38
38
|
"output_type": "execute_result"
|
|
39
39
|
}
|
|
@@ -56,39 +56,61 @@
|
|
|
56
56
|
"cell_type": "markdown",
|
|
57
57
|
"metadata": {},
|
|
58
58
|
"source": [
|
|
59
|
-
"You can define your own or import parsers if they are defined. If you would like to suggest parser for LLM providers or contribute your own ones please check out this [issue](https://github.com/explodinggradients/ragas/issues/1151)
|
|
59
|
+
"You can define your own or import parsers if they are defined. If you would like to suggest parser for LLM providers or contribute your own ones please check out this [issue](https://github.com/explodinggradients/ragas/issues/1151) 🙂."
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"cell_type": "markdown",
|
|
64
|
+
"metadata": {},
|
|
65
|
+
"source": [
|
|
66
|
+
"## Token Usage for Evaluations\n",
|
|
60
67
|
"\n",
|
|
61
|
-
"
|
|
68
|
+
"Let's use the `get_token_usage_for_openai` parser to calculate the token usage for an evaluation."
|
|
62
69
|
]
|
|
63
70
|
},
|
|
64
71
|
{
|
|
65
72
|
"cell_type": "code",
|
|
66
|
-
"execution_count":
|
|
73
|
+
"execution_count": 8,
|
|
67
74
|
"metadata": {},
|
|
68
|
-
"outputs": [
|
|
75
|
+
"outputs": [
|
|
76
|
+
{
|
|
77
|
+
"name": "stderr",
|
|
78
|
+
"output_type": "stream",
|
|
79
|
+
"text": [
|
|
80
|
+
"Repo card metadata block was not found. Setting CardData to empty.\n"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
],
|
|
69
84
|
"source": [
|
|
70
85
|
"from ragas import EvaluationDataset\n",
|
|
71
86
|
"from datasets import load_dataset\n",
|
|
72
87
|
"\n",
|
|
73
88
|
"dataset = load_dataset(\"explodinggradients/amnesty_qa\", \"english_v3\")\n",
|
|
74
89
|
"\n",
|
|
75
|
-
"
|
|
90
|
+
"eval_dataset = EvaluationDataset.from_hf_dataset(dataset[\"eval\"])"
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"cell_type": "markdown",
|
|
95
|
+
"metadata": {},
|
|
96
|
+
"source": [
|
|
97
|
+
"You can pass in the parser to the `evaluate()` function and the cost will be calculated and returned in the `Result` object."
|
|
76
98
|
]
|
|
77
99
|
},
|
|
78
100
|
{
|
|
79
101
|
"cell_type": "code",
|
|
80
|
-
"execution_count":
|
|
102
|
+
"execution_count": 9,
|
|
81
103
|
"metadata": {},
|
|
82
104
|
"outputs": [
|
|
83
105
|
{
|
|
84
106
|
"data": {
|
|
85
107
|
"application/vnd.jupyter.widget-view+json": {
|
|
86
|
-
"model_id": "
|
|
108
|
+
"model_id": "c9cf15f7bae64320b2bc389b98321a37",
|
|
87
109
|
"version_major": 2,
|
|
88
110
|
"version_minor": 0
|
|
89
111
|
},
|
|
90
112
|
"text/plain": [
|
|
91
|
-
"Evaluating: 0%| | 0/
|
|
113
|
+
"Evaluating: 0%| | 0/20 [00:00<?, ?it/s]"
|
|
92
114
|
]
|
|
93
115
|
},
|
|
94
116
|
"metadata": {},
|
|
@@ -102,7 +124,7 @@
|
|
|
102
124
|
"from ragas.cost import get_token_usage_for_openai\n",
|
|
103
125
|
"\n",
|
|
104
126
|
"result = evaluate(\n",
|
|
105
|
-
"
|
|
127
|
+
" eval_dataset,\n",
|
|
106
128
|
" metrics=[LLMContextRecall()],\n",
|
|
107
129
|
" llm=gpt4o,\n",
|
|
108
130
|
" token_usage_parser=get_token_usage_for_openai,\n",
|
|
@@ -111,16 +133,16 @@
|
|
|
111
133
|
},
|
|
112
134
|
{
|
|
113
135
|
"cell_type": "code",
|
|
114
|
-
"execution_count":
|
|
136
|
+
"execution_count": 10,
|
|
115
137
|
"metadata": {},
|
|
116
138
|
"outputs": [
|
|
117
139
|
{
|
|
118
140
|
"data": {
|
|
119
141
|
"text/plain": [
|
|
120
|
-
"TokenUsage(input_tokens=
|
|
142
|
+
"TokenUsage(input_tokens=25097, output_tokens=3757, model='')"
|
|
121
143
|
]
|
|
122
144
|
},
|
|
123
|
-
"execution_count":
|
|
145
|
+
"execution_count": 10,
|
|
124
146
|
"metadata": {},
|
|
125
147
|
"output_type": "execute_result"
|
|
126
148
|
}
|
|
@@ -157,6 +179,88 @@
|
|
|
157
179
|
"source": [
|
|
158
180
|
"result.total_cost(cost_per_input_token=5 / 1e6, cost_per_output_token=15 / 1e6)"
|
|
159
181
|
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"cell_type": "markdown",
|
|
185
|
+
"metadata": {},
|
|
186
|
+
"source": [
|
|
187
|
+
"## Token Usage for Testset Generation\n",
|
|
188
|
+
"\n",
|
|
189
|
+
"You can use the same parser for testset generation but you need to pass in the `token_usage_parser` to the `generate()` function. For now it only calculates the cost for the generation process and not the cost for the transforms.\n",
|
|
190
|
+
"\n",
|
|
191
|
+
"For an example let's load an existing KnowledgeGraph and generate a testset. If you want to know more about how to generate a testset please check out the [testset generation](../../getstarted/rag_testset_generation.md#a-deeper-look)."
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"cell_type": "code",
|
|
196
|
+
"execution_count": 18,
|
|
197
|
+
"metadata": {},
|
|
198
|
+
"outputs": [
|
|
199
|
+
{
|
|
200
|
+
"data": {
|
|
201
|
+
"text/plain": [
|
|
202
|
+
"KnowledgeGraph(nodes: 47, relationships: 109)"
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
"execution_count": 18,
|
|
206
|
+
"metadata": {},
|
|
207
|
+
"output_type": "execute_result"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"source": [
|
|
211
|
+
"from ragas.testset.graph import KnowledgeGraph\n",
|
|
212
|
+
"\n",
|
|
213
|
+
"# loading an existing KnowledgeGraph\n",
|
|
214
|
+
"# make sure to change the path to the location of the KnowledgeGraph file\n",
|
|
215
|
+
"kg = KnowledgeGraph.load(\"../../../experiments/scratchpad_kg.json\")\n",
|
|
216
|
+
"kg"
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"cell_type": "markdown",
|
|
221
|
+
"metadata": {},
|
|
222
|
+
"source": [
|
|
223
|
+
"### Choose your LLM\n",
|
|
224
|
+
"\n",
|
|
225
|
+
"--8<--\n",
|
|
226
|
+
"choose_generator_llm.md\n",
|
|
227
|
+
"--8<--"
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"cell_type": "code",
|
|
232
|
+
"execution_count": null,
|
|
233
|
+
"metadata": {},
|
|
234
|
+
"outputs": [],
|
|
235
|
+
"source": [
|
|
236
|
+
"from ragas.testset import TestsetGenerator\n",
|
|
237
|
+
"from ragas.llms import llm_factory\n",
|
|
238
|
+
"\n",
|
|
239
|
+
"tg = TestsetGenerator(llm=llm_factory(), knowledge_graph=kg)\n",
|
|
240
|
+
"# generating a testset\n",
|
|
241
|
+
"testset = tg.generate(testset_size=10, token_usage_parser=get_token_usage_for_openai)"
|
|
242
|
+
]
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"cell_type": "code",
|
|
246
|
+
"execution_count": 22,
|
|
247
|
+
"metadata": {},
|
|
248
|
+
"outputs": [
|
|
249
|
+
{
|
|
250
|
+
"data": {
|
|
251
|
+
"text/plain": [
|
|
252
|
+
"0.20967000000000002"
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
"execution_count": 22,
|
|
256
|
+
"metadata": {},
|
|
257
|
+
"output_type": "execute_result"
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
"source": [
|
|
261
|
+
"# total cost for the generation process\n",
|
|
262
|
+
"testset.total_cost(cost_per_input_token=5 / 1e6, cost_per_output_token=15 / 1e6)"
|
|
263
|
+
]
|
|
160
264
|
}
|
|
161
265
|
],
|
|
162
266
|
"metadata": {
|
|
@@ -175,7 +279,7 @@
|
|
|
175
279
|
"name": "python",
|
|
176
280
|
"nbconvert_exporter": "python",
|
|
177
281
|
"pygments_lexer": "ipython3",
|
|
178
|
-
"version": "3.10.
|
|
282
|
+
"version": "3.10.12"
|
|
179
283
|
}
|
|
180
284
|
},
|
|
181
285
|
"nbformat": 4,
|