├── finance.pdf ├── attention is all you need.pdf ├── README.md ├── .gitignore ├── demo.py ├── LICENSE └── chatbot_demo.ipynb /finance.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madfrog/chatbot_llama2/HEAD/finance.pdf -------------------------------------------------------------------------------- /attention is all you need.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madfrog/chatbot_llama2/HEAD/attention is all you need.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chatbot_llama2 2 | 3 | 4 | ## Reference 5 | 6 | - https://colab.research.google.com/drive/1Ssg-fffeJ0LG0m3DoTofeLPvOUQyG1h3?usp=sharing#scrollTo=SP4Bk5YBf1mI -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /demo.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | import torch 4 | from langchain.text_splitter import RecursiveCharacterTextSplitter 5 | from langchain.vectorstores import Chroma 6 | from langchain.embeddings import HuggingFaceInstructEmbeddings 7 | 8 | from langchain import HuggingFacePipeline 9 | from langchain import PromptTemplate, LLMChain 10 | from transformers import AutoModelForCausalLM, AutoTokenizer 11 | from langchain.document_loaders import PyPDFLoader 12 | from transformers import pipeline 13 | import json 14 | import textwrap 15 | 16 | pdf_file_path = "./attention is all you need.pdf" 17 | model_path = "/mnt/h/Chinese-Llama-2-7b-4bit" 18 | 19 | 20 | B_INST, E_INST = "[INST]", "[/INST]" 21 | B_SYS, E_SYS = "<>\n", "\n<>\n\n" 22 | DEFAULT_SYSTEM_PROMPT = """\ 23 | You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. 24 | 25 | If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.""" 26 | 27 | 28 | def get_prompt(instruction, new_system_prompt=DEFAULT_SYSTEM_PROMPT ): 29 | SYSTEM_PROMPT = B_SYS + new_system_prompt + E_SYS 30 | prompt_template = B_INST + SYSTEM_PROMPT + instruction + E_INST 31 | return prompt_template 32 | 33 | def cut_off_text(text, prompt): 34 | cutoff_phrase = prompt 35 | index = text.find(cutoff_phrase) 36 | if index != -1: 37 | return text[:index] 38 | else: 39 | return text 40 | 41 | def remove_substring(string, substring): 42 | return string.replace(substring, "") 43 | 44 | 45 | 46 | def generate(text): 47 | prompt = get_prompt(text) 48 | with torch.autocast('cuda', dtype=torch.bfloat16): 49 | inputs = tokenizer(prompt, return_tensors="pt").to('cuda') 50 | outputs = model.generate(**inputs, 51 | max_new_tokens=512, 52 | eos_token_id=tokenizer.eos_token_id, 53 | pad_token_id=tokenizer.eos_token_id, 54 | ) 55 | final_outputs = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0] 56 | final_outputs = cut_off_text(final_outputs, '') 57 | final_outputs = remove_substring(final_outputs, prompt) 58 | 59 | return final_outputs#, outputs 60 | 61 | def parse_text(text): 62 | wrapped_text = textwrap.fill(text, width=100) 63 | print(wrapped_text +'\n\n') 64 | # return assistant_text 65 | 66 | 67 | def main(): 68 | pdf_loader = PyPDFLoader(pdf_file_path) 69 | text_splitter = RecursiveCharacterTextSplitter(chunk_size=300, chunk_overlap=0) 70 | splitted_docs = text_splitter.split_documents(pdf_loader.load()) 71 | 72 | EMBEDDING_MODEL_NAME = "/mnt/h/instructor-large" 73 | embeddings = HuggingFaceInstructEmbeddings( 74 | model_name=EMBEDDING_MODEL_NAME, 75 | model_kwargs={"device": "cuda"}, 76 | ) 77 | vector_store = Chroma( 78 | collection_name='llama2_demo', 79 | embedding_function=embeddings, 80 | persist_directory='./' 81 | ) 82 | vector_store.add_documents(splitted_docs) 83 | 84 | tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False) 85 | model = AutoModelForCausalLM.from_pretrained( 86 | model_path, 87 | load_in_4bit=True, 88 | torch_dtype=torch.float16, 89 | device_map='auto' 90 | ) 91 | pipe = pipeline( 92 | "text-generation", 93 | model=model, 94 | torch_dtype=torch.bfloat16, 95 | device_map='auto', 96 | max_new_tokens=512, 97 | do_sample=True, 98 | top_k=30, 99 | num_return_sequences=1, 100 | tokenizer=tokenizer, 101 | eos_token_id = tokenizer.eos_token_id 102 | ) 103 | 104 | llm = HuggingFacePipeline(pipeline=pipe, model_kwargs={'temperature':0}) 105 | system_prompt = "You are an advanced assistant that excels at translation. " 106 | instruction = "Convert the following text from English to French:\n\n {text}" 107 | template = get_prompt(instruction, system_prompt) 108 | print(template) 109 | 110 | prompt = PromptTemplate(template=template, input_variables=["text"]) 111 | llm_chain = LLMChain(prompt=prompt, llm=llm) 112 | 113 | text = "how are you today?" 114 | output = llm_chain.run(text) 115 | 116 | parse_text(output) 117 | 118 | 119 | if __name__=='__main__': 120 | main() 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /chatbot_demo.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "UWeuScHlWOok" 7 | }, 8 | "source": [ 9 | "# Check GPU info" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 1, 15 | "metadata": { 16 | "colab": { 17 | "base_uri": "https://localhost:8080/" 18 | }, 19 | "executionInfo": { 20 | "elapsed": 19, 21 | "status": "ok", 22 | "timestamp": 1692621908211, 23 | "user": { 24 | "displayName": "Jie Ke", 25 | "userId": "13821873407880707566" 26 | }, 27 | "user_tz": -480 28 | }, 29 | "id": "suNJHpbIWtV0", 30 | "outputId": "168085a1-adf4-48e0-9962-163ec89d1eea", 31 | "scrolled": true 32 | }, 33 | "outputs": [ 34 | { 35 | "name": "stdout", 36 | "output_type": "stream", 37 | "text": [ 38 | "Thu Aug 24 16:25:43 2023 \n", 39 | "+---------------------------------------------------------------------------------------+\n", 40 | "| NVIDIA-SMI 535.86.01 Driver Version: 536.67 CUDA Version: 12.2 |\n", 41 | "|-----------------------------------------+----------------------+----------------------+\n", 42 | "| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |\n", 43 | "| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |\n", 44 | "| | | MIG M. |\n", 45 | "|=========================================+======================+======================|\n", 46 | "| 0 NVIDIA GeForce GTX 1080 On | 00000000:01:00.0 Off | N/A |\n", 47 | "| 0% 38C P2 35W / 198W | 15MiB / 8192MiB | 0% Default |\n", 48 | "| | | N/A |\n", 49 | "+-----------------------------------------+----------------------+----------------------+\n", 50 | " \n", 51 | "+---------------------------------------------------------------------------------------+\n", 52 | "| Processes: |\n", 53 | "| GPU GI CI PID Type Process name GPU Memory |\n", 54 | "| ID ID Usage |\n", 55 | "|=======================================================================================|\n", 56 | "| 0 N/A N/A 23 G /Xwayland N/A |\n", 57 | "+---------------------------------------------------------------------------------------+\n" 58 | ] 59 | } 60 | ], 61 | "source": [ 62 | "!nvidia-smi" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "metadata": { 68 | "id": "Z9fecVpcWi6Z" 69 | }, 70 | "source": [ 71 | "# Install and import dependencies" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 2, 77 | "metadata": { 78 | "scrolled": true 79 | }, 80 | "outputs": [ 81 | { 82 | "name": "stdout", 83 | "output_type": "stream", 84 | "text": [ 85 | "Defaulting to user installation because normal site-packages is not writeable\n", 86 | "Looking in indexes: https://download.pytorch.org/whl/cu118\n", 87 | "Requirement already satisfied: torch in /home/voyagerke/.local/lib/python3.10/site-packages (2.0.1)\n", 88 | "Requirement already satisfied: torchvision in /home/voyagerke/.local/lib/python3.10/site-packages (0.15.2)\n", 89 | "Requirement already satisfied: torchaudio in /home/voyagerke/.local/lib/python3.10/site-packages (2.0.2)\n", 90 | "Requirement already satisfied: filelock in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (3.12.2)\n", 91 | "Requirement already satisfied: typing-extensions in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (4.7.1)\n", 92 | "Requirement already satisfied: sympy in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (1.12)\n", 93 | "Requirement already satisfied: networkx in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (3.1)\n", 94 | "Requirement already satisfied: jinja2 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (3.1.2)\n", 95 | "Requirement already satisfied: nvidia-cuda-nvrtc-cu11==11.7.99 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (11.7.99)\n", 96 | "Requirement already satisfied: nvidia-cuda-runtime-cu11==11.7.99 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (11.7.99)\n", 97 | "Requirement already satisfied: nvidia-cuda-cupti-cu11==11.7.101 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (11.7.101)\n", 98 | "Requirement already satisfied: nvidia-cudnn-cu11==8.5.0.96 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (8.5.0.96)\n", 99 | "Requirement already satisfied: nvidia-cublas-cu11==11.10.3.66 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (11.10.3.66)\n", 100 | "Requirement already satisfied: nvidia-cufft-cu11==10.9.0.58 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (10.9.0.58)\n", 101 | "Requirement already satisfied: nvidia-curand-cu11==10.2.10.91 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (10.2.10.91)\n", 102 | "Requirement already satisfied: nvidia-cusolver-cu11==11.4.0.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (11.4.0.1)\n", 103 | "Requirement already satisfied: nvidia-cusparse-cu11==11.7.4.91 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (11.7.4.91)\n", 104 | "Requirement already satisfied: nvidia-nccl-cu11==2.14.3 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (2.14.3)\n", 105 | "Requirement already satisfied: nvidia-nvtx-cu11==11.7.91 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (11.7.91)\n", 106 | "Requirement already satisfied: triton==2.0.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch) (2.0.0)\n", 107 | "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from nvidia-cublas-cu11==11.10.3.66->torch) (68.0.0)\n", 108 | "Requirement already satisfied: wheel in /usr/local/lib/python3.10/dist-packages (from nvidia-cublas-cu11==11.10.3.66->torch) (0.41.1)\n", 109 | "Requirement already satisfied: cmake in /home/voyagerke/.local/lib/python3.10/site-packages (from triton==2.0.0->torch) (3.27.2)\n", 110 | "Requirement already satisfied: lit in /home/voyagerke/.local/lib/python3.10/site-packages (from triton==2.0.0->torch) (16.0.6)\n", 111 | "Requirement already satisfied: numpy in /home/voyagerke/.local/lib/python3.10/site-packages (from torchvision) (1.25.2)\n", 112 | "Requirement already satisfied: requests in /home/voyagerke/.local/lib/python3.10/site-packages (from torchvision) (2.31.0)\n", 113 | "Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from torchvision) (10.0.0)\n", 114 | "Requirement already satisfied: MarkupSafe>=2.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from jinja2->torch) (2.1.3)\n", 115 | "Requirement already satisfied: charset-normalizer<4,>=2 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->torchvision) (3.2.0)\n", 116 | "Requirement already satisfied: idna<4,>=2.5 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->torchvision) (3.4)\n", 117 | "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->torchvision) (2.0.4)\n", 118 | "Requirement already satisfied: certifi>=2017.4.17 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->torchvision) (2023.7.22)\n", 119 | "Requirement already satisfied: mpmath>=0.19 in /home/voyagerke/.local/lib/python3.10/site-packages (from sympy->torch) (1.3.0)\n", 120 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 121 | "\u001b[0m" 122 | ] 123 | } 124 | ], 125 | "source": [ 126 | "!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 3, 132 | "metadata": { 133 | "colab": { 134 | "base_uri": "https://localhost:8080/" 135 | }, 136 | "executionInfo": { 137 | "elapsed": 37361, 138 | "status": "ok", 139 | "timestamp": 1692621959437, 140 | "user": { 141 | "displayName": "Jie Ke", 142 | "userId": "13821873407880707566" 143 | }, 144 | "user_tz": -480 145 | }, 146 | "id": "DmEzbXOHWiT2", 147 | "outputId": "49ddae91-2815-4a79-9ee6-2720ae02e50a", 148 | "scrolled": true 149 | }, 150 | "outputs": [ 151 | { 152 | "name": "stdout", 153 | "output_type": "stream", 154 | "text": [ 155 | "Defaulting to user installation because normal site-packages is not writeable\n", 156 | "Requirement already satisfied: jsons in /home/voyagerke/.local/lib/python3.10/site-packages (1.6.3)\n", 157 | "Requirement already satisfied: typish>=1.9.2 in /home/voyagerke/.local/lib/python3.10/site-packages (from jsons) (1.9.3)\n", 158 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 159 | "\u001b[0mDefaulting to user installation because normal site-packages is not writeable\n", 160 | "Requirement already satisfied: langchain in /home/voyagerke/.local/lib/python3.10/site-packages (0.0.268)\n", 161 | "Requirement already satisfied: PyYAML>=5.3 in /usr/lib/python3/dist-packages (from langchain) (5.4.1)\n", 162 | "Requirement already satisfied: SQLAlchemy<3,>=1.4 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (2.0.20)\n", 163 | "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (3.8.5)\n", 164 | "Requirement already satisfied: async-timeout<5.0.0,>=4.0.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (4.0.3)\n", 165 | "Requirement already satisfied: dataclasses-json<0.6.0,>=0.5.7 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (0.5.14)\n", 166 | "Requirement already satisfied: langsmith<0.1.0,>=0.0.21 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (0.0.25)\n", 167 | "Requirement already satisfied: numexpr<3.0.0,>=2.8.4 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (2.8.5)\n", 168 | "Requirement already satisfied: numpy<2,>=1 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (1.25.2)\n", 169 | "Requirement already satisfied: pydantic<3,>=1 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (1.10.12)\n", 170 | "Requirement already satisfied: requests<3,>=2 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (2.31.0)\n", 171 | "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from langchain) (8.2.3)\n", 172 | "Requirement already satisfied: attrs>=17.3.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (23.1.0)\n", 173 | "Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (3.2.0)\n", 174 | "Requirement already satisfied: multidict<7.0,>=4.5 in /home/voyagerke/.local/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.4)\n", 175 | "Requirement already satisfied: yarl<2.0,>=1.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.9.2)\n", 176 | "Requirement already satisfied: frozenlist>=1.1.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.4.0)\n", 177 | "Requirement already satisfied: aiosignal>=1.1.2 in /home/voyagerke/.local/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.1)\n", 178 | "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (3.20.1)\n", 179 | "Requirement already satisfied: typing-inspect<1,>=0.4.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (0.9.0)\n", 180 | "Requirement already satisfied: typing-extensions>=4.2.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from pydantic<3,>=1->langchain) (4.7.1)\n", 181 | "Requirement already satisfied: idna<4,>=2.5 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests<3,>=2->langchain) (3.4)\n", 182 | "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests<3,>=2->langchain) (2.0.4)\n", 183 | "Requirement already satisfied: certifi>=2017.4.17 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests<3,>=2->langchain) (2023.7.22)\n", 184 | "Requirement already satisfied: greenlet!=0.4.17 in /home/voyagerke/.local/lib/python3.10/site-packages (from SQLAlchemy<3,>=1.4->langchain) (2.0.2)\n", 185 | "Requirement already satisfied: packaging>=17.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json<0.6.0,>=0.5.7->langchain) (23.1)\n", 186 | "Requirement already satisfied: mypy-extensions>=0.3.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.6.0,>=0.5.7->langchain) (1.0.0)\n", 187 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 188 | "\u001b[0mDefaulting to user installation because normal site-packages is not writeable\n", 189 | "Requirement already satisfied: textwrap3 in /home/voyagerke/.local/lib/python3.10/site-packages (0.9.2)\n", 190 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 191 | "\u001b[0m" 192 | ] 193 | } 194 | ], 195 | "source": [ 196 | "!pip install jsons\n", 197 | "!pip install langchain\n", 198 | "!pip install textwrap3" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": 4, 204 | "metadata": { 205 | "colab": { 206 | "base_uri": "https://localhost:8080/" 207 | }, 208 | "executionInfo": { 209 | "elapsed": 22882, 210 | "status": "ok", 211 | "timestamp": 1692621982303, 212 | "user": { 213 | "displayName": "Jie Ke", 214 | "userId": "13821873407880707566" 215 | }, 216 | "user_tz": -480 217 | }, 218 | "id": "tsaxyjhoXwY4", 219 | "outputId": "25522acb-c703-4fbf-88d9-601953f14121", 220 | "scrolled": true 221 | }, 222 | "outputs": [ 223 | { 224 | "name": "stdout", 225 | "output_type": "stream", 226 | "text": [ 227 | "Defaulting to user installation because normal site-packages is not writeable\n", 228 | "Requirement already satisfied: transformers in /home/voyagerke/.local/lib/python3.10/site-packages (4.31.0)\n", 229 | "Requirement already satisfied: filelock in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers) (3.12.2)\n", 230 | "Requirement already satisfied: huggingface-hub<1.0,>=0.14.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers) (0.16.4)\n", 231 | "Requirement already satisfied: numpy>=1.17 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers) (1.25.2)\n", 232 | "Requirement already satisfied: packaging>=20.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers) (23.1)\n", 233 | "Requirement already satisfied: pyyaml>=5.1 in /usr/lib/python3/dist-packages (from transformers) (5.4.1)\n", 234 | "Requirement already satisfied: regex!=2019.12.17 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers) (2023.8.8)\n", 235 | "Requirement already satisfied: requests in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers) (2.31.0)\n", 236 | "Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers) (0.13.3)\n", 237 | "Requirement already satisfied: safetensors>=0.3.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers) (0.3.2)\n", 238 | "Requirement already satisfied: tqdm>=4.27 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers) (4.66.1)\n", 239 | "Requirement already satisfied: fsspec in /home/voyagerke/.local/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.14.1->transformers) (2023.6.0)\n", 240 | "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/voyagerke/.local/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.14.1->transformers) (4.7.1)\n", 241 | "Requirement already satisfied: charset-normalizer<4,>=2 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->transformers) (3.2.0)\n", 242 | "Requirement already satisfied: idna<4,>=2.5 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->transformers) (3.4)\n", 243 | "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->transformers) (2.0.4)\n", 244 | "Requirement already satisfied: certifi>=2017.4.17 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->transformers) (2023.7.22)\n", 245 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 246 | "\u001b[0m" 247 | ] 248 | } 249 | ], 250 | "source": [ 251 | "!pip install transformers" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": 5, 257 | "metadata": { 258 | "colab": { 259 | "base_uri": "https://localhost:8080/" 260 | }, 261 | "executionInfo": { 262 | "elapsed": 6606, 263 | "status": "ok", 264 | "timestamp": 1692621988892, 265 | "user": { 266 | "displayName": "Jie Ke", 267 | "userId": "13821873407880707566" 268 | }, 269 | "user_tz": -480 270 | }, 271 | "id": "kLZniEJKYqtV", 272 | "outputId": "a573c464-0c50-458b-aa56-e126a908c13b" 273 | }, 274 | "outputs": [ 275 | { 276 | "name": "stdout", 277 | "output_type": "stream", 278 | "text": [ 279 | "Defaulting to user installation because normal site-packages is not writeable\n", 280 | "Requirement already satisfied: pypdf in /home/voyagerke/.local/lib/python3.10/site-packages (3.15.2)\n", 281 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 282 | "\u001b[0m" 283 | ] 284 | } 285 | ], 286 | "source": [ 287 | "!pip install pypdf" 288 | ] 289 | }, 290 | { 291 | "cell_type": "code", 292 | "execution_count": 6, 293 | "metadata": { 294 | "colab": { 295 | "base_uri": "https://localhost:8080/" 296 | }, 297 | "executionInfo": { 298 | "elapsed": 16249, 299 | "status": "ok", 300 | "timestamp": 1692622005139, 301 | "user": { 302 | "displayName": "Jie Ke", 303 | "userId": "13821873407880707566" 304 | }, 305 | "user_tz": -480 306 | }, 307 | "id": "OA9hk_yKWfHL", 308 | "outputId": "41c2ae9d-91f3-4974-b781-f00ccb055b6b" 309 | }, 310 | "outputs": [ 311 | { 312 | "name": "stderr", 313 | "output_type": "stream", 314 | "text": [ 315 | "/home/voyagerke/.local/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", 316 | " from .autonotebook import tqdm as notebook_tqdm\n" 317 | ] 318 | } 319 | ], 320 | "source": [ 321 | "import torch\n", 322 | "from langchain.text_splitter import RecursiveCharacterTextSplitter\n", 323 | "from langchain.vectorstores import Chroma\n", 324 | "from langchain.embeddings import HuggingFaceInstructEmbeddings\n", 325 | "\n", 326 | "from langchain import HuggingFacePipeline\n", 327 | "from langchain import PromptTemplate, LLMChain\n", 328 | "from langchain.chains import RetrievalQA\n", 329 | "from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig\n", 330 | "from langchain.document_loaders import PyPDFLoader\n", 331 | "from transformers import pipeline\n", 332 | "import json\n", 333 | "import textwrap" 334 | ] 335 | }, 336 | { 337 | "cell_type": "markdown", 338 | "metadata": { 339 | "id": "L-Dlwy-mYMMh" 340 | }, 341 | "source": [ 342 | "# Ingest pdf file" 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "execution_count": 8, 348 | "metadata": { 349 | "executionInfo": { 350 | "elapsed": 16, 351 | "status": "ok", 352 | "timestamp": 1692622005139, 353 | "user": { 354 | "displayName": "Jie Ke", 355 | "userId": "13821873407880707566" 356 | }, 357 | "user_tz": -480 358 | }, 359 | "id": "RCIPcukLYOm9" 360 | }, 361 | "outputs": [], 362 | "source": [ 363 | "pdf_file_path = \"./finance.pdf\"\n", 364 | "# pdf_file_path = \"./attention is all you need.pdf\"" 365 | ] 366 | }, 367 | { 368 | "cell_type": "code", 369 | "execution_count": 9, 370 | "metadata": { 371 | "executionInfo": { 372 | "elapsed": 1484, 373 | "status": "ok", 374 | "timestamp": 1692622006608, 375 | "user": { 376 | "displayName": "Jie Ke", 377 | "userId": "13821873407880707566" 378 | }, 379 | "user_tz": -480 380 | }, 381 | "id": "ox0FJhOYYfwC" 382 | }, 383 | "outputs": [], 384 | "source": [ 385 | "pdf_loader = PyPDFLoader(pdf_file_path)\n", 386 | "text_splitter = RecursiveCharacterTextSplitter(chunk_size=300, chunk_overlap=0)\n", 387 | "splitted_docs = text_splitter.split_documents(pdf_loader.load())" 388 | ] 389 | }, 390 | { 391 | "cell_type": "code", 392 | "execution_count": 43, 393 | "metadata": { 394 | "colab": { 395 | "base_uri": "https://localhost:8080/" 396 | }, 397 | "executionInfo": { 398 | "elapsed": 6, 399 | "status": "ok", 400 | "timestamp": 1692622006608, 401 | "user": { 402 | "displayName": "Jie Ke", 403 | "userId": "13821873407880707566" 404 | }, 405 | "user_tz": -480 406 | }, 407 | "id": "SD929TvlYxaR", 408 | "outputId": "969ed343-78ae-413c-9285-ae6ea37da39a", 409 | "scrolled": true 410 | }, 411 | "outputs": [ 412 | { 413 | "name": "stdout", 414 | "output_type": "stream", 415 | "text": [ 416 | "page_content='中信证券研报表示,选取了14家具有代表性的海外CRO/CDMO企业以及生命科学上\\n游服务商,对其中报业绩进行总结并作为对国内企业的参考。中信证券发现,全球临床\\n阶段的新药研发依然活跃,早期研发的需求虽然暂时疲软,但随着海外投融资的回暖,\\n也有望回归快速增长常态。生命科学上游服务商的收入,则受到了下游企业去库存周期\\n的影响,但相关公司也普遍认为四季度将出现新增需求的拐点。综上,中信证券认为一\\n体化服务于全球中后期临床研发阶段/商业化阶段外包需求,以及高校/科研院所客户收\\n入占比高的企业业绩相对稳定,且海外收入占比较高的企业将有望率先受益于投融资回\\n暖带来的需求增加。\\n全文如下' metadata={'source': './finance.pdf', 'page': 0}\n" 417 | ] 418 | } 419 | ], 420 | "source": [ 421 | "print(splitted_docs[0])" 422 | ] 423 | }, 424 | { 425 | "cell_type": "markdown", 426 | "metadata": { 427 | "id": "oCeZbBGpY7j9" 428 | }, 429 | "source": [ 430 | "# Build and store embeddings" 431 | ] 432 | }, 433 | { 434 | "cell_type": "code", 435 | "execution_count": 11, 436 | "metadata": { 437 | "colab": { 438 | "base_uri": "https://localhost:8080/" 439 | }, 440 | "executionInfo": { 441 | "elapsed": 36014, 442 | "status": "ok", 443 | "timestamp": 1692622042620, 444 | "user": { 445 | "displayName": "Jie Ke", 446 | "userId": "13821873407880707566" 447 | }, 448 | "user_tz": -480 449 | }, 450 | "id": "kuajd4h3ZQrh", 451 | "outputId": "ccf5ba1d-a54b-4b00-8394-50ced48e9cd7", 452 | "scrolled": true 453 | }, 454 | "outputs": [ 455 | { 456 | "name": "stdout", 457 | "output_type": "stream", 458 | "text": [ 459 | "Defaulting to user installation because normal site-packages is not writeable\n", 460 | "Requirement already satisfied: InstructorEmbedding in /home/voyagerke/.local/lib/python3.10/site-packages (1.0.1)\n", 461 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 462 | "\u001b[0mDefaulting to user installation because normal site-packages is not writeable\n", 463 | "Requirement already satisfied: sentence_transformers in /home/voyagerke/.local/lib/python3.10/site-packages (2.2.2)\n", 464 | "Requirement already satisfied: transformers<5.0.0,>=4.6.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (4.31.0)\n", 465 | "Requirement already satisfied: tqdm in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (4.66.1)\n", 466 | "Requirement already satisfied: torch>=1.6.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (2.0.1)\n", 467 | "Requirement already satisfied: torchvision in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (0.15.2)\n", 468 | "Requirement already satisfied: numpy in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (1.25.2)\n", 469 | "Requirement already satisfied: scikit-learn in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (1.3.0)\n", 470 | "Requirement already satisfied: scipy in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (1.11.1)\n", 471 | "Requirement already satisfied: nltk in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (3.8.1)\n", 472 | "Requirement already satisfied: sentencepiece in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (0.1.99)\n", 473 | "Requirement already satisfied: huggingface-hub>=0.4.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from sentence_transformers) (0.16.4)\n", 474 | "Requirement already satisfied: filelock in /home/voyagerke/.local/lib/python3.10/site-packages (from huggingface-hub>=0.4.0->sentence_transformers) (3.12.2)\n", 475 | "Requirement already satisfied: fsspec in /home/voyagerke/.local/lib/python3.10/site-packages (from huggingface-hub>=0.4.0->sentence_transformers) (2023.6.0)\n", 476 | "Requirement already satisfied: requests in /home/voyagerke/.local/lib/python3.10/site-packages (from huggingface-hub>=0.4.0->sentence_transformers) (2.31.0)\n", 477 | "Requirement already satisfied: pyyaml>=5.1 in /usr/lib/python3/dist-packages (from huggingface-hub>=0.4.0->sentence_transformers) (5.4.1)\n", 478 | "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/voyagerke/.local/lib/python3.10/site-packages (from huggingface-hub>=0.4.0->sentence_transformers) (4.7.1)\n", 479 | "Requirement already satisfied: packaging>=20.9 in /home/voyagerke/.local/lib/python3.10/site-packages (from huggingface-hub>=0.4.0->sentence_transformers) (23.1)\n", 480 | "Requirement already satisfied: sympy in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (1.12)\n", 481 | "Requirement already satisfied: networkx in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (3.1)\n", 482 | "Requirement already satisfied: jinja2 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (3.1.2)\n", 483 | "Requirement already satisfied: nvidia-cuda-nvrtc-cu11==11.7.99 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (11.7.99)\n", 484 | "Requirement already satisfied: nvidia-cuda-runtime-cu11==11.7.99 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (11.7.99)\n", 485 | "Requirement already satisfied: nvidia-cuda-cupti-cu11==11.7.101 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (11.7.101)\n", 486 | "Requirement already satisfied: nvidia-cudnn-cu11==8.5.0.96 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (8.5.0.96)\n", 487 | "Requirement already satisfied: nvidia-cublas-cu11==11.10.3.66 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (11.10.3.66)\n", 488 | "Requirement already satisfied: nvidia-cufft-cu11==10.9.0.58 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (10.9.0.58)\n", 489 | "Requirement already satisfied: nvidia-curand-cu11==10.2.10.91 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (10.2.10.91)\n", 490 | "Requirement already satisfied: nvidia-cusolver-cu11==11.4.0.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (11.4.0.1)\n", 491 | "Requirement already satisfied: nvidia-cusparse-cu11==11.7.4.91 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (11.7.4.91)\n", 492 | "Requirement already satisfied: nvidia-nccl-cu11==2.14.3 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (2.14.3)\n", 493 | "Requirement already satisfied: nvidia-nvtx-cu11==11.7.91 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (11.7.91)\n", 494 | "Requirement already satisfied: triton==2.0.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.6.0->sentence_transformers) (2.0.0)\n", 495 | "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from nvidia-cublas-cu11==11.10.3.66->torch>=1.6.0->sentence_transformers) (68.0.0)\n", 496 | "Requirement already satisfied: wheel in /usr/local/lib/python3.10/dist-packages (from nvidia-cublas-cu11==11.10.3.66->torch>=1.6.0->sentence_transformers) (0.41.1)\n", 497 | "Requirement already satisfied: cmake in /home/voyagerke/.local/lib/python3.10/site-packages (from triton==2.0.0->torch>=1.6.0->sentence_transformers) (3.27.2)\n", 498 | "Requirement already satisfied: lit in /home/voyagerke/.local/lib/python3.10/site-packages (from triton==2.0.0->torch>=1.6.0->sentence_transformers) (16.0.6)\n", 499 | "Requirement already satisfied: regex!=2019.12.17 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers<5.0.0,>=4.6.0->sentence_transformers) (2023.8.8)\n", 500 | "Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers<5.0.0,>=4.6.0->sentence_transformers) (0.13.3)\n", 501 | "Requirement already satisfied: safetensors>=0.3.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from transformers<5.0.0,>=4.6.0->sentence_transformers) (0.3.2)\n", 502 | "Requirement already satisfied: click in /home/voyagerke/.local/lib/python3.10/site-packages (from nltk->sentence_transformers) (8.1.7)\n", 503 | "Requirement already satisfied: joblib in /home/voyagerke/.local/lib/python3.10/site-packages (from nltk->sentence_transformers) (1.3.2)\n", 504 | "Requirement already satisfied: threadpoolctl>=2.0.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from scikit-learn->sentence_transformers) (3.2.0)\n", 505 | "Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from torchvision->sentence_transformers) (10.0.0)\n", 506 | "Requirement already satisfied: MarkupSafe>=2.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from jinja2->torch>=1.6.0->sentence_transformers) (2.1.3)\n", 507 | "Requirement already satisfied: charset-normalizer<4,>=2 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.4.0->sentence_transformers) (3.2.0)\n", 508 | "Requirement already satisfied: idna<4,>=2.5 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.4.0->sentence_transformers) (3.4)\n", 509 | "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.4.0->sentence_transformers) (2.0.4)\n", 510 | "Requirement already satisfied: certifi>=2017.4.17 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.4.0->sentence_transformers) (2023.7.22)\n", 511 | "Requirement already satisfied: mpmath>=0.19 in /home/voyagerke/.local/lib/python3.10/site-packages (from sympy->torch>=1.6.0->sentence_transformers) (1.3.0)\n", 512 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 513 | "\u001b[0mDefaulting to user installation because normal site-packages is not writeable\n", 514 | "Requirement already satisfied: Chromadb in /home/voyagerke/.local/lib/python3.10/site-packages (0.4.6)\n", 515 | "Requirement already satisfied: requests>=2.28 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (2.31.0)\n", 516 | "Requirement already satisfied: pydantic<2.0,>=1.9 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (1.10.12)\n", 517 | "Requirement already satisfied: chroma-hnswlib==0.7.2 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (0.7.2)\n", 518 | "Requirement already satisfied: fastapi<0.100.0,>=0.95.2 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (0.99.1)\n", 519 | "Requirement already satisfied: uvicorn[standard]>=0.18.3 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (0.23.2)\n", 520 | "Requirement already satisfied: numpy>=1.21.6 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (1.25.2)\n", 521 | "Requirement already satisfied: posthog>=2.4.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (3.0.2)\n", 522 | "Requirement already satisfied: typing-extensions>=4.5.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (4.7.1)\n", 523 | "Requirement already satisfied: pulsar-client>=3.1.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (3.2.0)\n", 524 | "Requirement already satisfied: onnxruntime>=1.14.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (1.15.1)\n", 525 | "Requirement already satisfied: tokenizers>=0.13.2 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (0.13.3)\n", 526 | "Requirement already satisfied: pypika>=0.48.9 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (0.48.9)\n", 527 | "Requirement already satisfied: tqdm>=4.65.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (4.66.1)\n", 528 | "Requirement already satisfied: overrides>=7.3.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (7.4.0)\n", 529 | "Requirement already satisfied: importlib-resources in /home/voyagerke/.local/lib/python3.10/site-packages (from Chromadb) (6.0.1)\n", 530 | "Requirement already satisfied: starlette<0.28.0,>=0.27.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from fastapi<0.100.0,>=0.95.2->Chromadb) (0.27.0)\n", 531 | "Requirement already satisfied: coloredlogs in /home/voyagerke/.local/lib/python3.10/site-packages (from onnxruntime>=1.14.1->Chromadb) (15.0.1)\n", 532 | "Requirement already satisfied: flatbuffers in /home/voyagerke/.local/lib/python3.10/site-packages (from onnxruntime>=1.14.1->Chromadb) (23.5.26)\n", 533 | "Requirement already satisfied: packaging in /home/voyagerke/.local/lib/python3.10/site-packages (from onnxruntime>=1.14.1->Chromadb) (23.1)\n", 534 | "Requirement already satisfied: protobuf in /home/voyagerke/.local/lib/python3.10/site-packages (from onnxruntime>=1.14.1->Chromadb) (4.24.1)\n", 535 | "Requirement already satisfied: sympy in /home/voyagerke/.local/lib/python3.10/site-packages (from onnxruntime>=1.14.1->Chromadb) (1.12)\n", 536 | "Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from posthog>=2.4.0->Chromadb) (1.16.0)\n", 537 | "Requirement already satisfied: monotonic>=1.5 in /home/voyagerke/.local/lib/python3.10/site-packages (from posthog>=2.4.0->Chromadb) (1.6)\n", 538 | "Requirement already satisfied: backoff>=1.10.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from posthog>=2.4.0->Chromadb) (2.2.1)\n", 539 | "Requirement already satisfied: python-dateutil>2.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from posthog>=2.4.0->Chromadb) (2.8.2)\n", 540 | "Requirement already satisfied: certifi in /home/voyagerke/.local/lib/python3.10/site-packages (from pulsar-client>=3.1.0->Chromadb) (2023.7.22)\n", 541 | "Requirement already satisfied: charset-normalizer<4,>=2 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests>=2.28->Chromadb) (3.2.0)\n", 542 | "Requirement already satisfied: idna<4,>=2.5 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests>=2.28->Chromadb) (3.4)\n", 543 | "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from requests>=2.28->Chromadb) (2.0.4)\n", 544 | "Requirement already satisfied: click>=7.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from uvicorn[standard]>=0.18.3->Chromadb) (8.1.7)\n", 545 | "Requirement already satisfied: h11>=0.8 in /home/voyagerke/.local/lib/python3.10/site-packages (from uvicorn[standard]>=0.18.3->Chromadb) (0.14.0)\n", 546 | "Requirement already satisfied: httptools>=0.5.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from uvicorn[standard]>=0.18.3->Chromadb) (0.6.0)\n", 547 | "Requirement already satisfied: python-dotenv>=0.13 in /home/voyagerke/.local/lib/python3.10/site-packages (from uvicorn[standard]>=0.18.3->Chromadb) (1.0.0)\n", 548 | "Requirement already satisfied: pyyaml>=5.1 in /usr/lib/python3/dist-packages (from uvicorn[standard]>=0.18.3->Chromadb) (5.4.1)\n", 549 | "Requirement already satisfied: uvloop!=0.15.0,!=0.15.1,>=0.14.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from uvicorn[standard]>=0.18.3->Chromadb) (0.17.0)\n", 550 | "Requirement already satisfied: watchfiles>=0.13 in /home/voyagerke/.local/lib/python3.10/site-packages (from uvicorn[standard]>=0.18.3->Chromadb) (0.19.0)\n", 551 | "Requirement already satisfied: websockets>=10.4 in /home/voyagerke/.local/lib/python3.10/site-packages (from uvicorn[standard]>=0.18.3->Chromadb) (11.0.3)\n", 552 | "Requirement already satisfied: anyio<5,>=3.4.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from starlette<0.28.0,>=0.27.0->fastapi<0.100.0,>=0.95.2->Chromadb) (3.7.1)\n", 553 | "Requirement already satisfied: humanfriendly>=9.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from coloredlogs->onnxruntime>=1.14.1->Chromadb) (10.0)\n", 554 | "Requirement already satisfied: mpmath>=0.19 in /home/voyagerke/.local/lib/python3.10/site-packages (from sympy->onnxruntime>=1.14.1->Chromadb) (1.3.0)\n", 555 | "Requirement already satisfied: sniffio>=1.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from anyio<5,>=3.4.0->starlette<0.28.0,>=0.27.0->fastapi<0.100.0,>=0.95.2->Chromadb) (1.3.0)\n", 556 | "Requirement already satisfied: exceptiongroup in /home/voyagerke/.local/lib/python3.10/site-packages (from anyio<5,>=3.4.0->starlette<0.28.0,>=0.27.0->fastapi<0.100.0,>=0.95.2->Chromadb) (1.1.3)\n", 557 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 558 | "\u001b[0m" 559 | ] 560 | } 561 | ], 562 | "source": [ 563 | "!pip install InstructorEmbedding\n", 564 | "!pip install sentence_transformers\n", 565 | "!pip install Chromadb" 566 | ] 567 | }, 568 | { 569 | "cell_type": "markdown", 570 | "metadata": {}, 571 | "source": [ 572 | "## Build Sentence Embeddings for Chinese" 573 | ] 574 | }, 575 | { 576 | "cell_type": "code", 577 | "execution_count": 12, 578 | "metadata": {}, 579 | "outputs": [], 580 | "source": [ 581 | "from langchain.embeddings.huggingface import HuggingFaceEmbeddings\n", 582 | "\n", 583 | "'''\n", 584 | "https://huggingface.co/shibing624/text2vec-base-chinese/tree/main\n", 585 | "'''\n", 586 | "chinese_embedding_name = \"/mnt/h/text2vec-base-chinese\"\n", 587 | "embeddings = HuggingFaceEmbeddings(\n", 588 | " model_name=chinese_embedding_name,\n", 589 | " model_kwargs={\"device\": \"cuda\"},\n", 590 | ")" 591 | ] 592 | }, 593 | { 594 | "cell_type": "code", 595 | "execution_count": 29, 596 | "metadata": { 597 | "colab": { 598 | "base_uri": "https://localhost:8080/" 599 | }, 600 | "executionInfo": { 601 | "elapsed": 16346, 602 | "status": "ok", 603 | "timestamp": 1692622067531, 604 | "user": { 605 | "displayName": "Jie Ke", 606 | "userId": "13821873407880707566" 607 | }, 608 | "user_tz": -480 609 | }, 610 | "id": "3D2dWij2Zkb0", 611 | "outputId": "4f7641c3-9d23-49ba-d1f1-7a9017a1b5bb", 612 | "scrolled": true 613 | }, 614 | "outputs": [], 615 | "source": [ 616 | "collection_name = 'llama2_demo'\n", 617 | "db = Chroma(\n", 618 | " collection_name=collection_name,\n", 619 | " embedding_function=embeddings,\n", 620 | " persist_directory='./'\n", 621 | ")\n" 622 | ] 623 | }, 624 | { 625 | "cell_type": "code", 626 | "execution_count": 31, 627 | "metadata": { 628 | "scrolled": true 629 | }, 630 | "outputs": [ 631 | { 632 | "data": { 633 | "text/plain": [ 634 | "['946cabe6-4258-11ee-a0ca-817489a76db9',\n", 635 | " '946cabe7-4258-11ee-a0ca-817489a76db9',\n", 636 | " '946cabe8-4258-11ee-a0ca-817489a76db9',\n", 637 | " '946cabe9-4258-11ee-a0ca-817489a76db9',\n", 638 | " '946cabea-4258-11ee-a0ca-817489a76db9',\n", 639 | " '946cabeb-4258-11ee-a0ca-817489a76db9',\n", 640 | " '946cabec-4258-11ee-a0ca-817489a76db9',\n", 641 | " '946cabed-4258-11ee-a0ca-817489a76db9',\n", 642 | " '946cabee-4258-11ee-a0ca-817489a76db9',\n", 643 | " '946cabef-4258-11ee-a0ca-817489a76db9',\n", 644 | " '946cabf0-4258-11ee-a0ca-817489a76db9',\n", 645 | " '946cabf1-4258-11ee-a0ca-817489a76db9',\n", 646 | " '946cabf2-4258-11ee-a0ca-817489a76db9']" 647 | ] 648 | }, 649 | "execution_count": 31, 650 | "metadata": {}, 651 | "output_type": "execute_result" 652 | } 653 | ], 654 | "source": [ 655 | "db.add_documents(splitted_docs)" 656 | ] 657 | }, 658 | { 659 | "cell_type": "markdown", 660 | "metadata": {}, 661 | "source": [ 662 | "## Test similarity search in Chroma" 663 | ] 664 | }, 665 | { 666 | "cell_type": "code", 667 | "execution_count": 32, 668 | "metadata": {}, 669 | "outputs": [ 670 | { 671 | "name": "stdout", 672 | "output_type": "stream", 673 | "text": [ 674 | "[Document(page_content='医疗健康|海外CXO生命科学上游公司中报盘点:投融资回暖趋势已现,需求拐\\n点在望\\n我们选取了14家具有代表性的海外CRO/CDMO企业以及生命科学上游服务商,\\n对其中报业绩进行总结并作为对国内企业的参考。我们发现,全球临床阶段的新药研发\\n依然活跃,早期研发的需求虽然暂时疲软,但随着海外投融资的回暖,也有望回归快速\\n增长常态。生命科学上游服务商的收入,则受到了下游企业去库存周期的影响,但相关\\n公司也普遍认为23Q4将出现新增需求的拐点。综上,我们认为一体化服务于全球中后\\n期临床研发阶段/商业化阶段外包需求,以及高校/科研院所客户收入占比高的企业业绩', metadata={'page': 0, 'source': './finance.pdf'}), Document(page_content='增长常态。生命科学上游服务商的收入,则受到了下游企业去库存周期的影响,但企业\\n普遍认为23Q4将出现新增需求的拐点。综上,我们认为一体化服务于全球中后期临床\\n研发阶段/商业化阶段外包需求,以及高校/科研院所/大药企客户收入占比高的企业业\\n绩相对稳定;且海外收入占比较高的企业将有望率先受益于投融资回暖带来的需求增加。', metadata={'page': 4, 'source': './finance.pdf'}), Document(page_content='了项目投资计划。来自资金相对更为充沛的高校、科研院所、大药企的需求则更为稳定。\\n我们认为投融资的改善有望促进下游企业的资本开支恢复常态。\\n3)中国区需求收入有一定波动。2023年H1,海外企业均表示中国区需求出现了\\n下降,这一部分是因为国内同样正在经历投融资下滑+去库存的周期,一部分则是因为\\n中国本土供应商的崛起:Sartorius认为中国本土供应商的市场份额已显著上升。\\n▍风险因素:\\n生物医药投融资恢复不及预期;去库存周期长于预期;宏观经济恢复不及预期;研\\n发投入不及预期;研发管线推进不及预期。\\n▍投资策略:\\n我们选取了14家具有代表性的海外CRO/CDMO企业以及生命科学上游服务商,', metadata={'page': 3, 'source': './finance.pdf'}), Document(page_content='中信证券研报表示,选取了14家具有代表性的海外CRO/CDMO企业以及生命科学上\\n游服务商,对其中报业绩进行总结并作为对国内企业的参考。中信证券发现,全球临床\\n阶段的新药研发依然活跃,早期研发的需求虽然暂时疲软,但随着海外投融资的回暖,\\n也有望回归快速增长常态。生命科学上游服务商的收入,则受到了下游企业去库存周期\\n的影响,但相关公司也普遍认为四季度将出现新增需求的拐点。综上,中信证券认为一\\n体化服务于全球中后期临床研发阶段/商业化阶段外包需求,以及高校/科研院所客户收\\n入占比高的企业业绩相对稳定,且海外收入占比较高的企业将有望率先受益于投融资回\\n暖带来的需求增加。\\n全文如下', metadata={'page': 0, 'source': './finance.pdf'})]\n" 675 | ] 676 | } 677 | ], 678 | "source": [ 679 | "test_query = '医疗健康投资的风险因素有哪些?'\n", 680 | "# test_query = 'what is dominant sequence transduction models?'\n", 681 | "search_docs = db.similarity_search(test_query)\n", 682 | "print(search_docs)" 683 | ] 684 | }, 685 | { 686 | "cell_type": "code", 687 | "execution_count": 16, 688 | "metadata": {}, 689 | "outputs": [], 690 | "source": [ 691 | "# db.delete_collection()" 692 | ] 693 | }, 694 | { 695 | "cell_type": "markdown", 696 | "metadata": { 697 | "id": "sTSC-0ywbPUw" 698 | }, 699 | "source": [ 700 | "# Build model and transformer pipeline" 701 | ] 702 | }, 703 | { 704 | "cell_type": "code", 705 | "execution_count": 17, 706 | "metadata": { 707 | "colab": { 708 | "base_uri": "https://localhost:8080/" 709 | }, 710 | "executionInfo": { 711 | "elapsed": 24785, 712 | "status": "ok", 713 | "timestamp": 1692622092302, 714 | "user": { 715 | "displayName": "Jie Ke", 716 | "userId": "13821873407880707566" 717 | }, 718 | "user_tz": -480 719 | }, 720 | "id": "0KeBMiD6cEvb", 721 | "outputId": "3c403188-f62c-4b9e-bcb0-745b8e47807e", 722 | "scrolled": true 723 | }, 724 | "outputs": [ 725 | { 726 | "name": "stdout", 727 | "output_type": "stream", 728 | "text": [ 729 | "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n", 730 | "To disable this warning, you can either:\n", 731 | "\t- Avoid using `tokenizers` before the fork if possible\n", 732 | "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n", 733 | "Defaulting to user installation because normal site-packages is not writeable\n", 734 | "Requirement already satisfied: accelerate in /home/voyagerke/.local/lib/python3.10/site-packages (0.21.0)\n", 735 | "Requirement already satisfied: numpy>=1.17 in /home/voyagerke/.local/lib/python3.10/site-packages (from accelerate) (1.25.2)\n", 736 | "Requirement already satisfied: packaging>=20.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from accelerate) (23.1)\n", 737 | "Requirement already satisfied: psutil in /home/voyagerke/.local/lib/python3.10/site-packages (from accelerate) (5.9.5)\n", 738 | "Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from accelerate) (5.4.1)\n", 739 | "Requirement already satisfied: torch>=1.10.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from accelerate) (2.0.1)\n", 740 | "Requirement already satisfied: filelock in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (3.12.2)\n", 741 | "Requirement already satisfied: typing-extensions in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (4.7.1)\n", 742 | "Requirement already satisfied: sympy in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (1.12)\n", 743 | "Requirement already satisfied: networkx in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (3.1)\n", 744 | "Requirement already satisfied: jinja2 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (3.1.2)\n", 745 | "Requirement already satisfied: nvidia-cuda-nvrtc-cu11==11.7.99 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.7.99)\n", 746 | "Requirement already satisfied: nvidia-cuda-runtime-cu11==11.7.99 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.7.99)\n", 747 | "Requirement already satisfied: nvidia-cuda-cupti-cu11==11.7.101 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.7.101)\n", 748 | "Requirement already satisfied: nvidia-cudnn-cu11==8.5.0.96 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (8.5.0.96)\n", 749 | "Requirement already satisfied: nvidia-cublas-cu11==11.10.3.66 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.10.3.66)\n", 750 | "Requirement already satisfied: nvidia-cufft-cu11==10.9.0.58 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (10.9.0.58)\n", 751 | "Requirement already satisfied: nvidia-curand-cu11==10.2.10.91 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (10.2.10.91)\n", 752 | "Requirement already satisfied: nvidia-cusolver-cu11==11.4.0.1 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.4.0.1)\n", 753 | "Requirement already satisfied: nvidia-cusparse-cu11==11.7.4.91 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.7.4.91)\n", 754 | "Requirement already satisfied: nvidia-nccl-cu11==2.14.3 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (2.14.3)\n", 755 | "Requirement already satisfied: nvidia-nvtx-cu11==11.7.91 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (11.7.91)\n", 756 | "Requirement already satisfied: triton==2.0.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from torch>=1.10.0->accelerate) (2.0.0)\n", 757 | "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from nvidia-cublas-cu11==11.10.3.66->torch>=1.10.0->accelerate) (68.0.0)\n", 758 | "Requirement already satisfied: wheel in /usr/local/lib/python3.10/dist-packages (from nvidia-cublas-cu11==11.10.3.66->torch>=1.10.0->accelerate) (0.41.1)\n", 759 | "Requirement already satisfied: cmake in /home/voyagerke/.local/lib/python3.10/site-packages (from triton==2.0.0->torch>=1.10.0->accelerate) (3.27.2)\n", 760 | "Requirement already satisfied: lit in /home/voyagerke/.local/lib/python3.10/site-packages (from triton==2.0.0->torch>=1.10.0->accelerate) (16.0.6)\n", 761 | "Requirement already satisfied: MarkupSafe>=2.0 in /home/voyagerke/.local/lib/python3.10/site-packages (from jinja2->torch>=1.10.0->accelerate) (2.1.3)\n", 762 | "Requirement already satisfied: mpmath>=0.19 in /home/voyagerke/.local/lib/python3.10/site-packages (from sympy->torch>=1.10.0->accelerate) (1.3.0)\n", 763 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 764 | "\u001b[0mhuggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n", 765 | "To disable this warning, you can either:\n", 766 | "\t- Avoid using `tokenizers` before the fork if possible\n", 767 | "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n", 768 | "Defaulting to user installation because normal site-packages is not writeable\n", 769 | "Requirement already satisfied: bitsandbytes in /home/voyagerke/.local/lib/python3.10/site-packages (0.41.1)\n", 770 | "\u001b[33mDEPRECATION: distro-info 1.1build1 has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of distro-info or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", 771 | "\u001b[0m" 772 | ] 773 | } 774 | ], 775 | "source": [ 776 | "!pip install accelerate\n", 777 | "!pip install bitsandbytes" 778 | ] 779 | }, 780 | { 781 | "cell_type": "code", 782 | "execution_count": 18, 783 | "metadata": { 784 | "colab": { 785 | "base_uri": "https://localhost:8080/", 786 | "height": 215, 787 | "referenced_widgets": [ 788 | "b3ca2dda95c7458aa34e1affd35ce6c5", 789 | "290bba95208d41a9859be6fdf0fd9162", 790 | "6753ef627c3241efb2f532c68ef26d42", 791 | "c2ba7e405d0c41519270e48af899d6b8", 792 | "8a477b2736984ef8a76d7e3878323e8d", 793 | "ac18d1c538f84444861d4255377a603c", 794 | "a2260c5958d04f9a8ef16e9f33045425", 795 | "0da0da8ffc18498bb676221d768fd339", 796 | "217de16416484c92b77b187222607d92", 797 | "39a7407817004510b85e45949bf4532a", 798 | "0f8bfea3563c4cf0b8a0024e347dfc96", 799 | "ec7fe87663d144f8a1aeb477c2d022f4", 800 | "5b0edbb973ab4b0aa0ff4e6426465dcf", 801 | "f8c0ce8212e6458eb7a34f3d3cb14231", 802 | "e96aabf90f7341a5b147ce9553e9c14b", 803 | "96108b6ca9204839af176eda7afd0049", 804 | "12aff629989341fdbd8c23465fe43e10", 805 | "9abd89ae79e04ce686c3103cd29af08f", 806 | "d8439c2c34b44be5a43055af77ece713", 807 | "4adfcca6abeb46bd82ea2f7323c518bb", 808 | "1dae3525d2c94656bcda3c8ea2cdf7d6", 809 | "652d98faf01845b38baadf89af5f7c10", 810 | "372e13b30ab7400993861d3523a3c268", 811 | "f48c4bd3516d4134b08cf9536d44da37", 812 | "27466edededd40f988b935d9471eaf3f", 813 | "2aac1bdbeff94ee2a462db962ece1b5f", 814 | "f2d5d5f9c7e2405c8e9defeab42778d3", 815 | "3c32370319e54395bcc7d129aaab84bd", 816 | "c1f707cb3960413db86ee33ce346e2b0", 817 | "ac0deace83194ef79754ae5cf78242cb", 818 | "686c627bad6149508d52b7a9bbc76dd1", 819 | "004d1bd60ce346c29af7b9b03fa8e81d", 820 | "690d47749161426c82dee36209ea1de3", 821 | "99eb59e647dc40389ebe7fe6f9bae8d9", 822 | "8f0ff2e87fc348b0bb48aa27555a3f49", 823 | "bf20104fa2ad48c0a86960fb9fe5876a", 824 | "88f87969ad2444159b84c88ee5dbf13c", 825 | "7cf6c9715f22497a8708eb58e36829dd", 826 | "95da6821ae4041158c26d4b4aa07646d", 827 | "106890bf2ad54901985071bd80e102c5", 828 | "cf21efca556642b494b815577a314b5a", 829 | "3966c4b83dea4e7d92f44985f020c491", 830 | "4a24d0a8293548a4967c9b7d3cd0fe93", 831 | "ce046e7c5f2741a798666d018a7782db", 832 | "7022a295aff949ef8243406667d23b99", 833 | "b7d815284baa4b1686d62dc7f8370ce6", 834 | "820c9e5b15c54b5bafc886770059ab80", 835 | "727f8e555f4147828a65dda4c3d4e5f0", 836 | "f299f204b11f4132bfc771680d9fc563", 837 | "13269879221342949b321c2035079068", 838 | "60210099713d4f03967b7b738153aabf", 839 | "01df2cfd842b4168a5b2c9f1822fc875", 840 | "4f7ac39e566640e29173c7390879ecc2", 841 | "aca12d4a77314027b30b232ec010ef83", 842 | "34719f671b1143f98d4e92611dac6dce" 843 | ] 844 | }, 845 | "id": "ro2sF5w6bUBy", 846 | "outputId": "e7ca4ce2-54f7-4c72-a891-ff470d57f847" 847 | }, 848 | "outputs": [ 849 | { 850 | "name": "stderr", 851 | "output_type": "stream", 852 | "text": [ 853 | "You are using the legacy behaviour of the . This means that tokens that come after special tokens will not be properly handled. We recommend you to read the related pull request available at https://github.com/huggingface/transformers/pull/24565\n", 854 | "Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [01:36<00:00, 48.41s/it]\n" 855 | ] 856 | } 857 | ], 858 | "source": [ 859 | "'''\n", 860 | "https://huggingface.co/LinkSoul/Chinese-Llama-2-7b-4bit\n", 861 | "'''\n", 862 | "model_path = '/mnt/h/Chinese-Llama-2-7b-4bit'\n", 863 | "tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)\n", 864 | "model = AutoModelForCausalLM.from_pretrained(\n", 865 | " model_path,\n", 866 | " load_in_4bit=True,\n", 867 | " torch_dtype=torch.float16,\n", 868 | " device_map='auto'\n", 869 | ")" 870 | ] 871 | }, 872 | { 873 | "cell_type": "code", 874 | "execution_count": 19, 875 | "metadata": { 876 | "id": "BxWm8XcigCOh" 877 | }, 878 | "outputs": [ 879 | { 880 | "name": "stderr", 881 | "output_type": "stream", 882 | "text": [ 883 | "Xformers is not installed correctly. If you want to use memory_efficient_attention to accelerate training use the following command to install Xformers\n", 884 | "pip install xformers.\n" 885 | ] 886 | } 887 | ], 888 | "source": [ 889 | "generation_config = GenerationConfig.from_pretrained(model_path)\n", 890 | "pipe = pipeline(\n", 891 | " \"text-generation\",\n", 892 | " model=model,\n", 893 | " torch_dtype=torch.bfloat16,\n", 894 | " device_map='auto',\n", 895 | " max_length=2048,\n", 896 | " temperature=0,\n", 897 | " top_p=0.95,\n", 898 | " repetition_penalty=1.15,\n", 899 | " tokenizer=tokenizer,\n", 900 | " generation_config=generation_config,\n", 901 | ")" 902 | ] 903 | }, 904 | { 905 | "cell_type": "markdown", 906 | "metadata": {}, 907 | "source": [ 908 | "## The function for building prompt" 909 | ] 910 | }, 911 | { 912 | "cell_type": "code", 913 | "execution_count": 20, 914 | "metadata": { 915 | "id": "pMhcwjCUgKYG" 916 | }, 917 | "outputs": [], 918 | "source": [ 919 | "B_INST, E_INST = \"[INST]\", \"[/INST]\"\n", 920 | "B_SYS, E_SYS = \"<>\\n\", \"\\n<>\\n\\n\"\n", 921 | "DEFAULT_SYSTEM_PROMPT = \"\"\"\\\n", 922 | "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n", 923 | "\n", 924 | "If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\"\"\"\n", 925 | "\n", 926 | "def get_prompt(instruction, new_system_prompt=DEFAULT_SYSTEM_PROMPT ):\n", 927 | " SYSTEM_PROMPT = B_SYS + new_system_prompt + E_SYS\n", 928 | " prompt_template = B_INST + SYSTEM_PROMPT + instruction + E_INST\n", 929 | " return prompt_template" 930 | ] 931 | }, 932 | { 933 | "cell_type": "code", 934 | "execution_count": 21, 935 | "metadata": {}, 936 | "outputs": [ 937 | { 938 | "data": { 939 | "text/plain": [ 940 | "\"[INST]<>\\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\\n\\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\\n<>\\n\\nWhat is the temperature in Melbourne?[/INST]\"" 941 | ] 942 | }, 943 | "execution_count": 21, 944 | "metadata": {}, 945 | "output_type": "execute_result" 946 | } 947 | ], 948 | "source": [ 949 | "# Test function get_prompt()\n", 950 | "\n", 951 | "instruction = \"What is the temperature in Melbourne?\"\n", 952 | "get_prompt(instruction)" 953 | ] 954 | }, 955 | { 956 | "cell_type": "markdown", 957 | "metadata": {}, 958 | "source": [ 959 | "## Build HuggingFacePipeline" 960 | ] 961 | }, 962 | { 963 | "cell_type": "code", 964 | "execution_count": 22, 965 | "metadata": {}, 966 | "outputs": [], 967 | "source": [ 968 | "llm = HuggingFacePipeline(pipeline=pipe, model_kwargs={'temperature':0})" 969 | ] 970 | }, 971 | { 972 | "cell_type": "code", 973 | "execution_count": 23, 974 | "metadata": {}, 975 | "outputs": [], 976 | "source": [ 977 | "def parse_text(text):\n", 978 | " wrapped_text = textwrap.fill(text, width=100)\n", 979 | " print(wrapped_text +'\\n\\n')" 980 | ] 981 | }, 982 | { 983 | "cell_type": "code", 984 | "execution_count": 24, 985 | "metadata": {}, 986 | "outputs": [], 987 | "source": [ 988 | "from langchain.memory import ConversationBufferMemory\n", 989 | "from langchain.prompts import PromptTemplate" 990 | ] 991 | }, 992 | { 993 | "cell_type": "code", 994 | "execution_count": 25, 995 | "metadata": {}, 996 | "outputs": [], 997 | "source": [ 998 | "template = \"\"\"Use the following pieces of context to answer the question at the end. If you don't know the answer,\\\n", 999 | "just say that you don't know, don't try to make up an answer. Must use Chinese to answer the question.\n", 1000 | "\n", 1001 | "{context}\n", 1002 | "\n", 1003 | "{history}\n", 1004 | "Question: {question}\n", 1005 | "Helpful Answer:\"\"\"\n", 1006 | "prompt = PromptTemplate(input_variables=[\"history\", \"context\", \"question\"], template=template)\n", 1007 | "memory = ConversationBufferMemory(input_key='question', memory_key='history')" 1008 | ] 1009 | }, 1010 | { 1011 | "cell_type": "code", 1012 | "execution_count": 34, 1013 | "metadata": {}, 1014 | "outputs": [], 1015 | "source": [ 1016 | "from langchain.retrievers.multi_query import MultiQueryRetriever\n", 1017 | "\n", 1018 | "retriever_from_llm = MultiQueryRetriever.from_llm(retriever=db.as_retriever(), llm=llm)\n", 1019 | "# retriever_from_llm = db.as_retriever()" 1020 | ] 1021 | }, 1022 | { 1023 | "cell_type": "markdown", 1024 | "metadata": {}, 1025 | "source": [ 1026 | "## Add context compression" 1027 | ] 1028 | }, 1029 | { 1030 | "cell_type": "markdown", 1031 | "metadata": {}, 1032 | "source": [ 1033 | "Max token size of Llama2 is 2048, should compress each document." 1034 | ] 1035 | }, 1036 | { 1037 | "cell_type": "code", 1038 | "execution_count": 35, 1039 | "metadata": {}, 1040 | "outputs": [], 1041 | "source": [ 1042 | "from langchain.retrievers.document_compressors import LLMChainExtractor\n", 1043 | "from langchain.retrievers import ContextualCompressionRetriever\n", 1044 | "\n", 1045 | "compressor = LLMChainExtractor.from_llm(llm)\n", 1046 | "compression_retriever = ContextualCompressionRetriever(base_compressor=compressor, base_retriever=retriever_from_llm)" 1047 | ] 1048 | }, 1049 | { 1050 | "cell_type": "code", 1051 | "execution_count": 37, 1052 | "metadata": {}, 1053 | "outputs": [], 1054 | "source": [ 1055 | "import logging\n", 1056 | "logging.getLogger(\"langchain.retrievers.multi_query\").setLevel(logging.DEBUG)" 1057 | ] 1058 | }, 1059 | { 1060 | "cell_type": "code", 1061 | "execution_count": 38, 1062 | "metadata": {}, 1063 | "outputs": [ 1064 | { 1065 | "name": "stderr", 1066 | "output_type": "stream", 1067 | "text": [ 1068 | "/home/voyagerke/.local/lib/python3.10/site-packages/transformers/pipelines/base.py:1083: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset\n", 1069 | " warnings.warn(\n" 1070 | ] 1071 | }, 1072 | { 1073 | "name": "stdout", 1074 | "output_type": "stream", 1075 | "text": [ 1076 | "[Document(page_content='\"全球临干阶段的新药研发依然活跃\"', metadata={'page': 0, 'source': './finance.pdf'}), Document(page_content='\"生命科学上游服务商的收入,则受到了下游企业去库存周期的影响\"', metadata={'page': 0, 'source': './finance.pdf'}), Document(page_content='\"生命科学上游服务商的收入,则受到了下游企业去库存周期的影响\"', metadata={'page': 4, 'source': './finance.pdf'}), Document(page_content='\"全球生物医药领域的投融资已出现回暖\"', metadata={'page': 2, 'source': './finance.pdf'}), Document(page_content='\"生物医药投融资恢复不及预期\" and \"去库存周期长于预期\".', metadata={'page': 3, 'source': './finance.pdf'}), Document(page_content='Repligen, Waters, MerckKGaA, Sartorius are representatives of overseas life science upstream suppliers.', metadata={'page': 2, 'source': './finance.pdf'}), Document(page_content='IQVIA, Medpace, CRO, Q2, RFP, business growth, new contracts, revenue increase, client engagement,\\noverall performance, industry outlook.', metadata={'page': 1, 'source': './finance.pdf'})]\n" 1077 | ] 1078 | } 1079 | ], 1080 | "source": [ 1081 | "retri_docs = compression_retriever.get_relevant_documents('医疗健康投资的风险因素有哪些?')\n", 1082 | "print(retri_docs)" 1083 | ] 1084 | }, 1085 | { 1086 | "cell_type": "code", 1087 | "execution_count": 41, 1088 | "metadata": { 1089 | "scrolled": true 1090 | }, 1091 | "outputs": [], 1092 | "source": [ 1093 | "qa = RetrievalQA.from_chain_type(\n", 1094 | " llm = llm,\n", 1095 | " chain_type = 'stuff',\n", 1096 | " retriever = compression_retriever,\n", 1097 | " return_source_documents = True,\n", 1098 | " chain_type_kwargs = {\"prompt\": prompt, \"memory\": memory}\n", 1099 | ")" 1100 | ] 1101 | }, 1102 | { 1103 | "cell_type": "markdown", 1104 | "metadata": {}, 1105 | "source": [ 1106 | "# Q&A" 1107 | ] 1108 | }, 1109 | { 1110 | "cell_type": "code", 1111 | "execution_count": 42, 1112 | "metadata": {}, 1113 | "outputs": [ 1114 | { 1115 | "name": "stdin", 1116 | "output_type": "stream", 1117 | "text": [ 1118 | "\n", 1119 | "Enter a query: 医疗健康投资的风险因素有哪些?\n" 1120 | ] 1121 | }, 1122 | { 1123 | "name": "stdout", 1124 | "output_type": "stream", 1125 | "text": [ 1126 | "{'query': '医疗健康投资的风险因素有哪些?', 'result': ' 在医疗健康行业中进行投资时,可能会面临以下一些主要风险因素:1)政府法规和监管变化;2)技术创新与市场需求的失衡;3)公司治理问题;4)经济波动对消费者支付力度的影响;5)人才流失等。此外,还应注意其他特定行业或项目的风险,如基因工程、生物制品安全性等方面的风险。 ', 'source_documents': [Document(page_content='\"全球临干阶段的新药研发依然活跃\"', metadata={'page': 0, 'source': './finance.pdf'}), Document(page_content='\"生命科学上游服务商的收入,则受到了下游企业去库存周期的影响\"', metadata={'page': 0, 'source': './finance.pdf'}), Document(page_content='\"生命科学上游服务商的收入,则受到了下游企业去库存周期的影响\"', metadata={'page': 4, 'source': './finance.pdf'}), Document(page_content='\"全球生物医药领域的投融资已出现回暖\"', metadata={'page': 2, 'source': './finance.pdf'}), Document(page_content='\"生物医药投融资恢复不及预期\" and \"去库存周期长于预期\".', metadata={'page': 3, 'source': './finance.pdf'}), Document(page_content='Repligen, Waters, MerckKGaA, Sartorius are representatives of overseas life science upstream suppliers.', metadata={'page': 2, 'source': './finance.pdf'}), Document(page_content='IQVIA, Medpace, CRO, Q2, RFP, business growth, new contracts, revenue increase, client engagement,\\nbusiness outlook, industry trends.', metadata={'page': 1, 'source': './finance.pdf'})]}\n" 1127 | ] 1128 | } 1129 | ], 1130 | "source": [ 1131 | "query = input(\"\\nEnter a query: \")\n", 1132 | "res = qa(query)\n", 1133 | "print(res)" 1134 | ] 1135 | }, 1136 | { 1137 | "cell_type": "code", 1138 | "execution_count": null, 1139 | "metadata": {}, 1140 | "outputs": [], 1141 | "source": [] 1142 | } 1143 | ], 1144 | "metadata": { 1145 | "accelerator": "GPU", 1146 | "colab": { 1147 | "authorship_tag": "ABX9TyMn/dsfgwYF5S8zw5naOMhL", 1148 | "gpuType": "T4", 1149 | "provenance": [] 1150 | }, 1151 | "kernelspec": { 1152 | "display_name": "Python 3 (ipykernel)", 1153 | "language": "python", 1154 | "name": "python3" 1155 | }, 1156 | "language_info": { 1157 | "codemirror_mode": { 1158 | "name": "ipython", 1159 | "version": 3 1160 | }, 1161 | "file_extension": ".py", 1162 | "mimetype": "text/x-python", 1163 | "name": "python", 1164 | "nbconvert_exporter": "python", 1165 | "pygments_lexer": "ipython3", 1166 | "version": "3.10.12" 1167 | }, 1168 | "widgets": { 1169 | "application/vnd.jupyter.widget-state+json": { 1170 | "004d1bd60ce346c29af7b9b03fa8e81d": { 1171 | "model_module": "@jupyter-widgets/base", 1172 | "model_module_version": "1.2.0", 1173 | "model_name": "LayoutModel", 1174 | "state": { 1175 | "_model_module": "@jupyter-widgets/base", 1176 | "_model_module_version": "1.2.0", 1177 | "_model_name": "LayoutModel", 1178 | "_view_count": null, 1179 | "_view_module": "@jupyter-widgets/base", 1180 | "_view_module_version": "1.2.0", 1181 | "_view_name": "LayoutView", 1182 | "align_content": null, 1183 | "align_items": null, 1184 | "align_self": null, 1185 | "border": null, 1186 | "bottom": null, 1187 | "display": null, 1188 | "flex": null, 1189 | "flex_flow": null, 1190 | "grid_area": null, 1191 | "grid_auto_columns": null, 1192 | "grid_auto_flow": null, 1193 | "grid_auto_rows": null, 1194 | "grid_column": null, 1195 | "grid_gap": null, 1196 | "grid_row": null, 1197 | "grid_template_areas": null, 1198 | "grid_template_columns": null, 1199 | "grid_template_rows": null, 1200 | "height": null, 1201 | "justify_content": null, 1202 | "justify_items": null, 1203 | "left": null, 1204 | "margin": null, 1205 | "max_height": null, 1206 | "max_width": null, 1207 | "min_height": null, 1208 | "min_width": null, 1209 | "object_fit": null, 1210 | "object_position": null, 1211 | "order": null, 1212 | "overflow": null, 1213 | "overflow_x": null, 1214 | "overflow_y": null, 1215 | "padding": null, 1216 | "right": null, 1217 | "top": null, 1218 | "visibility": null, 1219 | "width": null 1220 | } 1221 | }, 1222 | "01df2cfd842b4168a5b2c9f1822fc875": { 1223 | "model_module": "@jupyter-widgets/base", 1224 | "model_module_version": "1.2.0", 1225 | "model_name": "LayoutModel", 1226 | "state": { 1227 | "_model_module": "@jupyter-widgets/base", 1228 | "_model_module_version": "1.2.0", 1229 | "_model_name": "LayoutModel", 1230 | "_view_count": null, 1231 | "_view_module": "@jupyter-widgets/base", 1232 | "_view_module_version": "1.2.0", 1233 | "_view_name": "LayoutView", 1234 | "align_content": null, 1235 | "align_items": null, 1236 | "align_self": null, 1237 | "border": null, 1238 | "bottom": null, 1239 | "display": null, 1240 | "flex": null, 1241 | "flex_flow": null, 1242 | "grid_area": null, 1243 | "grid_auto_columns": null, 1244 | "grid_auto_flow": null, 1245 | "grid_auto_rows": null, 1246 | "grid_column": null, 1247 | "grid_gap": null, 1248 | "grid_row": null, 1249 | "grid_template_areas": null, 1250 | "grid_template_columns": null, 1251 | "grid_template_rows": null, 1252 | "height": null, 1253 | "justify_content": null, 1254 | "justify_items": null, 1255 | "left": null, 1256 | "margin": null, 1257 | "max_height": null, 1258 | "max_width": null, 1259 | "min_height": null, 1260 | "min_width": null, 1261 | "object_fit": null, 1262 | "object_position": null, 1263 | "order": null, 1264 | "overflow": null, 1265 | "overflow_x": null, 1266 | "overflow_y": null, 1267 | "padding": null, 1268 | "right": null, 1269 | "top": null, 1270 | "visibility": null, 1271 | "width": null 1272 | } 1273 | }, 1274 | "0da0da8ffc18498bb676221d768fd339": { 1275 | "model_module": "@jupyter-widgets/base", 1276 | "model_module_version": "1.2.0", 1277 | "model_name": "LayoutModel", 1278 | "state": { 1279 | "_model_module": "@jupyter-widgets/base", 1280 | "_model_module_version": "1.2.0", 1281 | "_model_name": "LayoutModel", 1282 | "_view_count": null, 1283 | "_view_module": "@jupyter-widgets/base", 1284 | "_view_module_version": "1.2.0", 1285 | "_view_name": "LayoutView", 1286 | "align_content": null, 1287 | "align_items": null, 1288 | "align_self": null, 1289 | "border": null, 1290 | "bottom": null, 1291 | "display": null, 1292 | "flex": null, 1293 | "flex_flow": null, 1294 | "grid_area": null, 1295 | "grid_auto_columns": null, 1296 | "grid_auto_flow": null, 1297 | "grid_auto_rows": null, 1298 | "grid_column": null, 1299 | "grid_gap": null, 1300 | "grid_row": null, 1301 | "grid_template_areas": null, 1302 | "grid_template_columns": null, 1303 | "grid_template_rows": null, 1304 | "height": null, 1305 | "justify_content": null, 1306 | "justify_items": null, 1307 | "left": null, 1308 | "margin": null, 1309 | "max_height": null, 1310 | "max_width": null, 1311 | "min_height": null, 1312 | "min_width": null, 1313 | "object_fit": null, 1314 | "object_position": null, 1315 | "order": null, 1316 | "overflow": null, 1317 | "overflow_x": null, 1318 | "overflow_y": null, 1319 | "padding": null, 1320 | "right": null, 1321 | "top": null, 1322 | "visibility": null, 1323 | "width": null 1324 | } 1325 | }, 1326 | "0f8bfea3563c4cf0b8a0024e347dfc96": { 1327 | "model_module": "@jupyter-widgets/controls", 1328 | "model_module_version": "1.5.0", 1329 | "model_name": "DescriptionStyleModel", 1330 | "state": { 1331 | "_model_module": "@jupyter-widgets/controls", 1332 | "_model_module_version": "1.5.0", 1333 | "_model_name": "DescriptionStyleModel", 1334 | "_view_count": null, 1335 | "_view_module": "@jupyter-widgets/base", 1336 | "_view_module_version": "1.2.0", 1337 | "_view_name": "StyleView", 1338 | "description_width": "" 1339 | } 1340 | }, 1341 | "106890bf2ad54901985071bd80e102c5": { 1342 | "model_module": "@jupyter-widgets/controls", 1343 | "model_module_version": "1.5.0", 1344 | "model_name": "DescriptionStyleModel", 1345 | "state": { 1346 | "_model_module": "@jupyter-widgets/controls", 1347 | "_model_module_version": "1.5.0", 1348 | "_model_name": "DescriptionStyleModel", 1349 | "_view_count": null, 1350 | "_view_module": "@jupyter-widgets/base", 1351 | "_view_module_version": "1.2.0", 1352 | "_view_name": "StyleView", 1353 | "description_width": "" 1354 | } 1355 | }, 1356 | "12aff629989341fdbd8c23465fe43e10": { 1357 | "model_module": "@jupyter-widgets/base", 1358 | "model_module_version": "1.2.0", 1359 | "model_name": "LayoutModel", 1360 | "state": { 1361 | "_model_module": "@jupyter-widgets/base", 1362 | "_model_module_version": "1.2.0", 1363 | "_model_name": "LayoutModel", 1364 | "_view_count": null, 1365 | "_view_module": "@jupyter-widgets/base", 1366 | "_view_module_version": "1.2.0", 1367 | "_view_name": "LayoutView", 1368 | "align_content": null, 1369 | "align_items": null, 1370 | "align_self": null, 1371 | "border": null, 1372 | "bottom": null, 1373 | "display": null, 1374 | "flex": null, 1375 | "flex_flow": null, 1376 | "grid_area": null, 1377 | "grid_auto_columns": null, 1378 | "grid_auto_flow": null, 1379 | "grid_auto_rows": null, 1380 | "grid_column": null, 1381 | "grid_gap": null, 1382 | "grid_row": null, 1383 | "grid_template_areas": null, 1384 | "grid_template_columns": null, 1385 | "grid_template_rows": null, 1386 | "height": null, 1387 | "justify_content": null, 1388 | "justify_items": null, 1389 | "left": null, 1390 | "margin": null, 1391 | "max_height": null, 1392 | "max_width": null, 1393 | "min_height": null, 1394 | "min_width": null, 1395 | "object_fit": null, 1396 | "object_position": null, 1397 | "order": null, 1398 | "overflow": null, 1399 | "overflow_x": null, 1400 | "overflow_y": null, 1401 | "padding": null, 1402 | "right": null, 1403 | "top": null, 1404 | "visibility": null, 1405 | "width": null 1406 | } 1407 | }, 1408 | "13269879221342949b321c2035079068": { 1409 | "model_module": "@jupyter-widgets/base", 1410 | "model_module_version": "1.2.0", 1411 | "model_name": "LayoutModel", 1412 | "state": { 1413 | "_model_module": "@jupyter-widgets/base", 1414 | "_model_module_version": "1.2.0", 1415 | "_model_name": "LayoutModel", 1416 | "_view_count": null, 1417 | "_view_module": "@jupyter-widgets/base", 1418 | "_view_module_version": "1.2.0", 1419 | "_view_name": "LayoutView", 1420 | "align_content": null, 1421 | "align_items": null, 1422 | "align_self": null, 1423 | "border": null, 1424 | "bottom": null, 1425 | "display": null, 1426 | "flex": null, 1427 | "flex_flow": null, 1428 | "grid_area": null, 1429 | "grid_auto_columns": null, 1430 | "grid_auto_flow": null, 1431 | "grid_auto_rows": null, 1432 | "grid_column": null, 1433 | "grid_gap": null, 1434 | "grid_row": null, 1435 | "grid_template_areas": null, 1436 | "grid_template_columns": null, 1437 | "grid_template_rows": null, 1438 | "height": null, 1439 | "justify_content": null, 1440 | "justify_items": null, 1441 | "left": null, 1442 | "margin": null, 1443 | "max_height": null, 1444 | "max_width": null, 1445 | "min_height": null, 1446 | "min_width": null, 1447 | "object_fit": null, 1448 | "object_position": null, 1449 | "order": null, 1450 | "overflow": null, 1451 | "overflow_x": null, 1452 | "overflow_y": null, 1453 | "padding": null, 1454 | "right": null, 1455 | "top": null, 1456 | "visibility": null, 1457 | "width": null 1458 | } 1459 | }, 1460 | "1dae3525d2c94656bcda3c8ea2cdf7d6": { 1461 | "model_module": "@jupyter-widgets/base", 1462 | "model_module_version": "1.2.0", 1463 | "model_name": "LayoutModel", 1464 | "state": { 1465 | "_model_module": "@jupyter-widgets/base", 1466 | "_model_module_version": "1.2.0", 1467 | "_model_name": "LayoutModel", 1468 | "_view_count": null, 1469 | "_view_module": "@jupyter-widgets/base", 1470 | "_view_module_version": "1.2.0", 1471 | "_view_name": "LayoutView", 1472 | "align_content": null, 1473 | "align_items": null, 1474 | "align_self": null, 1475 | "border": null, 1476 | "bottom": null, 1477 | "display": null, 1478 | "flex": null, 1479 | "flex_flow": null, 1480 | "grid_area": null, 1481 | "grid_auto_columns": null, 1482 | "grid_auto_flow": null, 1483 | "grid_auto_rows": null, 1484 | "grid_column": null, 1485 | "grid_gap": null, 1486 | "grid_row": null, 1487 | "grid_template_areas": null, 1488 | "grid_template_columns": null, 1489 | "grid_template_rows": null, 1490 | "height": null, 1491 | "justify_content": null, 1492 | "justify_items": null, 1493 | "left": null, 1494 | "margin": null, 1495 | "max_height": null, 1496 | "max_width": null, 1497 | "min_height": null, 1498 | "min_width": null, 1499 | "object_fit": null, 1500 | "object_position": null, 1501 | "order": null, 1502 | "overflow": null, 1503 | "overflow_x": null, 1504 | "overflow_y": null, 1505 | "padding": null, 1506 | "right": null, 1507 | "top": null, 1508 | "visibility": null, 1509 | "width": null 1510 | } 1511 | }, 1512 | "217de16416484c92b77b187222607d92": { 1513 | "model_module": "@jupyter-widgets/controls", 1514 | "model_module_version": "1.5.0", 1515 | "model_name": "ProgressStyleModel", 1516 | "state": { 1517 | "_model_module": "@jupyter-widgets/controls", 1518 | "_model_module_version": "1.5.0", 1519 | "_model_name": "ProgressStyleModel", 1520 | "_view_count": null, 1521 | "_view_module": "@jupyter-widgets/base", 1522 | "_view_module_version": "1.2.0", 1523 | "_view_name": "StyleView", 1524 | "bar_color": null, 1525 | "description_width": "" 1526 | } 1527 | }, 1528 | "27466edededd40f988b935d9471eaf3f": { 1529 | "model_module": "@jupyter-widgets/controls", 1530 | "model_module_version": "1.5.0", 1531 | "model_name": "FloatProgressModel", 1532 | "state": { 1533 | "_dom_classes": [], 1534 | "_model_module": "@jupyter-widgets/controls", 1535 | "_model_module_version": "1.5.0", 1536 | "_model_name": "FloatProgressModel", 1537 | "_view_count": null, 1538 | "_view_module": "@jupyter-widgets/controls", 1539 | "_view_module_version": "1.5.0", 1540 | "_view_name": "ProgressView", 1541 | "bar_style": "success", 1542 | "description": "", 1543 | "description_tooltip": null, 1544 | "layout": "IPY_MODEL_ac0deace83194ef79754ae5cf78242cb", 1545 | "max": 9976637886, 1546 | "min": 0, 1547 | "orientation": "horizontal", 1548 | "style": "IPY_MODEL_686c627bad6149508d52b7a9bbc76dd1", 1549 | "value": 9976637886 1550 | } 1551 | }, 1552 | "290bba95208d41a9859be6fdf0fd9162": { 1553 | "model_module": "@jupyter-widgets/controls", 1554 | "model_module_version": "1.5.0", 1555 | "model_name": "HTMLModel", 1556 | "state": { 1557 | "_dom_classes": [], 1558 | "_model_module": "@jupyter-widgets/controls", 1559 | "_model_module_version": "1.5.0", 1560 | "_model_name": "HTMLModel", 1561 | "_view_count": null, 1562 | "_view_module": "@jupyter-widgets/controls", 1563 | "_view_module_version": "1.5.0", 1564 | "_view_name": "HTMLView", 1565 | "description": "", 1566 | "description_tooltip": null, 1567 | "layout": "IPY_MODEL_ac18d1c538f84444861d4255377a603c", 1568 | "placeholder": "​", 1569 | "style": "IPY_MODEL_a2260c5958d04f9a8ef16e9f33045425", 1570 | "value": "Downloading (…)model.bin.index.json: 100%" 1571 | } 1572 | }, 1573 | "2aac1bdbeff94ee2a462db962ece1b5f": { 1574 | "model_module": "@jupyter-widgets/controls", 1575 | "model_module_version": "1.5.0", 1576 | "model_name": "HTMLModel", 1577 | "state": { 1578 | "_dom_classes": [], 1579 | "_model_module": "@jupyter-widgets/controls", 1580 | "_model_module_version": "1.5.0", 1581 | "_model_name": "HTMLModel", 1582 | "_view_count": null, 1583 | "_view_module": "@jupyter-widgets/controls", 1584 | "_view_module_version": "1.5.0", 1585 | "_view_name": "HTMLView", 1586 | "description": "", 1587 | "description_tooltip": null, 1588 | "layout": "IPY_MODEL_004d1bd60ce346c29af7b9b03fa8e81d", 1589 | "placeholder": "​", 1590 | "style": "IPY_MODEL_690d47749161426c82dee36209ea1de3", 1591 | "value": " 9.98G/9.98G [01:17<00:00, 261MB/s]" 1592 | } 1593 | }, 1594 | "34719f671b1143f98d4e92611dac6dce": { 1595 | "model_module": "@jupyter-widgets/controls", 1596 | "model_module_version": "1.5.0", 1597 | "model_name": "DescriptionStyleModel", 1598 | "state": { 1599 | "_model_module": "@jupyter-widgets/controls", 1600 | "_model_module_version": "1.5.0", 1601 | "_model_name": "DescriptionStyleModel", 1602 | "_view_count": null, 1603 | "_view_module": "@jupyter-widgets/base", 1604 | "_view_module_version": "1.2.0", 1605 | "_view_name": "StyleView", 1606 | "description_width": "" 1607 | } 1608 | }, 1609 | "372e13b30ab7400993861d3523a3c268": { 1610 | "model_module": "@jupyter-widgets/controls", 1611 | "model_module_version": "1.5.0", 1612 | "model_name": "HBoxModel", 1613 | "state": { 1614 | "_dom_classes": [], 1615 | "_model_module": "@jupyter-widgets/controls", 1616 | "_model_module_version": "1.5.0", 1617 | "_model_name": "HBoxModel", 1618 | "_view_count": null, 1619 | "_view_module": "@jupyter-widgets/controls", 1620 | "_view_module_version": "1.5.0", 1621 | "_view_name": "HBoxView", 1622 | "box_style": "", 1623 | "children": [ 1624 | "IPY_MODEL_f48c4bd3516d4134b08cf9536d44da37", 1625 | "IPY_MODEL_27466edededd40f988b935d9471eaf3f", 1626 | "IPY_MODEL_2aac1bdbeff94ee2a462db962ece1b5f" 1627 | ], 1628 | "layout": "IPY_MODEL_f2d5d5f9c7e2405c8e9defeab42778d3" 1629 | } 1630 | }, 1631 | "3966c4b83dea4e7d92f44985f020c491": { 1632 | "model_module": "@jupyter-widgets/controls", 1633 | "model_module_version": "1.5.0", 1634 | "model_name": "ProgressStyleModel", 1635 | "state": { 1636 | "_model_module": "@jupyter-widgets/controls", 1637 | "_model_module_version": "1.5.0", 1638 | "_model_name": "ProgressStyleModel", 1639 | "_view_count": null, 1640 | "_view_module": "@jupyter-widgets/base", 1641 | "_view_module_version": "1.2.0", 1642 | "_view_name": "StyleView", 1643 | "bar_color": null, 1644 | "description_width": "" 1645 | } 1646 | }, 1647 | "39a7407817004510b85e45949bf4532a": { 1648 | "model_module": "@jupyter-widgets/base", 1649 | "model_module_version": "1.2.0", 1650 | "model_name": "LayoutModel", 1651 | "state": { 1652 | "_model_module": "@jupyter-widgets/base", 1653 | "_model_module_version": "1.2.0", 1654 | "_model_name": "LayoutModel", 1655 | "_view_count": null, 1656 | "_view_module": "@jupyter-widgets/base", 1657 | "_view_module_version": "1.2.0", 1658 | "_view_name": "LayoutView", 1659 | "align_content": null, 1660 | "align_items": null, 1661 | "align_self": null, 1662 | "border": null, 1663 | "bottom": null, 1664 | "display": null, 1665 | "flex": null, 1666 | "flex_flow": null, 1667 | "grid_area": null, 1668 | "grid_auto_columns": null, 1669 | "grid_auto_flow": null, 1670 | "grid_auto_rows": null, 1671 | "grid_column": null, 1672 | "grid_gap": null, 1673 | "grid_row": null, 1674 | "grid_template_areas": null, 1675 | "grid_template_columns": null, 1676 | "grid_template_rows": null, 1677 | "height": null, 1678 | "justify_content": null, 1679 | "justify_items": null, 1680 | "left": null, 1681 | "margin": null, 1682 | "max_height": null, 1683 | "max_width": null, 1684 | "min_height": null, 1685 | "min_width": null, 1686 | "object_fit": null, 1687 | "object_position": null, 1688 | "order": null, 1689 | "overflow": null, 1690 | "overflow_x": null, 1691 | "overflow_y": null, 1692 | "padding": null, 1693 | "right": null, 1694 | "top": null, 1695 | "visibility": null, 1696 | "width": null 1697 | } 1698 | }, 1699 | "3c32370319e54395bcc7d129aaab84bd": { 1700 | "model_module": "@jupyter-widgets/base", 1701 | "model_module_version": "1.2.0", 1702 | "model_name": "LayoutModel", 1703 | "state": { 1704 | "_model_module": "@jupyter-widgets/base", 1705 | "_model_module_version": "1.2.0", 1706 | "_model_name": "LayoutModel", 1707 | "_view_count": null, 1708 | "_view_module": "@jupyter-widgets/base", 1709 | "_view_module_version": "1.2.0", 1710 | "_view_name": "LayoutView", 1711 | "align_content": null, 1712 | "align_items": null, 1713 | "align_self": null, 1714 | "border": null, 1715 | "bottom": null, 1716 | "display": null, 1717 | "flex": null, 1718 | "flex_flow": null, 1719 | "grid_area": null, 1720 | "grid_auto_columns": null, 1721 | "grid_auto_flow": null, 1722 | "grid_auto_rows": null, 1723 | "grid_column": null, 1724 | "grid_gap": null, 1725 | "grid_row": null, 1726 | "grid_template_areas": null, 1727 | "grid_template_columns": null, 1728 | "grid_template_rows": null, 1729 | "height": null, 1730 | "justify_content": null, 1731 | "justify_items": null, 1732 | "left": null, 1733 | "margin": null, 1734 | "max_height": null, 1735 | "max_width": null, 1736 | "min_height": null, 1737 | "min_width": null, 1738 | "object_fit": null, 1739 | "object_position": null, 1740 | "order": null, 1741 | "overflow": null, 1742 | "overflow_x": null, 1743 | "overflow_y": null, 1744 | "padding": null, 1745 | "right": null, 1746 | "top": null, 1747 | "visibility": null, 1748 | "width": null 1749 | } 1750 | }, 1751 | "4a24d0a8293548a4967c9b7d3cd0fe93": { 1752 | "model_module": "@jupyter-widgets/base", 1753 | "model_module_version": "1.2.0", 1754 | "model_name": "LayoutModel", 1755 | "state": { 1756 | "_model_module": "@jupyter-widgets/base", 1757 | "_model_module_version": "1.2.0", 1758 | "_model_name": "LayoutModel", 1759 | "_view_count": null, 1760 | "_view_module": "@jupyter-widgets/base", 1761 | "_view_module_version": "1.2.0", 1762 | "_view_name": "LayoutView", 1763 | "align_content": null, 1764 | "align_items": null, 1765 | "align_self": null, 1766 | "border": null, 1767 | "bottom": null, 1768 | "display": null, 1769 | "flex": null, 1770 | "flex_flow": null, 1771 | "grid_area": null, 1772 | "grid_auto_columns": null, 1773 | "grid_auto_flow": null, 1774 | "grid_auto_rows": null, 1775 | "grid_column": null, 1776 | "grid_gap": null, 1777 | "grid_row": null, 1778 | "grid_template_areas": null, 1779 | "grid_template_columns": null, 1780 | "grid_template_rows": null, 1781 | "height": null, 1782 | "justify_content": null, 1783 | "justify_items": null, 1784 | "left": null, 1785 | "margin": null, 1786 | "max_height": null, 1787 | "max_width": null, 1788 | "min_height": null, 1789 | "min_width": null, 1790 | "object_fit": null, 1791 | "object_position": null, 1792 | "order": null, 1793 | "overflow": null, 1794 | "overflow_x": null, 1795 | "overflow_y": null, 1796 | "padding": null, 1797 | "right": null, 1798 | "top": null, 1799 | "visibility": null, 1800 | "width": null 1801 | } 1802 | }, 1803 | "4adfcca6abeb46bd82ea2f7323c518bb": { 1804 | "model_module": "@jupyter-widgets/controls", 1805 | "model_module_version": "1.5.0", 1806 | "model_name": "ProgressStyleModel", 1807 | "state": { 1808 | "_model_module": "@jupyter-widgets/controls", 1809 | "_model_module_version": "1.5.0", 1810 | "_model_name": "ProgressStyleModel", 1811 | "_view_count": null, 1812 | "_view_module": "@jupyter-widgets/base", 1813 | "_view_module_version": "1.2.0", 1814 | "_view_name": "StyleView", 1815 | "bar_color": null, 1816 | "description_width": "" 1817 | } 1818 | }, 1819 | "4f7ac39e566640e29173c7390879ecc2": { 1820 | "model_module": "@jupyter-widgets/controls", 1821 | "model_module_version": "1.5.0", 1822 | "model_name": "ProgressStyleModel", 1823 | "state": { 1824 | "_model_module": "@jupyter-widgets/controls", 1825 | "_model_module_version": "1.5.0", 1826 | "_model_name": "ProgressStyleModel", 1827 | "_view_count": null, 1828 | "_view_module": "@jupyter-widgets/base", 1829 | "_view_module_version": "1.2.0", 1830 | "_view_name": "StyleView", 1831 | "bar_color": null, 1832 | "description_width": "" 1833 | } 1834 | }, 1835 | "5b0edbb973ab4b0aa0ff4e6426465dcf": { 1836 | "model_module": "@jupyter-widgets/controls", 1837 | "model_module_version": "1.5.0", 1838 | "model_name": "HTMLModel", 1839 | "state": { 1840 | "_dom_classes": [], 1841 | "_model_module": "@jupyter-widgets/controls", 1842 | "_model_module_version": "1.5.0", 1843 | "_model_name": "HTMLModel", 1844 | "_view_count": null, 1845 | "_view_module": "@jupyter-widgets/controls", 1846 | "_view_module_version": "1.5.0", 1847 | "_view_name": "HTMLView", 1848 | "description": "", 1849 | "description_tooltip": null, 1850 | "layout": "IPY_MODEL_12aff629989341fdbd8c23465fe43e10", 1851 | "placeholder": "​", 1852 | "style": "IPY_MODEL_9abd89ae79e04ce686c3103cd29af08f", 1853 | "value": "Downloading shards: 100%" 1854 | } 1855 | }, 1856 | "60210099713d4f03967b7b738153aabf": { 1857 | "model_module": "@jupyter-widgets/controls", 1858 | "model_module_version": "1.5.0", 1859 | "model_name": "DescriptionStyleModel", 1860 | "state": { 1861 | "_model_module": "@jupyter-widgets/controls", 1862 | "_model_module_version": "1.5.0", 1863 | "_model_name": "DescriptionStyleModel", 1864 | "_view_count": null, 1865 | "_view_module": "@jupyter-widgets/base", 1866 | "_view_module_version": "1.2.0", 1867 | "_view_name": "StyleView", 1868 | "description_width": "" 1869 | } 1870 | }, 1871 | "652d98faf01845b38baadf89af5f7c10": { 1872 | "model_module": "@jupyter-widgets/controls", 1873 | "model_module_version": "1.5.0", 1874 | "model_name": "DescriptionStyleModel", 1875 | "state": { 1876 | "_model_module": "@jupyter-widgets/controls", 1877 | "_model_module_version": "1.5.0", 1878 | "_model_name": "DescriptionStyleModel", 1879 | "_view_count": null, 1880 | "_view_module": "@jupyter-widgets/base", 1881 | "_view_module_version": "1.2.0", 1882 | "_view_name": "StyleView", 1883 | "description_width": "" 1884 | } 1885 | }, 1886 | "6753ef627c3241efb2f532c68ef26d42": { 1887 | "model_module": "@jupyter-widgets/controls", 1888 | "model_module_version": "1.5.0", 1889 | "model_name": "FloatProgressModel", 1890 | "state": { 1891 | "_dom_classes": [], 1892 | "_model_module": "@jupyter-widgets/controls", 1893 | "_model_module_version": "1.5.0", 1894 | "_model_name": "FloatProgressModel", 1895 | "_view_count": null, 1896 | "_view_module": "@jupyter-widgets/controls", 1897 | "_view_module_version": "1.5.0", 1898 | "_view_name": "ProgressView", 1899 | "bar_style": "success", 1900 | "description": "", 1901 | "description_tooltip": null, 1902 | "layout": "IPY_MODEL_0da0da8ffc18498bb676221d768fd339", 1903 | "max": 26788, 1904 | "min": 0, 1905 | "orientation": "horizontal", 1906 | "style": "IPY_MODEL_217de16416484c92b77b187222607d92", 1907 | "value": 26788 1908 | } 1909 | }, 1910 | "686c627bad6149508d52b7a9bbc76dd1": { 1911 | "model_module": "@jupyter-widgets/controls", 1912 | "model_module_version": "1.5.0", 1913 | "model_name": "ProgressStyleModel", 1914 | "state": { 1915 | "_model_module": "@jupyter-widgets/controls", 1916 | "_model_module_version": "1.5.0", 1917 | "_model_name": "ProgressStyleModel", 1918 | "_view_count": null, 1919 | "_view_module": "@jupyter-widgets/base", 1920 | "_view_module_version": "1.2.0", 1921 | "_view_name": "StyleView", 1922 | "bar_color": null, 1923 | "description_width": "" 1924 | } 1925 | }, 1926 | "690d47749161426c82dee36209ea1de3": { 1927 | "model_module": "@jupyter-widgets/controls", 1928 | "model_module_version": "1.5.0", 1929 | "model_name": "DescriptionStyleModel", 1930 | "state": { 1931 | "_model_module": "@jupyter-widgets/controls", 1932 | "_model_module_version": "1.5.0", 1933 | "_model_name": "DescriptionStyleModel", 1934 | "_view_count": null, 1935 | "_view_module": "@jupyter-widgets/base", 1936 | "_view_module_version": "1.2.0", 1937 | "_view_name": "StyleView", 1938 | "description_width": "" 1939 | } 1940 | }, 1941 | "7022a295aff949ef8243406667d23b99": { 1942 | "model_module": "@jupyter-widgets/controls", 1943 | "model_module_version": "1.5.0", 1944 | "model_name": "HBoxModel", 1945 | "state": { 1946 | "_dom_classes": [], 1947 | "_model_module": "@jupyter-widgets/controls", 1948 | "_model_module_version": "1.5.0", 1949 | "_model_name": "HBoxModel", 1950 | "_view_count": null, 1951 | "_view_module": "@jupyter-widgets/controls", 1952 | "_view_module_version": "1.5.0", 1953 | "_view_name": "HBoxView", 1954 | "box_style": "", 1955 | "children": [ 1956 | "IPY_MODEL_b7d815284baa4b1686d62dc7f8370ce6", 1957 | "IPY_MODEL_820c9e5b15c54b5bafc886770059ab80", 1958 | "IPY_MODEL_727f8e555f4147828a65dda4c3d4e5f0" 1959 | ], 1960 | "layout": "IPY_MODEL_f299f204b11f4132bfc771680d9fc563" 1961 | } 1962 | }, 1963 | "727f8e555f4147828a65dda4c3d4e5f0": { 1964 | "model_module": "@jupyter-widgets/controls", 1965 | "model_module_version": "1.5.0", 1966 | "model_name": "HTMLModel", 1967 | "state": { 1968 | "_dom_classes": [], 1969 | "_model_module": "@jupyter-widgets/controls", 1970 | "_model_module_version": "1.5.0", 1971 | "_model_name": "HTMLModel", 1972 | "_view_count": null, 1973 | "_view_module": "@jupyter-widgets/controls", 1974 | "_view_module_version": "1.5.0", 1975 | "_view_name": "HTMLView", 1976 | "description": "", 1977 | "description_tooltip": null, 1978 | "layout": "IPY_MODEL_aca12d4a77314027b30b232ec010ef83", 1979 | "placeholder": "​", 1980 | "style": "IPY_MODEL_34719f671b1143f98d4e92611dac6dce", 1981 | "value": " 0/2 [00:00<?, ?it/s]" 1982 | } 1983 | }, 1984 | "7cf6c9715f22497a8708eb58e36829dd": { 1985 | "model_module": "@jupyter-widgets/base", 1986 | "model_module_version": "1.2.0", 1987 | "model_name": "LayoutModel", 1988 | "state": { 1989 | "_model_module": "@jupyter-widgets/base", 1990 | "_model_module_version": "1.2.0", 1991 | "_model_name": "LayoutModel", 1992 | "_view_count": null, 1993 | "_view_module": "@jupyter-widgets/base", 1994 | "_view_module_version": "1.2.0", 1995 | "_view_name": "LayoutView", 1996 | "align_content": null, 1997 | "align_items": null, 1998 | "align_self": null, 1999 | "border": null, 2000 | "bottom": null, 2001 | "display": null, 2002 | "flex": null, 2003 | "flex_flow": null, 2004 | "grid_area": null, 2005 | "grid_auto_columns": null, 2006 | "grid_auto_flow": null, 2007 | "grid_auto_rows": null, 2008 | "grid_column": null, 2009 | "grid_gap": null, 2010 | "grid_row": null, 2011 | "grid_template_areas": null, 2012 | "grid_template_columns": null, 2013 | "grid_template_rows": null, 2014 | "height": null, 2015 | "justify_content": null, 2016 | "justify_items": null, 2017 | "left": null, 2018 | "margin": null, 2019 | "max_height": null, 2020 | "max_width": null, 2021 | "min_height": null, 2022 | "min_width": null, 2023 | "object_fit": null, 2024 | "object_position": null, 2025 | "order": null, 2026 | "overflow": null, 2027 | "overflow_x": null, 2028 | "overflow_y": null, 2029 | "padding": null, 2030 | "right": null, 2031 | "top": null, 2032 | "visibility": null, 2033 | "width": null 2034 | } 2035 | }, 2036 | "820c9e5b15c54b5bafc886770059ab80": { 2037 | "model_module": "@jupyter-widgets/controls", 2038 | "model_module_version": "1.5.0", 2039 | "model_name": "FloatProgressModel", 2040 | "state": { 2041 | "_dom_classes": [], 2042 | "_model_module": "@jupyter-widgets/controls", 2043 | "_model_module_version": "1.5.0", 2044 | "_model_name": "FloatProgressModel", 2045 | "_view_count": null, 2046 | "_view_module": "@jupyter-widgets/controls", 2047 | "_view_module_version": "1.5.0", 2048 | "_view_name": "ProgressView", 2049 | "bar_style": "", 2050 | "description": "", 2051 | "description_tooltip": null, 2052 | "layout": "IPY_MODEL_01df2cfd842b4168a5b2c9f1822fc875", 2053 | "max": 2, 2054 | "min": 0, 2055 | "orientation": "horizontal", 2056 | "style": "IPY_MODEL_4f7ac39e566640e29173c7390879ecc2", 2057 | "value": 0 2058 | } 2059 | }, 2060 | "88f87969ad2444159b84c88ee5dbf13c": { 2061 | "model_module": "@jupyter-widgets/controls", 2062 | "model_module_version": "1.5.0", 2063 | "model_name": "HTMLModel", 2064 | "state": { 2065 | "_dom_classes": [], 2066 | "_model_module": "@jupyter-widgets/controls", 2067 | "_model_module_version": "1.5.0", 2068 | "_model_name": "HTMLModel", 2069 | "_view_count": null, 2070 | "_view_module": "@jupyter-widgets/controls", 2071 | "_view_module_version": "1.5.0", 2072 | "_view_name": "HTMLView", 2073 | "description": "", 2074 | "description_tooltip": null, 2075 | "layout": "IPY_MODEL_4a24d0a8293548a4967c9b7d3cd0fe93", 2076 | "placeholder": "​", 2077 | "style": "IPY_MODEL_ce046e7c5f2741a798666d018a7782db", 2078 | "value": " 3.50G/3.50G [00:24<00:00, 255MB/s]" 2079 | } 2080 | }, 2081 | "8a477b2736984ef8a76d7e3878323e8d": { 2082 | "model_module": "@jupyter-widgets/base", 2083 | "model_module_version": "1.2.0", 2084 | "model_name": "LayoutModel", 2085 | "state": { 2086 | "_model_module": "@jupyter-widgets/base", 2087 | "_model_module_version": "1.2.0", 2088 | "_model_name": "LayoutModel", 2089 | "_view_count": null, 2090 | "_view_module": "@jupyter-widgets/base", 2091 | "_view_module_version": "1.2.0", 2092 | "_view_name": "LayoutView", 2093 | "align_content": null, 2094 | "align_items": null, 2095 | "align_self": null, 2096 | "border": null, 2097 | "bottom": null, 2098 | "display": null, 2099 | "flex": null, 2100 | "flex_flow": null, 2101 | "grid_area": null, 2102 | "grid_auto_columns": null, 2103 | "grid_auto_flow": null, 2104 | "grid_auto_rows": null, 2105 | "grid_column": null, 2106 | "grid_gap": null, 2107 | "grid_row": null, 2108 | "grid_template_areas": null, 2109 | "grid_template_columns": null, 2110 | "grid_template_rows": null, 2111 | "height": null, 2112 | "justify_content": null, 2113 | "justify_items": null, 2114 | "left": null, 2115 | "margin": null, 2116 | "max_height": null, 2117 | "max_width": null, 2118 | "min_height": null, 2119 | "min_width": null, 2120 | "object_fit": null, 2121 | "object_position": null, 2122 | "order": null, 2123 | "overflow": null, 2124 | "overflow_x": null, 2125 | "overflow_y": null, 2126 | "padding": null, 2127 | "right": null, 2128 | "top": null, 2129 | "visibility": null, 2130 | "width": null 2131 | } 2132 | }, 2133 | "8f0ff2e87fc348b0bb48aa27555a3f49": { 2134 | "model_module": "@jupyter-widgets/controls", 2135 | "model_module_version": "1.5.0", 2136 | "model_name": "HTMLModel", 2137 | "state": { 2138 | "_dom_classes": [], 2139 | "_model_module": "@jupyter-widgets/controls", 2140 | "_model_module_version": "1.5.0", 2141 | "_model_name": "HTMLModel", 2142 | "_view_count": null, 2143 | "_view_module": "@jupyter-widgets/controls", 2144 | "_view_module_version": "1.5.0", 2145 | "_view_name": "HTMLView", 2146 | "description": "", 2147 | "description_tooltip": null, 2148 | "layout": "IPY_MODEL_95da6821ae4041158c26d4b4aa07646d", 2149 | "placeholder": "​", 2150 | "style": "IPY_MODEL_106890bf2ad54901985071bd80e102c5", 2151 | "value": "Downloading (…)l-00002-of-00002.bin: 100%" 2152 | } 2153 | }, 2154 | "95da6821ae4041158c26d4b4aa07646d": { 2155 | "model_module": "@jupyter-widgets/base", 2156 | "model_module_version": "1.2.0", 2157 | "model_name": "LayoutModel", 2158 | "state": { 2159 | "_model_module": "@jupyter-widgets/base", 2160 | "_model_module_version": "1.2.0", 2161 | "_model_name": "LayoutModel", 2162 | "_view_count": null, 2163 | "_view_module": "@jupyter-widgets/base", 2164 | "_view_module_version": "1.2.0", 2165 | "_view_name": "LayoutView", 2166 | "align_content": null, 2167 | "align_items": null, 2168 | "align_self": null, 2169 | "border": null, 2170 | "bottom": null, 2171 | "display": null, 2172 | "flex": null, 2173 | "flex_flow": null, 2174 | "grid_area": null, 2175 | "grid_auto_columns": null, 2176 | "grid_auto_flow": null, 2177 | "grid_auto_rows": null, 2178 | "grid_column": null, 2179 | "grid_gap": null, 2180 | "grid_row": null, 2181 | "grid_template_areas": null, 2182 | "grid_template_columns": null, 2183 | "grid_template_rows": null, 2184 | "height": null, 2185 | "justify_content": null, 2186 | "justify_items": null, 2187 | "left": null, 2188 | "margin": null, 2189 | "max_height": null, 2190 | "max_width": null, 2191 | "min_height": null, 2192 | "min_width": null, 2193 | "object_fit": null, 2194 | "object_position": null, 2195 | "order": null, 2196 | "overflow": null, 2197 | "overflow_x": null, 2198 | "overflow_y": null, 2199 | "padding": null, 2200 | "right": null, 2201 | "top": null, 2202 | "visibility": null, 2203 | "width": null 2204 | } 2205 | }, 2206 | "96108b6ca9204839af176eda7afd0049": { 2207 | "model_module": "@jupyter-widgets/base", 2208 | "model_module_version": "1.2.0", 2209 | "model_name": "LayoutModel", 2210 | "state": { 2211 | "_model_module": "@jupyter-widgets/base", 2212 | "_model_module_version": "1.2.0", 2213 | "_model_name": "LayoutModel", 2214 | "_view_count": null, 2215 | "_view_module": "@jupyter-widgets/base", 2216 | "_view_module_version": "1.2.0", 2217 | "_view_name": "LayoutView", 2218 | "align_content": null, 2219 | "align_items": null, 2220 | "align_self": null, 2221 | "border": null, 2222 | "bottom": null, 2223 | "display": null, 2224 | "flex": null, 2225 | "flex_flow": null, 2226 | "grid_area": null, 2227 | "grid_auto_columns": null, 2228 | "grid_auto_flow": null, 2229 | "grid_auto_rows": null, 2230 | "grid_column": null, 2231 | "grid_gap": null, 2232 | "grid_row": null, 2233 | "grid_template_areas": null, 2234 | "grid_template_columns": null, 2235 | "grid_template_rows": null, 2236 | "height": null, 2237 | "justify_content": null, 2238 | "justify_items": null, 2239 | "left": null, 2240 | "margin": null, 2241 | "max_height": null, 2242 | "max_width": null, 2243 | "min_height": null, 2244 | "min_width": null, 2245 | "object_fit": null, 2246 | "object_position": null, 2247 | "order": null, 2248 | "overflow": null, 2249 | "overflow_x": null, 2250 | "overflow_y": null, 2251 | "padding": null, 2252 | "right": null, 2253 | "top": null, 2254 | "visibility": null, 2255 | "width": null 2256 | } 2257 | }, 2258 | "99eb59e647dc40389ebe7fe6f9bae8d9": { 2259 | "model_module": "@jupyter-widgets/controls", 2260 | "model_module_version": "1.5.0", 2261 | "model_name": "HBoxModel", 2262 | "state": { 2263 | "_dom_classes": [], 2264 | "_model_module": "@jupyter-widgets/controls", 2265 | "_model_module_version": "1.5.0", 2266 | "_model_name": "HBoxModel", 2267 | "_view_count": null, 2268 | "_view_module": "@jupyter-widgets/controls", 2269 | "_view_module_version": "1.5.0", 2270 | "_view_name": "HBoxView", 2271 | "box_style": "", 2272 | "children": [ 2273 | "IPY_MODEL_8f0ff2e87fc348b0bb48aa27555a3f49", 2274 | "IPY_MODEL_bf20104fa2ad48c0a86960fb9fe5876a", 2275 | "IPY_MODEL_88f87969ad2444159b84c88ee5dbf13c" 2276 | ], 2277 | "layout": "IPY_MODEL_7cf6c9715f22497a8708eb58e36829dd" 2278 | } 2279 | }, 2280 | "9abd89ae79e04ce686c3103cd29af08f": { 2281 | "model_module": "@jupyter-widgets/controls", 2282 | "model_module_version": "1.5.0", 2283 | "model_name": "DescriptionStyleModel", 2284 | "state": { 2285 | "_model_module": "@jupyter-widgets/controls", 2286 | "_model_module_version": "1.5.0", 2287 | "_model_name": "DescriptionStyleModel", 2288 | "_view_count": null, 2289 | "_view_module": "@jupyter-widgets/base", 2290 | "_view_module_version": "1.2.0", 2291 | "_view_name": "StyleView", 2292 | "description_width": "" 2293 | } 2294 | }, 2295 | "a2260c5958d04f9a8ef16e9f33045425": { 2296 | "model_module": "@jupyter-widgets/controls", 2297 | "model_module_version": "1.5.0", 2298 | "model_name": "DescriptionStyleModel", 2299 | "state": { 2300 | "_model_module": "@jupyter-widgets/controls", 2301 | "_model_module_version": "1.5.0", 2302 | "_model_name": "DescriptionStyleModel", 2303 | "_view_count": null, 2304 | "_view_module": "@jupyter-widgets/base", 2305 | "_view_module_version": "1.2.0", 2306 | "_view_name": "StyleView", 2307 | "description_width": "" 2308 | } 2309 | }, 2310 | "ac0deace83194ef79754ae5cf78242cb": { 2311 | "model_module": "@jupyter-widgets/base", 2312 | "model_module_version": "1.2.0", 2313 | "model_name": "LayoutModel", 2314 | "state": { 2315 | "_model_module": "@jupyter-widgets/base", 2316 | "_model_module_version": "1.2.0", 2317 | "_model_name": "LayoutModel", 2318 | "_view_count": null, 2319 | "_view_module": "@jupyter-widgets/base", 2320 | "_view_module_version": "1.2.0", 2321 | "_view_name": "LayoutView", 2322 | "align_content": null, 2323 | "align_items": null, 2324 | "align_self": null, 2325 | "border": null, 2326 | "bottom": null, 2327 | "display": null, 2328 | "flex": null, 2329 | "flex_flow": null, 2330 | "grid_area": null, 2331 | "grid_auto_columns": null, 2332 | "grid_auto_flow": null, 2333 | "grid_auto_rows": null, 2334 | "grid_column": null, 2335 | "grid_gap": null, 2336 | "grid_row": null, 2337 | "grid_template_areas": null, 2338 | "grid_template_columns": null, 2339 | "grid_template_rows": null, 2340 | "height": null, 2341 | "justify_content": null, 2342 | "justify_items": null, 2343 | "left": null, 2344 | "margin": null, 2345 | "max_height": null, 2346 | "max_width": null, 2347 | "min_height": null, 2348 | "min_width": null, 2349 | "object_fit": null, 2350 | "object_position": null, 2351 | "order": null, 2352 | "overflow": null, 2353 | "overflow_x": null, 2354 | "overflow_y": null, 2355 | "padding": null, 2356 | "right": null, 2357 | "top": null, 2358 | "visibility": null, 2359 | "width": null 2360 | } 2361 | }, 2362 | "ac18d1c538f84444861d4255377a603c": { 2363 | "model_module": "@jupyter-widgets/base", 2364 | "model_module_version": "1.2.0", 2365 | "model_name": "LayoutModel", 2366 | "state": { 2367 | "_model_module": "@jupyter-widgets/base", 2368 | "_model_module_version": "1.2.0", 2369 | "_model_name": "LayoutModel", 2370 | "_view_count": null, 2371 | "_view_module": "@jupyter-widgets/base", 2372 | "_view_module_version": "1.2.0", 2373 | "_view_name": "LayoutView", 2374 | "align_content": null, 2375 | "align_items": null, 2376 | "align_self": null, 2377 | "border": null, 2378 | "bottom": null, 2379 | "display": null, 2380 | "flex": null, 2381 | "flex_flow": null, 2382 | "grid_area": null, 2383 | "grid_auto_columns": null, 2384 | "grid_auto_flow": null, 2385 | "grid_auto_rows": null, 2386 | "grid_column": null, 2387 | "grid_gap": null, 2388 | "grid_row": null, 2389 | "grid_template_areas": null, 2390 | "grid_template_columns": null, 2391 | "grid_template_rows": null, 2392 | "height": null, 2393 | "justify_content": null, 2394 | "justify_items": null, 2395 | "left": null, 2396 | "margin": null, 2397 | "max_height": null, 2398 | "max_width": null, 2399 | "min_height": null, 2400 | "min_width": null, 2401 | "object_fit": null, 2402 | "object_position": null, 2403 | "order": null, 2404 | "overflow": null, 2405 | "overflow_x": null, 2406 | "overflow_y": null, 2407 | "padding": null, 2408 | "right": null, 2409 | "top": null, 2410 | "visibility": null, 2411 | "width": null 2412 | } 2413 | }, 2414 | "aca12d4a77314027b30b232ec010ef83": { 2415 | "model_module": "@jupyter-widgets/base", 2416 | "model_module_version": "1.2.0", 2417 | "model_name": "LayoutModel", 2418 | "state": { 2419 | "_model_module": "@jupyter-widgets/base", 2420 | "_model_module_version": "1.2.0", 2421 | "_model_name": "LayoutModel", 2422 | "_view_count": null, 2423 | "_view_module": "@jupyter-widgets/base", 2424 | "_view_module_version": "1.2.0", 2425 | "_view_name": "LayoutView", 2426 | "align_content": null, 2427 | "align_items": null, 2428 | "align_self": null, 2429 | "border": null, 2430 | "bottom": null, 2431 | "display": null, 2432 | "flex": null, 2433 | "flex_flow": null, 2434 | "grid_area": null, 2435 | "grid_auto_columns": null, 2436 | "grid_auto_flow": null, 2437 | "grid_auto_rows": null, 2438 | "grid_column": null, 2439 | "grid_gap": null, 2440 | "grid_row": null, 2441 | "grid_template_areas": null, 2442 | "grid_template_columns": null, 2443 | "grid_template_rows": null, 2444 | "height": null, 2445 | "justify_content": null, 2446 | "justify_items": null, 2447 | "left": null, 2448 | "margin": null, 2449 | "max_height": null, 2450 | "max_width": null, 2451 | "min_height": null, 2452 | "min_width": null, 2453 | "object_fit": null, 2454 | "object_position": null, 2455 | "order": null, 2456 | "overflow": null, 2457 | "overflow_x": null, 2458 | "overflow_y": null, 2459 | "padding": null, 2460 | "right": null, 2461 | "top": null, 2462 | "visibility": null, 2463 | "width": null 2464 | } 2465 | }, 2466 | "b3ca2dda95c7458aa34e1affd35ce6c5": { 2467 | "model_module": "@jupyter-widgets/controls", 2468 | "model_module_version": "1.5.0", 2469 | "model_name": "HBoxModel", 2470 | "state": { 2471 | "_dom_classes": [], 2472 | "_model_module": "@jupyter-widgets/controls", 2473 | "_model_module_version": "1.5.0", 2474 | "_model_name": "HBoxModel", 2475 | "_view_count": null, 2476 | "_view_module": "@jupyter-widgets/controls", 2477 | "_view_module_version": "1.5.0", 2478 | "_view_name": "HBoxView", 2479 | "box_style": "", 2480 | "children": [ 2481 | "IPY_MODEL_290bba95208d41a9859be6fdf0fd9162", 2482 | "IPY_MODEL_6753ef627c3241efb2f532c68ef26d42", 2483 | "IPY_MODEL_c2ba7e405d0c41519270e48af899d6b8" 2484 | ], 2485 | "layout": "IPY_MODEL_8a477b2736984ef8a76d7e3878323e8d" 2486 | } 2487 | }, 2488 | "b7d815284baa4b1686d62dc7f8370ce6": { 2489 | "model_module": "@jupyter-widgets/controls", 2490 | "model_module_version": "1.5.0", 2491 | "model_name": "HTMLModel", 2492 | "state": { 2493 | "_dom_classes": [], 2494 | "_model_module": "@jupyter-widgets/controls", 2495 | "_model_module_version": "1.5.0", 2496 | "_model_name": "HTMLModel", 2497 | "_view_count": null, 2498 | "_view_module": "@jupyter-widgets/controls", 2499 | "_view_module_version": "1.5.0", 2500 | "_view_name": "HTMLView", 2501 | "description": "", 2502 | "description_tooltip": null, 2503 | "layout": "IPY_MODEL_13269879221342949b321c2035079068", 2504 | "placeholder": "​", 2505 | "style": "IPY_MODEL_60210099713d4f03967b7b738153aabf", 2506 | "value": "Loading checkpoint shards: 0%" 2507 | } 2508 | }, 2509 | "bf20104fa2ad48c0a86960fb9fe5876a": { 2510 | "model_module": "@jupyter-widgets/controls", 2511 | "model_module_version": "1.5.0", 2512 | "model_name": "FloatProgressModel", 2513 | "state": { 2514 | "_dom_classes": [], 2515 | "_model_module": "@jupyter-widgets/controls", 2516 | "_model_module_version": "1.5.0", 2517 | "_model_name": "FloatProgressModel", 2518 | "_view_count": null, 2519 | "_view_module": "@jupyter-widgets/controls", 2520 | "_view_module_version": "1.5.0", 2521 | "_view_name": "ProgressView", 2522 | "bar_style": "success", 2523 | "description": "", 2524 | "description_tooltip": null, 2525 | "layout": "IPY_MODEL_cf21efca556642b494b815577a314b5a", 2526 | "max": 3500316627, 2527 | "min": 0, 2528 | "orientation": "horizontal", 2529 | "style": "IPY_MODEL_3966c4b83dea4e7d92f44985f020c491", 2530 | "value": 3500316627 2531 | } 2532 | }, 2533 | "c1f707cb3960413db86ee33ce346e2b0": { 2534 | "model_module": "@jupyter-widgets/controls", 2535 | "model_module_version": "1.5.0", 2536 | "model_name": "DescriptionStyleModel", 2537 | "state": { 2538 | "_model_module": "@jupyter-widgets/controls", 2539 | "_model_module_version": "1.5.0", 2540 | "_model_name": "DescriptionStyleModel", 2541 | "_view_count": null, 2542 | "_view_module": "@jupyter-widgets/base", 2543 | "_view_module_version": "1.2.0", 2544 | "_view_name": "StyleView", 2545 | "description_width": "" 2546 | } 2547 | }, 2548 | "c2ba7e405d0c41519270e48af899d6b8": { 2549 | "model_module": "@jupyter-widgets/controls", 2550 | "model_module_version": "1.5.0", 2551 | "model_name": "HTMLModel", 2552 | "state": { 2553 | "_dom_classes": [], 2554 | "_model_module": "@jupyter-widgets/controls", 2555 | "_model_module_version": "1.5.0", 2556 | "_model_name": "HTMLModel", 2557 | "_view_count": null, 2558 | "_view_module": "@jupyter-widgets/controls", 2559 | "_view_module_version": "1.5.0", 2560 | "_view_name": "HTMLView", 2561 | "description": "", 2562 | "description_tooltip": null, 2563 | "layout": "IPY_MODEL_39a7407817004510b85e45949bf4532a", 2564 | "placeholder": "​", 2565 | "style": "IPY_MODEL_0f8bfea3563c4cf0b8a0024e347dfc96", 2566 | "value": " 26.8k/26.8k [00:00<00:00, 1.26MB/s]" 2567 | } 2568 | }, 2569 | "ce046e7c5f2741a798666d018a7782db": { 2570 | "model_module": "@jupyter-widgets/controls", 2571 | "model_module_version": "1.5.0", 2572 | "model_name": "DescriptionStyleModel", 2573 | "state": { 2574 | "_model_module": "@jupyter-widgets/controls", 2575 | "_model_module_version": "1.5.0", 2576 | "_model_name": "DescriptionStyleModel", 2577 | "_view_count": null, 2578 | "_view_module": "@jupyter-widgets/base", 2579 | "_view_module_version": "1.2.0", 2580 | "_view_name": "StyleView", 2581 | "description_width": "" 2582 | } 2583 | }, 2584 | "cf21efca556642b494b815577a314b5a": { 2585 | "model_module": "@jupyter-widgets/base", 2586 | "model_module_version": "1.2.0", 2587 | "model_name": "LayoutModel", 2588 | "state": { 2589 | "_model_module": "@jupyter-widgets/base", 2590 | "_model_module_version": "1.2.0", 2591 | "_model_name": "LayoutModel", 2592 | "_view_count": null, 2593 | "_view_module": "@jupyter-widgets/base", 2594 | "_view_module_version": "1.2.0", 2595 | "_view_name": "LayoutView", 2596 | "align_content": null, 2597 | "align_items": null, 2598 | "align_self": null, 2599 | "border": null, 2600 | "bottom": null, 2601 | "display": null, 2602 | "flex": null, 2603 | "flex_flow": null, 2604 | "grid_area": null, 2605 | "grid_auto_columns": null, 2606 | "grid_auto_flow": null, 2607 | "grid_auto_rows": null, 2608 | "grid_column": null, 2609 | "grid_gap": null, 2610 | "grid_row": null, 2611 | "grid_template_areas": null, 2612 | "grid_template_columns": null, 2613 | "grid_template_rows": null, 2614 | "height": null, 2615 | "justify_content": null, 2616 | "justify_items": null, 2617 | "left": null, 2618 | "margin": null, 2619 | "max_height": null, 2620 | "max_width": null, 2621 | "min_height": null, 2622 | "min_width": null, 2623 | "object_fit": null, 2624 | "object_position": null, 2625 | "order": null, 2626 | "overflow": null, 2627 | "overflow_x": null, 2628 | "overflow_y": null, 2629 | "padding": null, 2630 | "right": null, 2631 | "top": null, 2632 | "visibility": null, 2633 | "width": null 2634 | } 2635 | }, 2636 | "d8439c2c34b44be5a43055af77ece713": { 2637 | "model_module": "@jupyter-widgets/base", 2638 | "model_module_version": "1.2.0", 2639 | "model_name": "LayoutModel", 2640 | "state": { 2641 | "_model_module": "@jupyter-widgets/base", 2642 | "_model_module_version": "1.2.0", 2643 | "_model_name": "LayoutModel", 2644 | "_view_count": null, 2645 | "_view_module": "@jupyter-widgets/base", 2646 | "_view_module_version": "1.2.0", 2647 | "_view_name": "LayoutView", 2648 | "align_content": null, 2649 | "align_items": null, 2650 | "align_self": null, 2651 | "border": null, 2652 | "bottom": null, 2653 | "display": null, 2654 | "flex": null, 2655 | "flex_flow": null, 2656 | "grid_area": null, 2657 | "grid_auto_columns": null, 2658 | "grid_auto_flow": null, 2659 | "grid_auto_rows": null, 2660 | "grid_column": null, 2661 | "grid_gap": null, 2662 | "grid_row": null, 2663 | "grid_template_areas": null, 2664 | "grid_template_columns": null, 2665 | "grid_template_rows": null, 2666 | "height": null, 2667 | "justify_content": null, 2668 | "justify_items": null, 2669 | "left": null, 2670 | "margin": null, 2671 | "max_height": null, 2672 | "max_width": null, 2673 | "min_height": null, 2674 | "min_width": null, 2675 | "object_fit": null, 2676 | "object_position": null, 2677 | "order": null, 2678 | "overflow": null, 2679 | "overflow_x": null, 2680 | "overflow_y": null, 2681 | "padding": null, 2682 | "right": null, 2683 | "top": null, 2684 | "visibility": null, 2685 | "width": null 2686 | } 2687 | }, 2688 | "e96aabf90f7341a5b147ce9553e9c14b": { 2689 | "model_module": "@jupyter-widgets/controls", 2690 | "model_module_version": "1.5.0", 2691 | "model_name": "HTMLModel", 2692 | "state": { 2693 | "_dom_classes": [], 2694 | "_model_module": "@jupyter-widgets/controls", 2695 | "_model_module_version": "1.5.0", 2696 | "_model_name": "HTMLModel", 2697 | "_view_count": null, 2698 | "_view_module": "@jupyter-widgets/controls", 2699 | "_view_module_version": "1.5.0", 2700 | "_view_name": "HTMLView", 2701 | "description": "", 2702 | "description_tooltip": null, 2703 | "layout": "IPY_MODEL_1dae3525d2c94656bcda3c8ea2cdf7d6", 2704 | "placeholder": "​", 2705 | "style": "IPY_MODEL_652d98faf01845b38baadf89af5f7c10", 2706 | "value": " 2/2 [01:42<00:00, 46.68s/it]" 2707 | } 2708 | }, 2709 | "ec7fe87663d144f8a1aeb477c2d022f4": { 2710 | "model_module": "@jupyter-widgets/controls", 2711 | "model_module_version": "1.5.0", 2712 | "model_name": "HBoxModel", 2713 | "state": { 2714 | "_dom_classes": [], 2715 | "_model_module": "@jupyter-widgets/controls", 2716 | "_model_module_version": "1.5.0", 2717 | "_model_name": "HBoxModel", 2718 | "_view_count": null, 2719 | "_view_module": "@jupyter-widgets/controls", 2720 | "_view_module_version": "1.5.0", 2721 | "_view_name": "HBoxView", 2722 | "box_style": "", 2723 | "children": [ 2724 | "IPY_MODEL_5b0edbb973ab4b0aa0ff4e6426465dcf", 2725 | "IPY_MODEL_f8c0ce8212e6458eb7a34f3d3cb14231", 2726 | "IPY_MODEL_e96aabf90f7341a5b147ce9553e9c14b" 2727 | ], 2728 | "layout": "IPY_MODEL_96108b6ca9204839af176eda7afd0049" 2729 | } 2730 | }, 2731 | "f299f204b11f4132bfc771680d9fc563": { 2732 | "model_module": "@jupyter-widgets/base", 2733 | "model_module_version": "1.2.0", 2734 | "model_name": "LayoutModel", 2735 | "state": { 2736 | "_model_module": "@jupyter-widgets/base", 2737 | "_model_module_version": "1.2.0", 2738 | "_model_name": "LayoutModel", 2739 | "_view_count": null, 2740 | "_view_module": "@jupyter-widgets/base", 2741 | "_view_module_version": "1.2.0", 2742 | "_view_name": "LayoutView", 2743 | "align_content": null, 2744 | "align_items": null, 2745 | "align_self": null, 2746 | "border": null, 2747 | "bottom": null, 2748 | "display": null, 2749 | "flex": null, 2750 | "flex_flow": null, 2751 | "grid_area": null, 2752 | "grid_auto_columns": null, 2753 | "grid_auto_flow": null, 2754 | "grid_auto_rows": null, 2755 | "grid_column": null, 2756 | "grid_gap": null, 2757 | "grid_row": null, 2758 | "grid_template_areas": null, 2759 | "grid_template_columns": null, 2760 | "grid_template_rows": null, 2761 | "height": null, 2762 | "justify_content": null, 2763 | "justify_items": null, 2764 | "left": null, 2765 | "margin": null, 2766 | "max_height": null, 2767 | "max_width": null, 2768 | "min_height": null, 2769 | "min_width": null, 2770 | "object_fit": null, 2771 | "object_position": null, 2772 | "order": null, 2773 | "overflow": null, 2774 | "overflow_x": null, 2775 | "overflow_y": null, 2776 | "padding": null, 2777 | "right": null, 2778 | "top": null, 2779 | "visibility": null, 2780 | "width": null 2781 | } 2782 | }, 2783 | "f2d5d5f9c7e2405c8e9defeab42778d3": { 2784 | "model_module": "@jupyter-widgets/base", 2785 | "model_module_version": "1.2.0", 2786 | "model_name": "LayoutModel", 2787 | "state": { 2788 | "_model_module": "@jupyter-widgets/base", 2789 | "_model_module_version": "1.2.0", 2790 | "_model_name": "LayoutModel", 2791 | "_view_count": null, 2792 | "_view_module": "@jupyter-widgets/base", 2793 | "_view_module_version": "1.2.0", 2794 | "_view_name": "LayoutView", 2795 | "align_content": null, 2796 | "align_items": null, 2797 | "align_self": null, 2798 | "border": null, 2799 | "bottom": null, 2800 | "display": null, 2801 | "flex": null, 2802 | "flex_flow": null, 2803 | "grid_area": null, 2804 | "grid_auto_columns": null, 2805 | "grid_auto_flow": null, 2806 | "grid_auto_rows": null, 2807 | "grid_column": null, 2808 | "grid_gap": null, 2809 | "grid_row": null, 2810 | "grid_template_areas": null, 2811 | "grid_template_columns": null, 2812 | "grid_template_rows": null, 2813 | "height": null, 2814 | "justify_content": null, 2815 | "justify_items": null, 2816 | "left": null, 2817 | "margin": null, 2818 | "max_height": null, 2819 | "max_width": null, 2820 | "min_height": null, 2821 | "min_width": null, 2822 | "object_fit": null, 2823 | "object_position": null, 2824 | "order": null, 2825 | "overflow": null, 2826 | "overflow_x": null, 2827 | "overflow_y": null, 2828 | "padding": null, 2829 | "right": null, 2830 | "top": null, 2831 | "visibility": null, 2832 | "width": null 2833 | } 2834 | }, 2835 | "f48c4bd3516d4134b08cf9536d44da37": { 2836 | "model_module": "@jupyter-widgets/controls", 2837 | "model_module_version": "1.5.0", 2838 | "model_name": "HTMLModel", 2839 | "state": { 2840 | "_dom_classes": [], 2841 | "_model_module": "@jupyter-widgets/controls", 2842 | "_model_module_version": "1.5.0", 2843 | "_model_name": "HTMLModel", 2844 | "_view_count": null, 2845 | "_view_module": "@jupyter-widgets/controls", 2846 | "_view_module_version": "1.5.0", 2847 | "_view_name": "HTMLView", 2848 | "description": "", 2849 | "description_tooltip": null, 2850 | "layout": "IPY_MODEL_3c32370319e54395bcc7d129aaab84bd", 2851 | "placeholder": "​", 2852 | "style": "IPY_MODEL_c1f707cb3960413db86ee33ce346e2b0", 2853 | "value": "Downloading (…)l-00001-of-00002.bin: 100%" 2854 | } 2855 | }, 2856 | "f8c0ce8212e6458eb7a34f3d3cb14231": { 2857 | "model_module": "@jupyter-widgets/controls", 2858 | "model_module_version": "1.5.0", 2859 | "model_name": "FloatProgressModel", 2860 | "state": { 2861 | "_dom_classes": [], 2862 | "_model_module": "@jupyter-widgets/controls", 2863 | "_model_module_version": "1.5.0", 2864 | "_model_name": "FloatProgressModel", 2865 | "_view_count": null, 2866 | "_view_module": "@jupyter-widgets/controls", 2867 | "_view_module_version": "1.5.0", 2868 | "_view_name": "ProgressView", 2869 | "bar_style": "success", 2870 | "description": "", 2871 | "description_tooltip": null, 2872 | "layout": "IPY_MODEL_d8439c2c34b44be5a43055af77ece713", 2873 | "max": 2, 2874 | "min": 0, 2875 | "orientation": "horizontal", 2876 | "style": "IPY_MODEL_4adfcca6abeb46bd82ea2f7323c518bb", 2877 | "value": 2 2878 | } 2879 | } 2880 | } 2881 | } 2882 | }, 2883 | "nbformat": 4, 2884 | "nbformat_minor": 4 2885 | } 2886 | --------------------------------------------------------------------------------