|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "id": "16873712-1a56-4f10-90de-634875f65ab0", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "import json\n", |
| 11 | + "from promptify import Prompter,OpenAI,Pipeline\n", |
| 12 | + "from pprint import pprint" |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "code", |
| 17 | + "execution_count": 2, |
| 18 | + "id": "01b2cb21-7032-4933-8c8f-cfaee66ecc76", |
| 19 | + "metadata": {}, |
| 20 | + "outputs": [], |
| 21 | + "source": [ |
| 22 | + "from IPython.display import Markdown, display\n", |
| 23 | + "from IPython.display import display, HTML" |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "code", |
| 28 | + "execution_count": 3, |
| 29 | + "id": "dccda836-c445-4497-ae0f-3ff4d1a984f3", |
| 30 | + "metadata": {}, |
| 31 | + "outputs": [], |
| 32 | + "source": [ |
| 33 | + "api_key = \"\"" |
| 34 | + ] |
| 35 | + }, |
| 36 | + { |
| 37 | + "cell_type": "code", |
| 38 | + "execution_count": 4, |
| 39 | + "id": "847dfada-d5cc-47ef-9fe7-52ed95378822", |
| 40 | + "metadata": {}, |
| 41 | + "outputs": [], |
| 42 | + "source": [ |
| 43 | + "model=OpenAI(api_key)\n", |
| 44 | + "prompter = Prompter('qa_gen.jinja')\n", |
| 45 | + "pipe = Pipeline(prompter,model)" |
| 46 | + ] |
| 47 | + }, |
| 48 | + { |
| 49 | + "cell_type": "code", |
| 50 | + "execution_count": 15, |
| 51 | + "id": "f9b2a4bf-ab41-4362-aa7e-f04b664ca086", |
| 52 | + "metadata": {}, |
| 53 | + "outputs": [ |
| 54 | + { |
| 55 | + "name": "stdout", |
| 56 | + "output_type": "stream", |
| 57 | + "text": [ |
| 58 | + "In a world of over 7.9 billion people, approximately 4.66 billion individuals are active internet users, representing a staggering 59% of the global population. The exponential growth of digitalization is evident in the fact that there are an estimated 5.22 billion unique mobile users worldwide. Social media platforms continue to dominate the online landscape, with Facebook boasting a user base of around 2.8 billion, followed closely by YouTube with over 2.3 billion users. E-commerce has also seen remarkable growth, with global online retail sales surpassing $4.2 trillion in 2023, marking a significant increase from the previous year. Additionally, the rapid adoption of cryptocurrencies is reshaping financial landscapes, with Bitcoin leading the pack at a market capitalization exceeding $1.5 trillion, showcasing the evolving trends in digital assets.\n" |
| 59 | + ] |
| 60 | + } |
| 61 | + ], |
| 62 | + "source": [ |
| 63 | + "sent = \"In a world of over 7.9 billion people, approximately 4.66 billion individuals are active internet users, representing a staggering 59% of the global population. The exponential growth of digitalization is evident in the fact that there are an estimated 5.22 billion unique mobile users worldwide. Social media platforms continue to dominate the online landscape, with Facebook boasting a user base of around 2.8 billion, followed closely by YouTube with over 2.3 billion users. E-commerce has also seen remarkable growth, with global online retail sales surpassing $4.2 trillion in 2023, marking a significant increase from the previous year. Additionally, the rapid adoption of cryptocurrencies is reshaping financial landscapes, with Bitcoin leading the pack at a market capitalization exceeding $1.5 trillion, showcasing the evolving trends in digital assets.\"\n", |
| 64 | + "print(sent)" |
| 65 | + ] |
| 66 | + }, |
| 67 | + { |
| 68 | + "cell_type": "code", |
| 69 | + "execution_count": 16, |
| 70 | + "id": "1bcd707b-d5c7-48b0-bda9-7b9de0079e14", |
| 71 | + "metadata": {}, |
| 72 | + "outputs": [ |
| 73 | + { |
| 74 | + "name": "stderr", |
| 75 | + "output_type": "stream", |
| 76 | + "text": [ |
| 77 | + "100%|████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00, 1.42s/it]" |
| 78 | + ] |
| 79 | + }, |
| 80 | + { |
| 81 | + "name": "stdout", |
| 82 | + "output_type": "stream", |
| 83 | + "text": [ |
| 84 | + "[{'text': \"[{'Q': 'How many active internet users are there out of the global population?', 'A': 'Approximately 4.66 billion individuals are active internet users out of the global population.'}]\", 'usage': {'prompt_tokens': 290, 'completion_tokens': 41, 'total_tokens': 331}, 'parsed': {'status': 'completed', 'object_type': <class 'list'>, 'data': {'completion': [{'Q': 'How many active internet users are there out of the global population?', 'A': 'Approximately 4.66 billion individuals are active internet users out of the global population.'}], 'suggestions': []}}}]\n" |
| 85 | + ] |
| 86 | + }, |
| 87 | + { |
| 88 | + "name": "stderr", |
| 89 | + "output_type": "stream", |
| 90 | + "text": [ |
| 91 | + "\n" |
| 92 | + ] |
| 93 | + } |
| 94 | + ], |
| 95 | + "source": [ |
| 96 | + "result = pipe.fit(sent,\n", |
| 97 | + " domain = 'medical',\n", |
| 98 | + " total_questions=1,\n", |
| 99 | + " max_QA_tokens=1\n", |
| 100 | + " )\n", |
| 101 | + "print(result)" |
| 102 | + ] |
| 103 | + } |
| 104 | +, |
| 105 | + |
| 106 | + { |
| 107 | + "cell_type": "code", |
| 108 | + "execution_count": null, |
| 109 | + "id": "d02ad4bd-dabe-4c47-82b2-62e9f98525c5", |
| 110 | + "metadata": {}, |
| 111 | + "outputs": [], |
| 112 | + "source": [] |
| 113 | + } |
| 114 | + ], |
| 115 | + "metadata": { |
| 116 | + "kernelspec": { |
| 117 | + "display_name": "Python 3 (ipykernel)", |
| 118 | + "language": "python", |
| 119 | + "name": "python3" |
| 120 | + }, |
| 121 | + "language_info": { |
| 122 | + "codemirror_mode": { |
| 123 | + "name": "ipython", |
| 124 | + "version": 3 |
| 125 | + }, |
| 126 | + "file_extension": ".py", |
| 127 | + "mimetype": "text/x-python", |
| 128 | + "name": "python", |
| 129 | + "nbconvert_exporter": "python", |
| 130 | + "pygments_lexer": "ipython3", |
| 131 | + "version": "3.9.18" |
| 132 | + } |
| 133 | + }, |
| 134 | + "nbformat": 4, |
| 135 | + "nbformat_minor": 5 |
| 136 | +} |
0 commit comments