Skip to content

Commit a13ab02

Browse files
Fix testset generator issue on context selection (#937)
This pull request addresses an issue in the TestsetGenerator where the chosen contexts for evolutions were not being sampled correctly because only the very first contexts were selected. Now, the selection can potentially choose any context Co-authored-by: Jules Decaestecker <[email protected]>
1 parent 6d02a69 commit a13ab02

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ragas/testset/generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import typing as t
55
from dataclasses import dataclass
6-
from random import choices
6+
from random import choices, sample
77

88
import pandas as pd
99
from datasets import Dataset
@@ -242,7 +242,7 @@ def generate(
242242
]
243243
total_evolutions = 0
244244
for evolution, probability in distributions.items():
245-
for i in range(round(probability * test_size)):
245+
for i in sample(range(test_size),round(probability * test_size)):
246246
exec.submit(
247247
evolution.evolve,
248248
current_nodes[i],

0 commit comments

Comments
 (0)