Index
Dataset Module.
BaseLlamaDataExample #
Bases: BaseModel
Base llama dataset example class.
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
65 66 67 68 69 70 71 72 |
|
BaseLlamaDataset #
Bases: BaseModel
, Generic[P]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
examples
|
List[BaseLlamaDataExample]
|
Data examples of this dataset. |
[]
|
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
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 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 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
|
to_pandas
abstractmethod
#
to_pandas() -> Any
Create pandas dataframe.
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
147 148 149 |
|
save_json #
save_json(path: str) -> None
Save json.
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
151 152 153 154 155 156 157 158 159 |
|
from_json
classmethod
#
from_json(path: str) -> BaseLlamaDataset
Load json.
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
161 162 163 164 165 166 167 168 169 170 171 |
|
make_predictions_with #
make_predictions_with(predictor: P, show_progress: bool = False, batch_size: int = 20, sleep_time_in_seconds: int = 0) -> BaseLlamaPredictionDataset
Predict with a given query engine.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predictor
|
PredictorType
|
The predictor to make predictions with. |
required |
show_progress
|
bool
|
Show progress of making predictions. |
False
|
batch_size
|
int
|
Used to batch async calls, especially to reduce chances of hitting RateLimitError from openai. |
20
|
sleep_time_in_seconds
|
int
|
Amount of time to sleep between batch call to reduce chance of hitting RateLimitError from openai. |
0
|
Returns:
Name | Type | Description |
---|---|---|
BaseLlamaPredictionDataset |
BaseLlamaPredictionDataset
|
A dataset of predictions. |
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
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 |
|
amake_predictions_with
async
#
amake_predictions_with(predictor: P, show_progress: bool = False, batch_size: int = 20, sleep_time_in_seconds: int = 1) -> BaseLlamaPredictionDataset
Async predict with a given query engine.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predictor
|
PredictorType
|
The predictor to make predictions with. |
required |
show_progress
|
bool
|
Show progress of making predictions. |
False
|
batch_size
|
int
|
Used to batch async calls, especially to reduce chances of hitting RateLimitError from openai. |
20
|
sleep_time_in_seconds
|
int
|
Amount of time to sleep between batch call to reduce chance of hitting RateLimitError from openai. |
1
|
Returns:
Name | Type | Description |
---|---|---|
BaseLlamaPredictionDataset |
BaseLlamaPredictionDataset
|
A dataset of predictions. |
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
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 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
BaseLlamaExamplePrediction #
Bases: BaseModel
Base llama dataset example class.
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
55 56 57 58 59 60 61 62 |
|
BaseLlamaPredictionDataset #
Bases: BaseModel
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predictions
|
List[BaseLlamaExamplePrediction]
|
Predictions on train_examples. |
[]
|
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 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 |
|
to_pandas
abstractmethod
#
to_pandas() -> Any
Create pandas dataframe.
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
90 91 92 |
|
save_json #
save_json(path: str) -> None
Save json.
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
from_json
classmethod
#
from_json(path: str) -> BaseLlamaPredictionDataset
Load json.
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
CreatedBy #
Bases: BaseModel
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str | None
|
When CreatedByType.AI, specify model name. |
''
|
type
|
CreatedByType
|
|
required |
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
41 42 43 44 45 46 47 48 49 50 51 52 |
|
CreatedByType #
Bases: str
, Enum
The kinds of rag data examples.
Source code in llama-index-core/llama_index/core/llama_dataset/base.py
31 32 33 34 35 36 37 38 |
|
EvaluatorExamplePrediction #
Bases: BaseLlamaExamplePrediction
Evaluation example prediction class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feedback
|
Optional[str]
|
The evaluator's feedback. |
required |
score
|
Optional[float]
|
The evaluator's score. |
required |
invalid_prediction
|
bool
|
Whether or not the prediction is a valid one. |
False
|
invalid_reason
|
str | None
|
Reason as to why prediction is invalid. |
None
|
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
EvaluatorPredictionDataset #
Bases: BaseLlamaPredictionDataset
Evaluation Prediction Dataset Class.
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
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 |
|
to_pandas #
to_pandas() -> Any
Create pandas dataframe.
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
LabelledEvaluatorDataExample #
Bases: BaseLlamaDataExample
Evaluation example class.
This data class contains the ingredients to perform a new "prediction" i.e., evaluation. Here an evaluator is meant to evaluate a response against an associated query as well as optionally contexts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
The user query |
required |
query_by
|
CreatedBy
|
Query generated by human or ai (model-name) |
required |
contexts
|
Optional[List[str]]
|
The contexts used for response |
required |
answer
|
str
|
Answer to the query that is to be evaluated. |
required |
answer_by
|
The reference answer generated by human or ai (model-name). |
required | |
ground_truth_answer
|
Optional[str]
|
|
required |
ground_truth_answer_by
|
Optional[CreatedBy]
|
|
required |
reference_feedback
|
str
|
The reference feedback evaluation. |
required |
reference_score
|
float
|
The reference score evaluation. |
required |
reference_evaluation_by
|
CreatedBy
|
Evaluation generated by human or ai (model-name) |
required |
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
LabelledEvaluatorDataset #
Bases: BaseLlamaDataset[BaseEvaluator]
LabelledEvalationDataset class.
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
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 |
|
to_pandas #
to_pandas() -> Any
Create pandas dataframe.
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
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 |
|
LabelledPairwiseEvaluatorDataExample #
Bases: LabelledEvaluatorDataExample
Labelled pairwise evaluation data example class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
second_answer
|
str
|
The second answer to the example that is to be evaluated along versus |
''
|
second_answer_by
|
CreatedBy | None
|
What generated the second answer. |
None
|
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
|
LabelledPairwiseEvaluatorDataset #
Bases: BaseLlamaDataset[BaseEvaluator]
Labelled pairwise evaluation dataset. For evaluating the evaluator in performing pairwise evaluations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
BaseLlamaDataset
|
_type_
|
description |
required |
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
|
to_pandas #
to_pandas() -> Any
Create pandas dataframe.
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
|
PairwiseEvaluatorExamplePrediction #
Bases: BaseLlamaExamplePrediction
Pairwise evaluation example prediction class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feedback
|
Optional[str]
|
The evaluator's feedback. |
required |
score
|
Optional[float]
|
The evaluator's score. |
required |
evaluation_source
|
EvaluationSource
|
If the evaluation came from original order or flipped; or inconclusive. |
required |
invalid_prediction
|
bool
|
Whether or not the prediction is a valid one. |
False
|
invalid_reason
|
str | None
|
Reason as to why prediction is invalid. |
None
|
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
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 |
|
PairwiseEvaluatorPredictionDataset #
Bases: BaseLlamaPredictionDataset
Pairwise evaluation predictions dataset class.
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
to_pandas #
to_pandas() -> Any
Create pandas dataframe.
Source code in llama-index-core/llama_index/core/llama_dataset/evaluator_evaluation.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
LabelledRagDataExample #
Bases: BaseLlamaDataExample
RAG example class. Analogous to traditional ML datasets, this dataset contains the "features" (i.e., query + context) to make a prediction and the "label" (i.e., response) to evaluate the prediction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
The user query |
required |
query_by
|
CreatedBy
|
Query generated by human or ai (model-name) |
required |
reference_contexts
|
Optional[List[str]]
|
The contexts used for response |
required |
reference_answer
|
[str]
|
Reference answer to the query. An answer that would receive full marks upon evaluation. |
required |
reference_answer_by
|
The reference answer generated by human or ai (model-name). |
required |
Source code in llama-index-core/llama_index/core/llama_dataset/rag.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
LabelledRagDataset #
Bases: BaseLlamaDataset[BaseQueryEngine]
RagDataset class.
Source code in llama-index-core/llama_index/core/llama_dataset/rag.py
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 |
|
to_pandas #
to_pandas() -> Any
Create pandas dataframe.
Source code in llama-index-core/llama_index/core/llama_dataset/rag.py
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 |
|
RagExamplePrediction #
Bases: BaseLlamaExamplePrediction
RAG example prediction class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response
|
str
|
The response generated by the LLM. |
required |
contexts
|
Optional[List[str]]
|
The retrieved context (text) for generating response. |
required |
Source code in llama-index-core/llama_index/core/llama_dataset/rag.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
RagPredictionDataset #
Bases: BaseLlamaPredictionDataset
RagDataset class.
Source code in llama-index-core/llama_index/core/llama_dataset/rag.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
to_pandas #
to_pandas() -> Any
Create pandas dataframe.
Source code in llama-index-core/llama_index/core/llama_dataset/rag.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
download_llama_dataset #
download_llama_dataset(llama_dataset_class: str, download_dir: str, llama_datasets_url: str = LLAMA_DATASETS_URL, llama_datasets_lfs_url: str = LLAMA_DATASETS_LFS_URL, llama_datasets_source_files_tree_url: str = LLAMA_DATASETS_SOURCE_FILES_GITHUB_TREE_URL, show_progress: bool = False, load_documents: bool = True) -> Tuple[BaseLlamaDataset, List[Document]]
Download dataset from datasets-LFS and llamahub.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_class
|
The name of the llamadataset class you want to download,
such as |
required | |
custom_dir
|
Custom dir name to download loader into (under parent folder). |
required | |
custom_path
|
Custom dirpath to download loader into. |
required | |
llama_datasets_url
|
str
|
Url for getting ordinary files from llama_datasets repo |
LLAMA_DATASETS_URL
|
llama_datasets_lfs_url
|
str
|
Url for lfs-traced files llama_datasets repo |
LLAMA_DATASETS_LFS_URL
|
llama_datasets_source_files_tree_url
|
str
|
Url for listing source_files contents |
LLAMA_DATASETS_SOURCE_FILES_GITHUB_TREE_URL
|
refresh_cache
|
If true, the local cache will be skipped and the loader will be fetched directly from the remote repo. |
required | |
source_files_dirpath
|
The directory for storing source files |
required | |
library_path
|
File name of the library file. |
required | |
base_file_name
|
The rag dataset json file |
required | |
disable_library_cache
|
Boolean to control library cache |
required | |
override_path
|
Boolean to control overriding path |
required | |
show_progress
|
bool
|
Boolean for showing progress on downloading source files |
False
|
load_documents
|
bool
|
Boolean for whether or not source_files for LabelledRagDataset should be loaded. |
True
|
Returns:
Type | Description |
---|---|
Tuple[BaseLlamaDataset, List[Document]]
|
a |
Source code in llama-index-core/llama_index/core/llama_dataset/download.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|