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

feat: Non LLM based context precision #1264

Merged
merged 25 commits into from
Sep 12, 2024

Conversation

shahules786
Copy link
Member

@shahules786 shahules786 commented Sep 10, 2024

  1. Add Non LLM based context precision
  2. Rename and introduce naming convention to metrics - <llm_or_non_llm><metric_name><with_or_without_reference>
from ragas import SingleTurnSample
from ragas.metrics._context_precision import NonLLMContextPrecisionWithReference

context_precision = NonLLMContextPrecisionWithReference()

sample = SingleTurnSample(
    retrieved_contexts=["The Eiffel Tower is located in Paris."], 
    reference_contexts=["Paris is the capital of France.", "The Eiffel Tower is one of the most famous landmarks in Paris."]
)

await context_precision.single_turn_ascore(sample)

shahules786 and others added 17 commits September 9, 2024 16:27
```python
from ragas import evaluate
from ragas.metrics import rubrics_score_without_reference
from ragas.dataset_schema import EvaluationDataset, MultiTurnSample
from ragas.messages import HumanMessage

sample1 = MultiTurnSample(user_input=[HumanMessage(content="What is X")])
sample2 = MultiTurnSample(user_input=[HumanMessage(content="What is X")])
ds = EvaluationDataset(samples=[sample1, sample2])
evaluate(ds,metrics=[rubrics_score_without_reference])
```
Added support for
1. BLEU SCORE
2. ROGUE SCORE
3. STRING MATCH
4. EDIT DISTANCE
```python
from ragas.experimental.metrics._faithfulness import FaithfulnessExperimental, LongFormAnswerPrompt

faithfulness = FaithfulnessExperimental() 
faithfulness.get_prompts()

#{'long_form_answer_prompt': <ragas.experimental.metrics._faithfulness.LongFormAnswerPrompt at 0x7fd7baa8efb0>,
#'nli_statement_prompt': <ragas.experimental.metrics._faithfulness.NLIStatementPrompt at 0x7fd7baa8f010>}

long_form_prompt = LongFormAnswerPrompt()
long_form_prompt.instruction = "my new instruction"

prompts = {"long_form_answer_prompt":long_form_prompt}
faithfulness.set_prompts(**prompts)
```

---------

Co-authored-by: Jithin James <jamesjithin97@gmail.com>
@shahules786 shahules786 marked this pull request as ready for review September 10, 2024 14:12
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 10, 2024
Copy link
Member

@jjmachan jjmachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just the suggestion for doc change

docs/concepts/metrics/context_precision_v2.md Outdated Show resolved Hide resolved
docs/concepts/metrics/context_precision_v2.md Outdated Show resolved Hide resolved
docs/concepts/metrics/context_precision_v2.md Outdated Show resolved Hide resolved
shahules786 and others added 3 commits September 12, 2024 09:21
Co-authored-by: Jithin James <jamesjithin97@gmail.com>
Co-authored-by: Jithin James <jamesjithin97@gmail.com>
Co-authored-by: Jithin James <jamesjithin97@gmail.com>
@shahules786 shahules786 merged commit 196127e into explodinggradients:main Sep 12, 2024
15 checks passed
shahules786 added a commit to shahules786/ragas that referenced this pull request Sep 12, 2024
1. Add Non LLM based context precision
2. Rename and introduce naming convention to metrics -
<llm_or_non_llm><metric_name><with_or_without_reference>

```python

from ragas import SingleTurnSample
from ragas.metrics._context_precision import NonLLMContextPrecisionWithReference

context_precision = NonLLMContextPrecisionWithReference()

sample = SingleTurnSample(
    retrieved_contexts=["The Eiffel Tower is located in Paris."], 
    reference_contexts=["Paris is the capital of France.", "The Eiffel Tower is one of the most famous landmarks in Paris."]
)

await context_precision.single_turn_ascore(sample)
```

---------

Co-authored-by: Jithin James <jamesjithin97@gmail.com>
shahules786 added a commit to shahules786/ragas that referenced this pull request Sep 12, 2024
1. Add Non LLM based context precision
2. Rename and introduce naming convention to metrics -
<llm_or_non_llm><metric_name><with_or_without_reference>

```python

from ragas import SingleTurnSample
from ragas.metrics._context_precision import NonLLMContextPrecisionWithReference

context_precision = NonLLMContextPrecisionWithReference()

sample = SingleTurnSample(
    retrieved_contexts=["The Eiffel Tower is located in Paris."], 
    reference_contexts=["Paris is the capital of France.", "The Eiffel Tower is one of the most famous landmarks in Paris."]
)

await context_precision.single_turn_ascore(sample)
```

---------

Co-authored-by: Jithin James <jamesjithin97@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants