|
7 | 7 | "source": [
|
8 | 8 | "# Using Azure OpenAI\n",
|
9 | 9 | "\n",
|
10 |
| - "This tutorial will show you how to use Azure OpenAI endpoints instead of OpenAI endpoints." |
| 10 | + "This tutorial will show you how to use Azure OpenAI endpoints instead of OpenAI endpoints.\n", |
| 11 | + "\n", |
| 12 | + "\n", |
| 13 | + "- [Evaluation](#load-sample-dataset)\n", |
| 14 | + "- [Test set generation](#test-set-generation)" |
11 | 15 | ]
|
12 | 16 | },
|
13 | 17 | {
|
|
416 | 420 | "\n",
|
417 | 421 | "if you have any suggestion/feedbacks/things your not happy about, please do share it in the [issue section](https://github.com/explodinggradients/ragas/issues). We love hearing from you 😁"
|
418 | 422 | ]
|
| 423 | + }, |
| 424 | + { |
| 425 | + "cell_type": "markdown", |
| 426 | + "id": "3cee41e9", |
| 427 | + "metadata": {}, |
| 428 | + "source": [ |
| 429 | + "### Test set generation\n", |
| 430 | + "\n", |
| 431 | + "Here you will learn how to generate a test set from your dataset using the Azure OpenAI endpoints." |
| 432 | + ] |
| 433 | + }, |
| 434 | + { |
| 435 | + "cell_type": "code", |
| 436 | + "execution_count": null, |
| 437 | + "id": "aa9ff398", |
| 438 | + "metadata": {}, |
| 439 | + "outputs": [], |
| 440 | + "source": [ |
| 441 | + "! git clone https://huggingface.co/datasets/explodinggradients/2023-llm-papers" |
| 442 | + ] |
| 443 | + }, |
| 444 | + { |
| 445 | + "cell_type": "code", |
| 446 | + "execution_count": 2, |
| 447 | + "id": "d935a561", |
| 448 | + "metadata": {}, |
| 449 | + "outputs": [], |
| 450 | + "source": [ |
| 451 | + "from langchain.document_loaders import DirectoryLoader\n", |
| 452 | + "from ragas.testset.generator import TestsetGenerator\n", |
| 453 | + "from ragas.testset.evolutions import simple, reasoning, multi_context\n", |
| 454 | + "\n", |
| 455 | + "\n", |
| 456 | + "loader = DirectoryLoader(\"./2023-llm-papers/\", use_multithreading=True, silent_errors=True,sample_size=1)\n", |
| 457 | + "documents = loader.load()\n", |
| 458 | + "\n", |
| 459 | + "for document in documents:\n", |
| 460 | + " document.metadata['filename'] = document.metadata['source']" |
| 461 | + ] |
| 462 | + }, |
| 463 | + { |
| 464 | + "cell_type": "markdown", |
| 465 | + "id": "c8f735a7", |
| 466 | + "metadata": {}, |
| 467 | + "source": [ |
| 468 | + "Use the `azure_model` and `azure_embedding` that we initialized in above section to generate the test set" |
| 469 | + ] |
| 470 | + }, |
| 471 | + { |
| 472 | + "cell_type": "code", |
| 473 | + "execution_count": null, |
| 474 | + "id": "04abc4b1", |
| 475 | + "metadata": {}, |
| 476 | + "outputs": [], |
| 477 | + "source": [ |
| 478 | + "generator = TestsetGenerator.from_langchain(generator_llm=azure_model,critic_llm=azure_model,embeddings=azure_embeddings)\n", |
| 479 | + "\n", |
| 480 | + "testset = generator.generate_with_langchain_docs(documents, test_size=10, \n", |
| 481 | + " raise_exceptions=False, with_debugging_logs=False,\n", |
| 482 | + " distributions={simple: 0.5, reasoning: 0.25, multi_context: 0.25}) " |
| 483 | + ] |
| 484 | + }, |
| 485 | + { |
| 486 | + "cell_type": "markdown", |
| 487 | + "id": "d2f5a7f7", |
| 488 | + "metadata": {}, |
| 489 | + "source": [ |
| 490 | + "testset.to_pandas()" |
| 491 | + ] |
419 | 492 | }
|
420 | 493 | ],
|
421 | 494 | "metadata": {
|
|
434 | 507 | "name": "python",
|
435 | 508 | "nbconvert_exporter": "python",
|
436 | 509 | "pygments_lexer": "ipython3",
|
437 |
| - "version": "3.10.12" |
| 510 | + "version": "3.10.8" |
438 | 511 | }
|
439 | 512 | },
|
440 | 513 | "nbformat": 4,
|
|
0 commit comments