生成
TestsetGenerator
dataclass
TestsetGenerator(
llm: BaseRagasLLM,
knowledge_graph: KnowledgeGraph = KnowledgeGraph(),
)
Generates an evaluation dataset based on given scenarios and parameters.
Attributes:
Name | Type | Description |
---|---|---|
llm |
BaseRagasLLM
|
The language model to use for the generation process. |
knowledge_graph |
KnowledgeGraph, default empty
|
The knowledge graph to use for the generation process. |
from_langchain
classmethod
from_langchain(
llm: BaseLanguageModel,
knowledge_graph: Optional[KnowledgeGraph] = None,
) -> TestsetGenerator
Creates a TestsetGenerator
from a Langchain LLMs.
Source code in src/ragas/testset/synthesizers/generate.py
generate_with_langchain_docs
generate_with_langchain_docs(
documents: Sequence[Document],
test_size: int,
transforms: Optional[Transforms] = None,
query_distribution: Optional[QueryDistribution] = None,
run_config: Optional[RunConfig] = None,
callbacks: Optional[Callbacks] = None,
with_debugging_logs=False,
raise_exceptions: bool = True,
) -> Testset
Generates an evaluation dataset based on given scenarios and parameters.
Source code in src/ragas/testset/synthesizers/generate.py
generate
generate(
test_size: int,
query_distribution: Optional[QueryDistribution] = None,
run_config: Optional[RunConfig] = None,
callbacks: Optional[Callbacks] = None,
with_debugging_logs=False,
raise_exceptions: bool = True,
) -> Testset
Generate an evaluation dataset based on given scenarios and parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_size
|
int
|
The number of samples to generate. |
required |
query_distribution
|
Optional[QueryDistribution]
|
A list of tuples containing scenario simulators and their probabilities. If None, default simulators will be used. |
None
|
callbacks
|
Optional[Callbacks]
|
Langchain style callbacks to use for the generation process. You can use this to log the generation process or add other metadata. |
None
|
run_config
|
Optional[RunConfig]
|
Configuration for running the generation process. |
None
|
with_debugging_logs
|
bool
|
If True, enable debug logging for various components. |
False
|
raise_exceptions
|
bool
|
If True, raise exceptions during the generation process. |
True
|
Returns:
Type | Description |
---|---|
Testset
|
A dataset containing the generated TestsetSamples. |
Notes
This function performs the following steps: 1. Set up scenarios and debug logging if required. 2. Generate scenarios using an Executor. 3. Calculate split values for different scenario types. 4. Generate samples for each scenario. 5. Compile the results into an EvaluationDataset.
Source code in src/ragas/testset/synthesizers/generate.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|