|
| 1 | +# Braintrust Coda Help Desk Dataset |
| 2 | + |
| 3 | +[](https://www.braintrustdata.com/) |
| 4 | + |
| 5 | +_This dataset was kindly provided by Kenny Wong and Ankur Goyal._ |
| 6 | + |
| 7 | +## CLI Usage |
| 8 | + |
| 9 | +You can download `llamadatasets` directly using `llamaindex-cli`, which comes installed with the `llama-index` python package: |
| 10 | + |
| 11 | +```bash |
| 12 | +llamaindex-cli download-llamadataset BraintrustCodaHelpDeskDataset --download-dir ./data |
| 13 | +``` |
| 14 | + |
| 15 | +You can then inspect the files at `./data`. When you're ready to load the data into |
| 16 | +python, you can use the below snippet of code: |
| 17 | + |
| 18 | +```python |
| 19 | +from llama_index.core import SimpleDirectoryReader |
| 20 | +from llama_index.core.llama_dataset import LabelledRagDataset |
| 21 | + |
| 22 | +rag_dataset = LabelledRagDataset.from_json("./data/rag_dataset.json") |
| 23 | +documents = SimpleDirectoryReader(input_dir="./data/source_files").load_data() |
| 24 | +``` |
| 25 | + |
| 26 | +## Code Usage |
| 27 | + |
| 28 | +You can download the dataset to a directory, say `./data` directly in Python |
| 29 | +as well. From there, you can use the convenient `RagEvaluatorPack` llamapack to |
| 30 | +run your own LlamaIndex RAG pipeline with the `llamadataset`. |
| 31 | + |
| 32 | +```python |
| 33 | +from llama_index.core.llama_dataset import download_llama_dataset |
| 34 | +from llama_index.core.llama_pack import download_llama_pack |
| 35 | +from llama_index.core import VectorStoreIndex |
| 36 | + |
| 37 | +# download and install dependencies for benchmark dataset |
| 38 | +rag_dataset, documents = download_llama_dataset( |
| 39 | + "BraintrustCodaHelpDeskDataset", "./data" |
| 40 | +) |
| 41 | + |
| 42 | +# build basic RAG system |
| 43 | +index = VectorStoreIndex.from_documents(documents=documents) |
| 44 | +query_engine = index.as_query_engine() |
| 45 | + |
| 46 | +# evaluate using the RagEvaluatorPack |
| 47 | +RagEvaluatorPack = download_llama_pack( |
| 48 | + "RagEvaluatorPack", "./rag_evaluator_pack" |
| 49 | +) |
| 50 | +rag_evaluator_pack = RagEvaluatorPack( |
| 51 | + rag_dataset=rag_dataset, query_engine=query_engine |
| 52 | +) |
| 53 | + |
| 54 | +############################################################################ |
| 55 | +# NOTE: If have a lower tier subscription for OpenAI API like Usage Tier 1 # |
| 56 | +# then you'll need to use different batch_size and sleep_time_in_seconds. # |
| 57 | +# For Usage Tier 1, settings that seemed to work well were batch_size=5, # |
| 58 | +# and sleep_time_in_seconds=15 (as of December 2023.) # |
| 59 | +############################################################################ |
| 60 | + |
| 61 | +benchmark_df = await rag_evaluator_pack.arun( |
| 62 | + batch_size=20, # batches the number of openai api calls to make |
| 63 | + sleep_time_in_seconds=1, # seconds to sleep before making an api call |
| 64 | +) |
| 65 | +``` |
0 commit comments