Generation
TestsetGenerator
dataclass
TestsetGenerator(llm: BaseRagasLLM, embedding_model: BaseRagasEmbeddings, 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. |
embedding_model |
BaseRagasEmbeddings
|
Embedding model for generation process. |
knowledge_graph |
KnowledgeGraph, default empty
|
The knowledge graph to use for the generation process. |
from_langchain
classmethod
from_langchain(llm: BaseLanguageModel, embedding_model: Embeddings, 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], testset_size: int, transforms: Optional[Transforms] = None, transforms_llm: Optional[BaseRagasLLM] = None, transforms_embedding_model: Optional[BaseRagasEmbeddings] = 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(testset_size: int, query_distribution: Optional[QueryDistribution] = None, run_config: Optional[RunConfig] = None, callbacks: Optional[Callbacks] = None, token_usage_parser: Optional[TokenUsageParser] = 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 |
---|---|---|---|
testset_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
|
token_usage_parser
|
Optional[TokenUsageParser]
|
Parse the LLMResult object and return a TokenUsage object. This is used to calculate the cost of the generation process. |
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
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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
|