pushed
Browse files- .chainlit/config.toml +84 -0
- .env +1 -0
- Python RAQA Example.ipynb +1106 -0
- README.md +50 -11
- __pycache__/app.cpython-310.pyc +0 -0
- aimakerspace/__init__.py +0 -0
- aimakerspace/__pycache__/__init__.cpython-310.pyc +0 -0
- aimakerspace/__pycache__/__init__.cpython-311.pyc +0 -0
- aimakerspace/__pycache__/text_utils.cpython-310.pyc +0 -0
- aimakerspace/__pycache__/text_utils.cpython-311.pyc +0 -0
- aimakerspace/__pycache__/vectordatabase.cpython-310.pyc +0 -0
- aimakerspace/__pycache__/vectordatabase.cpython-311.pyc +0 -0
- aimakerspace/openai_utils/__init__.py +0 -0
- aimakerspace/openai_utils/__pycache__/__init__.cpython-310.pyc +0 -0
- aimakerspace/openai_utils/__pycache__/__init__.cpython-311.pyc +0 -0
- aimakerspace/openai_utils/__pycache__/chatmodel.cpython-310.pyc +0 -0
- aimakerspace/openai_utils/__pycache__/chatmodel.cpython-311.pyc +0 -0
- aimakerspace/openai_utils/__pycache__/embedding.cpython-310.pyc +0 -0
- aimakerspace/openai_utils/__pycache__/embedding.cpython-311.pyc +0 -0
- aimakerspace/openai_utils/__pycache__/prompts.cpython-310.pyc +0 -0
- aimakerspace/openai_utils/__pycache__/prompts.cpython-311.pyc +0 -0
- aimakerspace/openai_utils/chatmodel.py +27 -0
- aimakerspace/openai_utils/embedding.py +59 -0
- aimakerspace/openai_utils/prompts.py +75 -0
- aimakerspace/text_utils.py +77 -0
- aimakerspace/vectordatabase.py +81 -0
- app.py +137 -0
- chainlit.md +14 -0
- data/KingLear.txt +0 -0
- images/docchain_img.png +0 -0
- images/raqaapp_img.png +0 -0
- images/texsplitter_img.png +0 -0
- requirements.txt +12 -0
- wandb/run-20231205_135828-pd04j1u0/files/conda-environment.yaml +103 -0
- wandb/run-20231205_135828-pd04j1u0/files/config.yaml +26 -0
- wandb/run-20231205_135828-pd04j1u0/files/requirements.txt +81 -0
- wandb/run-20231205_135828-pd04j1u0/files/wandb-metadata.json +52 -0
- wandb/run-20231205_135828-pd04j1u0/files/wandb-summary.json +1 -0
- wandb/run-20231205_135828-pd04j1u0/logs/debug-internal.log +247 -0
- wandb/run-20231205_135828-pd04j1u0/logs/debug.log +43 -0
- wandb/run-20231205_135828-pd04j1u0/run-pd04j1u0.wandb +0 -0
.chainlit/config.toml
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[project]
|
2 |
+
# Whether to enable telemetry (default: true). No personal data is collected.
|
3 |
+
enable_telemetry = true
|
4 |
+
|
5 |
+
# List of environment variables to be provided by each user to use the app.
|
6 |
+
user_env = []
|
7 |
+
|
8 |
+
# Duration (in seconds) during which the session is saved when the connection is lost
|
9 |
+
session_timeout = 3600
|
10 |
+
|
11 |
+
# Enable third parties caching (e.g LangChain cache)
|
12 |
+
cache = false
|
13 |
+
|
14 |
+
# Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
|
15 |
+
# follow_symlink = false
|
16 |
+
|
17 |
+
[features]
|
18 |
+
# Show the prompt playground
|
19 |
+
prompt_playground = true
|
20 |
+
|
21 |
+
# Process and display HTML in messages. This can be a security risk (see https://stackoverflow.com/questions/19603097/why-is-it-dangerous-to-render-user-generated-html-or-javascript)
|
22 |
+
unsafe_allow_html = false
|
23 |
+
|
24 |
+
# Process and display mathematical expressions. This can clash with "$" characters in messages.
|
25 |
+
latex = false
|
26 |
+
|
27 |
+
# Authorize users to upload files with messages
|
28 |
+
multi_modal = true
|
29 |
+
|
30 |
+
# Allows user to use speech to text
|
31 |
+
[features.speech_to_text]
|
32 |
+
enabled = false
|
33 |
+
# See all languages here https://github.com/JamesBrill/react-speech-recognition/blob/HEAD/docs/API.md#language-string
|
34 |
+
# language = "en-US"
|
35 |
+
|
36 |
+
[UI]
|
37 |
+
# Name of the app and chatbot.
|
38 |
+
name = "Chatbot"
|
39 |
+
|
40 |
+
# Show the readme while the conversation is empty.
|
41 |
+
show_readme_as_default = true
|
42 |
+
|
43 |
+
# Description of the app and chatbot. This is used for HTML tags.
|
44 |
+
# description = ""
|
45 |
+
|
46 |
+
# Large size content are by default collapsed for a cleaner ui
|
47 |
+
default_collapse_content = true
|
48 |
+
|
49 |
+
# The default value for the expand messages settings.
|
50 |
+
default_expand_messages = false
|
51 |
+
|
52 |
+
# Hide the chain of thought details from the user in the UI.
|
53 |
+
hide_cot = false
|
54 |
+
|
55 |
+
# Link to your github repo. This will add a github button in the UI's header.
|
56 |
+
# github = ""
|
57 |
+
|
58 |
+
# Specify a CSS file that can be used to customize the user interface.
|
59 |
+
# The CSS file can be served from the public directory or via an external link.
|
60 |
+
# custom_css = "/public/test.css"
|
61 |
+
|
62 |
+
# Override default MUI light theme. (Check theme.ts)
|
63 |
+
[UI.theme.light]
|
64 |
+
#background = "#FAFAFA"
|
65 |
+
#paper = "#FFFFFF"
|
66 |
+
|
67 |
+
[UI.theme.light.primary]
|
68 |
+
#main = "#F80061"
|
69 |
+
#dark = "#980039"
|
70 |
+
#light = "#FFE7EB"
|
71 |
+
|
72 |
+
# Override default MUI dark theme. (Check theme.ts)
|
73 |
+
[UI.theme.dark]
|
74 |
+
#background = "#FAFAFA"
|
75 |
+
#paper = "#FFFFFF"
|
76 |
+
|
77 |
+
[UI.theme.dark.primary]
|
78 |
+
#main = "#F80061"
|
79 |
+
#dark = "#980039"
|
80 |
+
#light = "#FFE7EB"
|
81 |
+
|
82 |
+
|
83 |
+
[meta]
|
84 |
+
generated_by = "0.7.700"
|
.env
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
OPENAI_API_KEY=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
|
Python RAQA Example.ipynb
ADDED
@@ -0,0 +1,1106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {},
|
6 |
+
"source": [
|
7 |
+
"# Your First RAQA Application\n",
|
8 |
+
"\n",
|
9 |
+
"In this notebook, we'll walk you through each of the components that are involved in a simple RAQA application. \n",
|
10 |
+
"\n",
|
11 |
+
"We won't be leveraging any fancy tools, just the OpenAI Python SDK, Numpy, and some classic Python.\n",
|
12 |
+
"\n",
|
13 |
+
"> NOTE: This was done with Python 3.11.4."
|
14 |
+
]
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"cell_type": "markdown",
|
18 |
+
"metadata": {},
|
19 |
+
"source": [
|
20 |
+
"Let's look at a rather complicated looking visual representation of a basic RAQA application.\n",
|
21 |
+
"\n",
|
22 |
+
"<img src=\"https://i.imgur.com/LCNkd1A.png\" />"
|
23 |
+
]
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"cell_type": "markdown",
|
27 |
+
"metadata": {},
|
28 |
+
"source": [
|
29 |
+
"### Imports and Utility \n",
|
30 |
+
"\n",
|
31 |
+
"We're just doing some imports and enabling `async` to work within the Jupyter environment here, nothing too crazy!"
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"cell_type": "code",
|
36 |
+
"execution_count": 3,
|
37 |
+
"metadata": {},
|
38 |
+
"outputs": [],
|
39 |
+
"source": [
|
40 |
+
"!pip install -q -U numpy matplotlib plotly pandas scipy scikit-learn python-dotenv chainlit==0.7.700 cohere==4.37 openai==1.3.5 tiktoken==0.5.1"
|
41 |
+
]
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"cell_type": "code",
|
45 |
+
"execution_count": 4,
|
46 |
+
"metadata": {},
|
47 |
+
"outputs": [],
|
48 |
+
"source": [
|
49 |
+
"from aimakerspace.text_utils import TextFileLoader, CharacterTextSplitter\n",
|
50 |
+
"from aimakerspace.vectordatabase import VectorDatabase\n",
|
51 |
+
"import asyncio"
|
52 |
+
]
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"cell_type": "code",
|
56 |
+
"execution_count": 5,
|
57 |
+
"metadata": {},
|
58 |
+
"outputs": [],
|
59 |
+
"source": [
|
60 |
+
"import nest_asyncio\n",
|
61 |
+
"nest_asyncio.apply()"
|
62 |
+
]
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"cell_type": "markdown",
|
66 |
+
"metadata": {},
|
67 |
+
"source": [
|
68 |
+
"# Documents\n",
|
69 |
+
"\n",
|
70 |
+
"We'll be concerning ourselves with this part of the flow in the following section:\n",
|
71 |
+
"\n",
|
72 |
+
"<img src=\"https://i.imgur.com/wBYB2x3.png\" />"
|
73 |
+
]
|
74 |
+
},
|
75 |
+
{
|
76 |
+
"cell_type": "markdown",
|
77 |
+
"metadata": {},
|
78 |
+
"source": [
|
79 |
+
"### Loading Source Documents\n",
|
80 |
+
"\n",
|
81 |
+
"So, first things first, we need some documents to work with. \n",
|
82 |
+
"\n",
|
83 |
+
"While we could work directly with the `.txt` files (or whatever file-types you wanted to extend this to) we can instead do some batch processing of those documents at the beginning in order to store them in a more machine compatible format. \n",
|
84 |
+
"\n",
|
85 |
+
"In this case, we're going to parse our text file into a single document in memory.\n",
|
86 |
+
"\n",
|
87 |
+
"Let's look at the relevant bits of the `TextFileLoader` class:\n",
|
88 |
+
"\n",
|
89 |
+
"```python\n",
|
90 |
+
"def load_file(self):\n",
|
91 |
+
" with open(self.path, \"r\", encoding=self.encoding) as f:\n",
|
92 |
+
" self.documents.append(f.read())\n",
|
93 |
+
"```\n",
|
94 |
+
"\n",
|
95 |
+
"We're simply loading the document using the built in `open` method, and storing that output in our `self.documents` list.\n"
|
96 |
+
]
|
97 |
+
},
|
98 |
+
{
|
99 |
+
"cell_type": "code",
|
100 |
+
"execution_count": 5,
|
101 |
+
"metadata": {},
|
102 |
+
"outputs": [
|
103 |
+
{
|
104 |
+
"data": {
|
105 |
+
"text/plain": [
|
106 |
+
"1"
|
107 |
+
]
|
108 |
+
},
|
109 |
+
"execution_count": 5,
|
110 |
+
"metadata": {},
|
111 |
+
"output_type": "execute_result"
|
112 |
+
}
|
113 |
+
],
|
114 |
+
"source": [
|
115 |
+
"text_loader = TextFileLoader(\"data/KingLear.txt\")\n",
|
116 |
+
"documents = text_loader.load_documents()\n",
|
117 |
+
"len(documents)"
|
118 |
+
]
|
119 |
+
},
|
120 |
+
{
|
121 |
+
"cell_type": "code",
|
122 |
+
"execution_count": 7,
|
123 |
+
"metadata": {},
|
124 |
+
"outputs": [
|
125 |
+
{
|
126 |
+
"name": "stdout",
|
127 |
+
"output_type": "stream",
|
128 |
+
"text": [
|
129 |
+
"ACT I\n",
|
130 |
+
"SCENE I. King Lear's palace.\n",
|
131 |
+
"Enter KENT, GLOUCESTER, and EDMUND\n",
|
132 |
+
"KENT\n",
|
133 |
+
"I thought the king had more affected the Duke of\n",
|
134 |
+
"Albany than Cornwall.\n",
|
135 |
+
"GLOUCESTER\n",
|
136 |
+
"It did always seem so to us: but now, in the\n",
|
137 |
+
"division of the kingdom, it appears not which of\n",
|
138 |
+
"the dukes he values most; for equalities are so\n",
|
139 |
+
"weighed, that curiosity in neither can make choice\n",
|
140 |
+
"of either's moiety.\n",
|
141 |
+
"KENT\n",
|
142 |
+
"Is not this your son, my lord?\n",
|
143 |
+
"GLOUCESTER\n",
|
144 |
+
"His breeding, sir, hath been at my charge: I have\n",
|
145 |
+
"so often blushed to acknowledge him, that now I am\n",
|
146 |
+
"brazed to it.\n",
|
147 |
+
"KENT\n",
|
148 |
+
"I cannot conceive you.\n",
|
149 |
+
"GLOUCESTER\n",
|
150 |
+
"Sir, this young fellow's mot\n"
|
151 |
+
]
|
152 |
+
}
|
153 |
+
],
|
154 |
+
"source": [
|
155 |
+
"print(documents[0][:600])"
|
156 |
+
]
|
157 |
+
},
|
158 |
+
{
|
159 |
+
"cell_type": "markdown",
|
160 |
+
"metadata": {},
|
161 |
+
"source": [
|
162 |
+
"### Splitting Text Into Chunks\n",
|
163 |
+
"\n",
|
164 |
+
"As we can see, there is one document - and it's the entire text of King Lear.\n",
|
165 |
+
"\n",
|
166 |
+
"We'll want to chunk the document into smaller parts so it's easier to pass the most relevant snippets to the LLM. \n",
|
167 |
+
"\n",
|
168 |
+
"There is no fixed way to split/chunk documents - and you'll need to rely on some intuition as well as knowing your data *very* well in order to build the most robust system.\n",
|
169 |
+
"\n",
|
170 |
+
"For this toy example, we'll just split blindly on length. \n",
|
171 |
+
"\n",
|
172 |
+
">There's an opportunity to clear up some terminology here, for this course we will be stick to the following: \n",
|
173 |
+
">\n",
|
174 |
+
">- \"source documents\" : The `.txt`, `.pdf`, `.html`, ..., files that make up the files and information we start with in its raw format\n",
|
175 |
+
">- \"document(s)\" : single (or more) text object(s)\n",
|
176 |
+
">- \"corpus\" : the combination of all of our documents"
|
177 |
+
]
|
178 |
+
},
|
179 |
+
{
|
180 |
+
"cell_type": "markdown",
|
181 |
+
"metadata": {},
|
182 |
+
"source": [
|
183 |
+
"Let's take a peek visually at what we're doing here - and why it might be useful:\n",
|
184 |
+
"\n",
|
185 |
+
"<img src=\"https://i.imgur.com/rtM6Ci6.png\" />"
|
186 |
+
]
|
187 |
+
},
|
188 |
+
{
|
189 |
+
"cell_type": "markdown",
|
190 |
+
"metadata": {},
|
191 |
+
"source": [
|
192 |
+
"As you can see (though it's not specifically true in this toy example) the idea of splitting documents is to break them into managable sized chunks that retain the most relevant local context."
|
193 |
+
]
|
194 |
+
},
|
195 |
+
{
|
196 |
+
"cell_type": "code",
|
197 |
+
"execution_count": 6,
|
198 |
+
"metadata": {},
|
199 |
+
"outputs": [
|
200 |
+
{
|
201 |
+
"ename": "NameError",
|
202 |
+
"evalue": "name 'documents' is not defined",
|
203 |
+
"output_type": "error",
|
204 |
+
"traceback": [
|
205 |
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
206 |
+
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
|
207 |
+
"\u001b[1;32mc:\\ai\\llmops3\\repos\\vsrepo\\my-first-raqa\\Python RAQA Example.ipynb Cell 14\u001b[0m line \u001b[0;36m2\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/ai/llmops3/repos/vsrepo/my-first-raqa/Python%20RAQA%20Example.ipynb#X16sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m text_splitter \u001b[39m=\u001b[39m CharacterTextSplitter()\n\u001b[1;32m----> <a href='vscode-notebook-cell:/c%3A/ai/llmops3/repos/vsrepo/my-first-raqa/Python%20RAQA%20Example.ipynb#X16sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m split_documents \u001b[39m=\u001b[39m text_splitter\u001b[39m.\u001b[39msplit_texts(documents)\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/ai/llmops3/repos/vsrepo/my-first-raqa/Python%20RAQA%20Example.ipynb#X16sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39mlen\u001b[39m(split_documents)\n",
|
208 |
+
"\u001b[1;31mNameError\u001b[0m: name 'documents' is not defined"
|
209 |
+
]
|
210 |
+
}
|
211 |
+
],
|
212 |
+
"source": [
|
213 |
+
"text_splitter = CharacterTextSplitter()\n",
|
214 |
+
"split_documents = text_splitter.split_texts(documents)\n",
|
215 |
+
"len(split_documents)"
|
216 |
+
]
|
217 |
+
},
|
218 |
+
{
|
219 |
+
"cell_type": "markdown",
|
220 |
+
"metadata": {},
|
221 |
+
"source": [
|
222 |
+
"Let's take a look at some of the documents we've managed to split."
|
223 |
+
]
|
224 |
+
},
|
225 |
+
{
|
226 |
+
"cell_type": "code",
|
227 |
+
"execution_count": 16,
|
228 |
+
"metadata": {},
|
229 |
+
"outputs": [
|
230 |
+
{
|
231 |
+
"data": {
|
232 |
+
"text/plain": [
|
233 |
+
"[\"\\ufeffACT I\\nSCENE I. King Lear's palace.\\nEnter KENT, GLOUCESTER, and EDMUND\\nKENT\\nI thought the king had more affected the Duke of\\nAlbany than Cornwall.\\nGLOUCESTER\\nIt did always seem so to us: but now, in the\\ndivision of the kingdom, it appears not which of\\nthe dukes he values most; for equalities are so\\nweighed, that curiosity in neither can make choice\\nof either's moiety.\\nKENT\\nIs not this your son, my lord?\\nGLOUCESTER\\nHis breeding, sir, hath been at my charge: I have\\nso often blushed to acknowledge him, that now I am\\nbrazed to it.\\nKENT\\nI cannot conceive you.\\nGLOUCESTER\\nSir, this young fellow's mother could: whereupon\\nshe grew round-wombed, and had, indeed, sir, a son\\nfor her cradle ere she had a husband for her bed.\\nDo you smell a fault?\\nKENT\\nI cannot wish the fault undone, the issue of it\\nbeing so proper.\\nGLOUCESTER\\nBut I have, sir, a son by order of law, some year\\nelder than this, who yet is no dearer in my account:\\nthough this knave came something saucily into the\\nworld before he was se\"]"
|
234 |
+
]
|
235 |
+
},
|
236 |
+
"execution_count": 16,
|
237 |
+
"metadata": {},
|
238 |
+
"output_type": "execute_result"
|
239 |
+
}
|
240 |
+
],
|
241 |
+
"source": [
|
242 |
+
"split_documents[0:1]"
|
243 |
+
]
|
244 |
+
},
|
245 |
+
{
|
246 |
+
"cell_type": "markdown",
|
247 |
+
"metadata": {},
|
248 |
+
"source": [
|
249 |
+
"### Embeddings and Vectors\n",
|
250 |
+
"\n",
|
251 |
+
"Next, we have to convert our corpus into a \"machine readable\" format. \n",
|
252 |
+
"\n",
|
253 |
+
"Loosely, this means turning the text into numbers. \n",
|
254 |
+
"\n",
|
255 |
+
"There are plenty of resources that talk about this process in great detail - I'll leave this [blog](https://txt.cohere.com/sentence-word-embeddings/) from Cohere:AI as a resource if you want to deep dive a bit. \n",
|
256 |
+
"\n",
|
257 |
+
"Today, we're going to talk about the actual process of creating, and then storing, these embeddings, and how we can leverage that to intelligently add context to our queries."
|
258 |
+
]
|
259 |
+
},
|
260 |
+
{
|
261 |
+
"cell_type": "markdown",
|
262 |
+
"metadata": {},
|
263 |
+
"source": [
|
264 |
+
"While this is all baked into 1 call - let's look at some of the code that powers this process:\n",
|
265 |
+
"\n",
|
266 |
+
"Let's look at our `VectorDatabase().__init__()`:\n",
|
267 |
+
"\n",
|
268 |
+
"```python\n",
|
269 |
+
"def __init__(self, embedding_model: EmbeddingModel = None):\n",
|
270 |
+
" self.vectors = defaultdict(np.array)\n",
|
271 |
+
" self.embedding_model = embedding_model or EmbeddingModel()\n",
|
272 |
+
"```\n",
|
273 |
+
"\n",
|
274 |
+
"As you can see - our vectors are merely stored as a dictionary of `np.array` objects.\n",
|
275 |
+
"\n",
|
276 |
+
"Secondly, our `VectorDatabase()` has a default `EmbeddingModel()` which is a wrapper for OpenAI's `text-embedding-ada-002` model. \n",
|
277 |
+
"\n",
|
278 |
+
"> **Quick Info About `text-embedding-ada-002`**:\n",
|
279 |
+
"> - It has a context window of **8192** tokens\n",
|
280 |
+
"> - It returns vectors with dimension **1536**"
|
281 |
+
]
|
282 |
+
},
|
283 |
+
{
|
284 |
+
"cell_type": "code",
|
285 |
+
"execution_count": 17,
|
286 |
+
"metadata": {},
|
287 |
+
"outputs": [],
|
288 |
+
"source": [
|
289 |
+
"import os\n",
|
290 |
+
"import openai\n",
|
291 |
+
"from getpass import getpass\n",
|
292 |
+
"\n",
|
293 |
+
"openai.api_key = getpass(\"OpenAI API Key: \")\n",
|
294 |
+
"os.environ[\"OPENAI_API_KEY\"] = openai.api_key"
|
295 |
+
]
|
296 |
+
},
|
297 |
+
{
|
298 |
+
"cell_type": "markdown",
|
299 |
+
"metadata": {},
|
300 |
+
"source": [
|
301 |
+
"We can call the `async_get_embeddings` method of our `EmbeddingModel()` on a list of `str` and receive a list of `float` back!\n",
|
302 |
+
"\n",
|
303 |
+
"```python\n",
|
304 |
+
"async def async_get_embeddings(self, list_of_text: List[str]) -> List[List[float]]:\n",
|
305 |
+
" return await aget_embeddings(\n",
|
306 |
+
" list_of_text=list_of_text, engine=self.embeddings_model_name\n",
|
307 |
+
" )\n",
|
308 |
+
"```"
|
309 |
+
]
|
310 |
+
},
|
311 |
+
{
|
312 |
+
"cell_type": "markdown",
|
313 |
+
"metadata": {},
|
314 |
+
"source": [
|
315 |
+
"We cast those to `np.array` when we build our `VectorDatabase()`:\n",
|
316 |
+
"\n",
|
317 |
+
"```python\n",
|
318 |
+
"async def abuild_from_list(self, list_of_text: List[str]) -> \"VectorDatabase\":\n",
|
319 |
+
" embeddings = await self.embedding_model.async_get_embeddings(list_of_text)\n",
|
320 |
+
" for text, embedding in zip(list_of_text, embeddings):\n",
|
321 |
+
" self.insert(text, np.array(embedding))\n",
|
322 |
+
" return self\n",
|
323 |
+
"```\n",
|
324 |
+
"\n",
|
325 |
+
"And that's all we need to do!"
|
326 |
+
]
|
327 |
+
},
|
328 |
+
{
|
329 |
+
"cell_type": "code",
|
330 |
+
"execution_count": 19,
|
331 |
+
"metadata": {},
|
332 |
+
"outputs": [],
|
333 |
+
"source": [
|
334 |
+
"vector_db = VectorDatabase()\n",
|
335 |
+
"vector_db = asyncio.run(vector_db.abuild_from_list(split_documents))"
|
336 |
+
]
|
337 |
+
},
|
338 |
+
{
|
339 |
+
"cell_type": "markdown",
|
340 |
+
"metadata": {},
|
341 |
+
"source": [
|
342 |
+
"So, to review what we've done so far in natural language:\n",
|
343 |
+
"\n",
|
344 |
+
"1. We load source documents\n",
|
345 |
+
"2. We split those source documents into smaller chunks (documents)\n",
|
346 |
+
"3. We send each of those documents to the `text-embedding-ada-002` OpenAI API endpoint\n",
|
347 |
+
"4. We store each of the text representations with the vector representations as keys/values in a dictionary"
|
348 |
+
]
|
349 |
+
},
|
350 |
+
{
|
351 |
+
"cell_type": "markdown",
|
352 |
+
"metadata": {},
|
353 |
+
"source": [
|
354 |
+
"### Semantic Similarity\n",
|
355 |
+
"\n",
|
356 |
+
"The next step is to be able to query our `VectorDatabase()` with a `str` and have it return to us vectors and text that is most relevant from our corpus. \n",
|
357 |
+
"\n",
|
358 |
+
"We're going to use the following process to achieve this in our toy example:\n",
|
359 |
+
"\n",
|
360 |
+
"1. We need to embed our query with the same `EmbeddingModel()` as we used to construct our `VectorDatabase()`\n",
|
361 |
+
"2. We loop through every vector in our `VectorDatabase()` and use a distance measure to compare how related they are\n",
|
362 |
+
"3. We return a list of the top `k` closest vectors, with their text representations\n",
|
363 |
+
"\n",
|
364 |
+
"There's some very heavy optimization that can be done at each of these steps - but let's just focus on the basic pattern in this notebook.\n",
|
365 |
+
"\n",
|
366 |
+
"> We are using [cosine similarity](https://www.engati.com/glossary/cosine-similarity) as a distance measure in this example - but there are many many distance measures you could use - like [these](https://flavien-vidal.medium.com/similarity-distances-for-natural-language-processing-16f63cd5ba55)\n",
|
367 |
+
"\n",
|
368 |
+
"> We are using a rather inefficient way of calculating relative distance between the query vector and all other vectors - there are more advanced approaches that are much more efficient, like [ANN](https://towardsdatascience.com/comprehensive-guide-to-approximate-nearest-neighbors-algorithms-8b94f057d6b6)"
|
369 |
+
]
|
370 |
+
},
|
371 |
+
{
|
372 |
+
"cell_type": "code",
|
373 |
+
"execution_count": 20,
|
374 |
+
"metadata": {},
|
375 |
+
"outputs": [
|
376 |
+
{
|
377 |
+
"data": {
|
378 |
+
"text/plain": [
|
379 |
+
"[(\"ng] O my good master!\\nKING LEAR\\nPrithee, away.\\nEDGAR\\n'Tis noble Kent, your friend.\\nKING LEAR\\nA plague upon you, murderers, traitors all!\\nI might have saved her; now she's gone for ever!\\nCordelia, Cordelia! stay a little. Ha!\\nWhat is't thou say'st? Her voice was ever soft,\\nGentle, and low, an excellent thing in woman.\\nI kill'd the slave that was a-hanging thee.\\nCaptain\\n'Tis true, my lords, he did.\\nKING LEAR\\nDid I not, fellow?\\nI have seen the day, with my good biting falchion\\nI would have made them skip: I am old now,\\nAnd these same crosses spoil me. Who are you?\\nMine eyes are not o' the best: I'll tell you straight.\\nKENT\\nIf fortune brag of two she loved and hated,\\nOne of them we behold.\\nKING LEAR\\nThis is a dull sight. Are you not Kent?\\nKENT\\nThe same,\\nYour servant Kent: Where is your servant Caius?\\nKING LEAR\\nHe's a good fellow, I can tell you that;\\nHe'll strike, and quickly too: he's dead and rotten.\\nKENT\\nNo, my good lord; I am the very man,--\\nKING LEAR\\nI'll see that straight.\\nKENT\\nThat,\",\n",
|
380 |
+
" 0.8344666931475856),\n",
|
381 |
+
" (\",\\nLay comforts to your bosom; and bestow\\nYour needful counsel to our business,\\nWhich craves the instant use.\\nGLOUCESTER\\nI serve you, madam:\\nYour graces are right welcome.\\nExeunt\\n\\nSCENE II. Before Gloucester's castle.\\nEnter KENT and OSWALD, severally\\nOSWALD\\nGood dawning to thee, friend: art of this house?\\nKENT\\nAy.\\nOSWALD\\nWhere may we set our horses?\\nKENT\\nI' the mire.\\nOSWALD\\nPrithee, if thou lovest me, tell me.\\nKENT\\nI love thee not.\\nOSWALD\\nWhy, then, I care not for thee.\\nKENT\\nIf I had thee in Lipsbury pinfold, I would make thee\\ncare for me.\\nOSWALD\\nWhy dost thou use me thus? I know thee not.\\nKENT\\nFellow, I know thee.\\nOSWALD\\nWhat dost thou know me for?\\nKENT\\nA knave; a rascal; an eater of broken meats; a\\nbase, proud, shallow, beggarly, three-suited,\\nhundred-pound, filthy, worsted-stocking knave; a\\nlily-livered, action-taking knave, a whoreson,\\nglass-gazing, super-serviceable finical rogue;\\none-trunk-inheriting slave; one that wouldst be a\\nbawd, in way of good service, and art nothing but\\nth\",\n",
|
382 |
+
" 0.8218615790372598),\n",
|
383 |
+
" (\" Caius?\\nKING LEAR\\nHe's a good fellow, I can tell you that;\\nHe'll strike, and quickly too: he's dead and rotten.\\nKENT\\nNo, my good lord; I am the very man,--\\nKING LEAR\\nI'll see that straight.\\nKENT\\nThat, from your first of difference and decay,\\nHave follow'd your sad steps.\\nKING LEAR\\nYou are welcome hither.\\nKENT\\nNor no man else: all's cheerless, dark, and deadly.\\nYour eldest daughters have fordone them selves,\\nAnd desperately are dead.\\nKING LEAR\\nAy, so I think.\\nALBANY\\nHe knows not what he says: and vain it is\\nThat we present us to him.\\nEDGAR\\nVery bootless.\\nEnter a Captain\\n\\nCaptain\\nEdmund is dead, my lord.\\nALBANY\\nThat's but a trifle here.\\nYou lords and noble friends, know our intent.\\nWhat comfort to this great decay may come\\nShall be applied: for us we will resign,\\nDuring the life of this old majesty,\\nTo him our absolute power:\\nTo EDGAR and KENT\\n\\nyou, to your rights:\\nWith boot, and such addition as your honours\\nHave more than merited. All friends shall taste\\nThe wages of their virtue, and \",\n",
|
384 |
+
" 0.8212563905734079)]"
|
385 |
+
]
|
386 |
+
},
|
387 |
+
"execution_count": 20,
|
388 |
+
"metadata": {},
|
389 |
+
"output_type": "execute_result"
|
390 |
+
}
|
391 |
+
],
|
392 |
+
"source": [
|
393 |
+
"vector_db.search_by_text(\"Your servant Kent. Where is your servant Caius?\", k=3)"
|
394 |
+
]
|
395 |
+
},
|
396 |
+
{
|
397 |
+
"cell_type": "markdown",
|
398 |
+
"metadata": {},
|
399 |
+
"source": [
|
400 |
+
"# Prompts\n",
|
401 |
+
"\n",
|
402 |
+
"In the following section, we'll be looking at the role of prompts - and how they help us to guide our application in the right direction.\n",
|
403 |
+
"\n",
|
404 |
+
"In this notebook, we're going to rely on the idea of \"zero-shot in-context learning\".\n",
|
405 |
+
"\n",
|
406 |
+
"This is a lot of words to say: \"We will ask it to perform our desired task in the prompt, and provide no examples.\""
|
407 |
+
]
|
408 |
+
},
|
409 |
+
{
|
410 |
+
"cell_type": "markdown",
|
411 |
+
"metadata": {},
|
412 |
+
"source": [
|
413 |
+
"### XYZRolePrompt\n",
|
414 |
+
"\n",
|
415 |
+
"Before we do that, let's stop and think a bit about how OpenAI's chat models work. \n",
|
416 |
+
"\n",
|
417 |
+
"We know they have roles - as is indicated in the following API [documentation](https://platform.openai.com/docs/api-reference/chat/create#chat/create-messages)\n",
|
418 |
+
"\n",
|
419 |
+
"There are three roles, and they function as follows (taken directly from [OpenAI](https://platform.openai.com/docs/guides/gpt/chat-completions-api)): \n",
|
420 |
+
"\n",
|
421 |
+
"- `{\"role\" : \"system\"}` : The system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. However note that the system message is optional and the model’s behavior without a system message is likely to be similar to using a generic message such as \"You are a helpful assistant.\"\n",
|
422 |
+
"- `{\"role\" : \"user\"}` : The user messages provide requests or comments for the assistant to respond to.\n",
|
423 |
+
"- `{\"role\" : \"assistant\"}` : Assistant messages store previous assistant responses, but can also be written by you to give examples of desired behavior.\n",
|
424 |
+
"\n",
|
425 |
+
"The main idea is this: \n",
|
426 |
+
"\n",
|
427 |
+
"1. You start with a system message that outlines how the LLM should respond, what kind of behaviours you can expect from it, and more\n",
|
428 |
+
"2. Then, you can provide a few examples in the form of \"assistant\"/\"user\" pairs\n",
|
429 |
+
"3. Then, you prompt the model with the true \"user\" message.\n",
|
430 |
+
"\n",
|
431 |
+
"In this example, we'll be forgoing the 2nd step for simplicities sake."
|
432 |
+
]
|
433 |
+
},
|
434 |
+
{
|
435 |
+
"cell_type": "markdown",
|
436 |
+
"metadata": {},
|
437 |
+
"source": [
|
438 |
+
"#### Utility Functions\n",
|
439 |
+
"\n",
|
440 |
+
"You'll notice that we're using some utility functions from the `aimakerspace` module - let's take a peek at these and see what they're doing!"
|
441 |
+
]
|
442 |
+
},
|
443 |
+
{
|
444 |
+
"cell_type": "markdown",
|
445 |
+
"metadata": {},
|
446 |
+
"source": [
|
447 |
+
"##### XYZRolePrompt"
|
448 |
+
]
|
449 |
+
},
|
450 |
+
{
|
451 |
+
"cell_type": "markdown",
|
452 |
+
"metadata": {},
|
453 |
+
"source": [
|
454 |
+
"Here we have our `system`, `user`, and `assistant` role prompts. \n",
|
455 |
+
"\n",
|
456 |
+
"Let's take a peek at what they look like:\n",
|
457 |
+
"\n",
|
458 |
+
"```python\n",
|
459 |
+
"class BasePrompt:\n",
|
460 |
+
" def __init__(self, prompt):\n",
|
461 |
+
" \"\"\"\n",
|
462 |
+
" Initializes the BasePrompt object with a prompt template.\n",
|
463 |
+
"\n",
|
464 |
+
" :param prompt: A string that can contain placeholders within curly braces\n",
|
465 |
+
" \"\"\"\n",
|
466 |
+
" self.prompt = prompt\n",
|
467 |
+
" self._pattern = re.compile(r\"\\{([^}]+)\\}\")\n",
|
468 |
+
"\n",
|
469 |
+
" def format_prompt(self, **kwargs):\n",
|
470 |
+
" \"\"\"\n",
|
471 |
+
" Formats the prompt string using the keyword arguments provided.\n",
|
472 |
+
"\n",
|
473 |
+
" :param kwargs: The values to substitute into the prompt string\n",
|
474 |
+
" :return: The formatted prompt string\n",
|
475 |
+
" \"\"\"\n",
|
476 |
+
" matches = self._pattern.findall(self.prompt)\n",
|
477 |
+
" return self.prompt.format(**{match: kwargs.get(match, \"\") for match in matches})\n",
|
478 |
+
"\n",
|
479 |
+
" def get_input_variables(self):\n",
|
480 |
+
" \"\"\"\n",
|
481 |
+
" Gets the list of input variable names from the prompt string.\n",
|
482 |
+
"\n",
|
483 |
+
" :return: List of input variable names\n",
|
484 |
+
" \"\"\"\n",
|
485 |
+
" return self._pattern.findall(self.prompt)\n",
|
486 |
+
"```\n",
|
487 |
+
"\n",
|
488 |
+
"Then we have our `RolePrompt` which laser focuses us on the role pattern found in most API endpoints for LLMs.\n",
|
489 |
+
"\n",
|
490 |
+
"```python\n",
|
491 |
+
"class RolePrompt(BasePrompt):\n",
|
492 |
+
" def __init__(self, prompt, role: str):\n",
|
493 |
+
" \"\"\"\n",
|
494 |
+
" Initializes the RolePrompt object with a prompt template and a role.\n",
|
495 |
+
"\n",
|
496 |
+
" :param prompt: A string that can contain placeholders within curly braces\n",
|
497 |
+
" :param role: The role for the message ('system', 'user', or 'assistant')\n",
|
498 |
+
" \"\"\"\n",
|
499 |
+
" super().__init__(prompt)\n",
|
500 |
+
" self.role = role\n",
|
501 |
+
"\n",
|
502 |
+
" def create_message(self, **kwargs):\n",
|
503 |
+
" \"\"\"\n",
|
504 |
+
" Creates a message dictionary with a role and a formatted message.\n",
|
505 |
+
"\n",
|
506 |
+
" :param kwargs: The values to substitute into the prompt string\n",
|
507 |
+
" :return: Dictionary containing the role and the formatted message\n",
|
508 |
+
" \"\"\"\n",
|
509 |
+
" return {\"role\": self.role, \"content\": self.format_prompt(**kwargs)}\n",
|
510 |
+
"```\n",
|
511 |
+
"\n",
|
512 |
+
"We'll look at how the `SystemRolePrompt` is constructed to get a better idea of how that extension works:\n",
|
513 |
+
"\n",
|
514 |
+
"```python\n",
|
515 |
+
"class SystemRolePrompt(RolePrompt):\n",
|
516 |
+
" def __init__(self, prompt: str):\n",
|
517 |
+
" super().__init__(prompt, \"system\")\n",
|
518 |
+
"```\n",
|
519 |
+
"\n",
|
520 |
+
"That pattern is repeated for our `UserRolePrompt` and our `AssistantRolePrompt` as well."
|
521 |
+
]
|
522 |
+
},
|
523 |
+
{
|
524 |
+
"cell_type": "markdown",
|
525 |
+
"metadata": {},
|
526 |
+
"source": [
|
527 |
+
"##### ChatOpenAI"
|
528 |
+
]
|
529 |
+
},
|
530 |
+
{
|
531 |
+
"cell_type": "markdown",
|
532 |
+
"metadata": {},
|
533 |
+
"source": [
|
534 |
+
"Next we have our model, which is converted to a format analagous to libraries like LangChain and LlamaIndex.\n",
|
535 |
+
"\n",
|
536 |
+
"Let's take a peek at how that is constructed:\n",
|
537 |
+
"\n",
|
538 |
+
"```python\n",
|
539 |
+
"class ChatOpenAI:\n",
|
540 |
+
" def __init__(self, model_name: str = \"gpt-3.5-turbo\"):\n",
|
541 |
+
" self.model_name = model_name\n",
|
542 |
+
" self.openai_api_key = os.getenv(\"OPENAI_API_KEY\")\n",
|
543 |
+
" if self.openai_api_key is None:\n",
|
544 |
+
" raise ValueError(\"OPENAI_API_KEY is not set\")\n",
|
545 |
+
"\n",
|
546 |
+
" def run(self, messages, text_only: bool = True):\n",
|
547 |
+
" if not isinstance(messages, list):\n",
|
548 |
+
" raise ValueError(\"messages must be a list\")\n",
|
549 |
+
"\n",
|
550 |
+
" openai.api_key = self.openai_api_key\n",
|
551 |
+
" response = openai.ChatCompletion.create(\n",
|
552 |
+
" model=self.model_name, messages=messages\n",
|
553 |
+
" )\n",
|
554 |
+
"\n",
|
555 |
+
" if text_only:\n",
|
556 |
+
" return response.choices[0].message.content\n",
|
557 |
+
"\n",
|
558 |
+
" return response\n",
|
559 |
+
"```"
|
560 |
+
]
|
561 |
+
},
|
562 |
+
{
|
563 |
+
"cell_type": "markdown",
|
564 |
+
"metadata": {},
|
565 |
+
"source": [
|
566 |
+
"### Creating and Prompting OpenAI's `gpt-3.5-turbo`!\n",
|
567 |
+
"\n",
|
568 |
+
"Let's tie all these together and use it to prompt `gpt-3.5-turbo`!"
|
569 |
+
]
|
570 |
+
},
|
571 |
+
{
|
572 |
+
"cell_type": "code",
|
573 |
+
"execution_count": 21,
|
574 |
+
"metadata": {},
|
575 |
+
"outputs": [],
|
576 |
+
"source": [
|
577 |
+
"from aimakerspace.openai_utils.prompts import (\n",
|
578 |
+
" UserRolePrompt,\n",
|
579 |
+
" SystemRolePrompt,\n",
|
580 |
+
" AssistantRolePrompt,\n",
|
581 |
+
")\n",
|
582 |
+
"\n",
|
583 |
+
"from aimakerspace.openai_utils.chatmodel import ChatOpenAI\n",
|
584 |
+
"\n",
|
585 |
+
"chat_openai = ChatOpenAI()\n",
|
586 |
+
"user_prompt_template = \"{content}\"\n",
|
587 |
+
"user_role_prompt = UserRolePrompt(user_prompt_template)\n",
|
588 |
+
"system_prompt_template = (\n",
|
589 |
+
" \"You are an expert in {expertise}, you always answer in a kind way.\"\n",
|
590 |
+
")\n",
|
591 |
+
"system_role_prompt = SystemRolePrompt(system_prompt_template)\n",
|
592 |
+
"\n",
|
593 |
+
"messages = [\n",
|
594 |
+
" user_role_prompt.create_message(\n",
|
595 |
+
" content=\"What is the best way to write a loop?\"\n",
|
596 |
+
" ),\n",
|
597 |
+
" system_role_prompt.create_message(expertise=\"Python\"),\n",
|
598 |
+
"]\n",
|
599 |
+
"\n",
|
600 |
+
"response = chat_openai.run(messages)"
|
601 |
+
]
|
602 |
+
},
|
603 |
+
{
|
604 |
+
"cell_type": "code",
|
605 |
+
"execution_count": 22,
|
606 |
+
"metadata": {},
|
607 |
+
"outputs": [
|
608 |
+
{
|
609 |
+
"name": "stdout",
|
610 |
+
"output_type": "stream",
|
611 |
+
"text": [
|
612 |
+
"The best way to write a loop depends on the specific programming language you are using. However, I can provide some general tips for writing loops that can apply to many languages, including Python:\n",
|
613 |
+
"\n",
|
614 |
+
"1. Determine the type of loop you need: There are generally two types of loops: \"for\" loops and \"while\" loops. Use a \"for\" loop when you know the number of iterations in advance, and a \"while\" loop when the number of iterations is uncertain.\n",
|
615 |
+
"\n",
|
616 |
+
"2. Define the loop condition: In most cases, a loop should have a defined condition that determines whether the loop should continue or exit. This condition is typically checked before each iteration. Make sure the condition is appropriate for your specific scenario.\n",
|
617 |
+
"\n",
|
618 |
+
"3. Initialize loop control variables: If your loop requires variables to control its flow, make sure to initialize them before the loop starts. This ensures the loop starts with the expected initial values.\n",
|
619 |
+
"\n",
|
620 |
+
"4. Update loop control variables: When using a loop that relies on control variables, ensure that you update these variables within the loop body. Otherwise, the loop might become infinite or not produce the desired results.\n",
|
621 |
+
"\n",
|
622 |
+
"5. Include necessary code in the loop body: Within the loop body, place the code you want to execute during each iteration. This could include calculations, condition checks, or any other desired operations.\n",
|
623 |
+
"\n",
|
624 |
+
"6. Ensure proper indentation: Many programming languages, including Python, use indentation to define the scope of the loop body. Make sure to indent the code inside the loop correctly, so it is executed as part of the loop.\n",
|
625 |
+
"\n",
|
626 |
+
"7. Exit the loop when appropriate: If there is a condition based on which the loop should terminate, ensure it is properly implemented. Otherwise, an infinite loop may occur, which could lead to unexpected results or even crash your program.\n",
|
627 |
+
"\n",
|
628 |
+
"Remember, coding practices and guidelines may vary based on the programming language you are using, so it's always a good idea to consult the documentation or specific best practices for that language.\n"
|
629 |
+
]
|
630 |
+
}
|
631 |
+
],
|
632 |
+
"source": [
|
633 |
+
"print(response)"
|
634 |
+
]
|
635 |
+
},
|
636 |
+
{
|
637 |
+
"cell_type": "markdown",
|
638 |
+
"metadata": {},
|
639 |
+
"source": [
|
640 |
+
"### Retrieval Augmented Question Answering Prompt\n",
|
641 |
+
"\n",
|
642 |
+
"Now we can create a RAQA prompt - which will help our system behave in a way that makes sense!\n",
|
643 |
+
"\n",
|
644 |
+
"There is much you could do here, many tweaks and improvements to be made!"
|
645 |
+
]
|
646 |
+
},
|
647 |
+
{
|
648 |
+
"cell_type": "code",
|
649 |
+
"execution_count": 23,
|
650 |
+
"metadata": {},
|
651 |
+
"outputs": [],
|
652 |
+
"source": [
|
653 |
+
"RAQA_PROMPT_TEMPLATE = \"\"\"\n",
|
654 |
+
"Use the provided context to answer the user's query. \n",
|
655 |
+
"\n",
|
656 |
+
"You may not answer the user's query unless there is specific context in the following text.\n",
|
657 |
+
"\n",
|
658 |
+
"If you do not know the answer, or cannot answer, please respond with \"I don't know\".\n",
|
659 |
+
"\n",
|
660 |
+
"Context:\n",
|
661 |
+
"{context}\n",
|
662 |
+
"\"\"\"\n",
|
663 |
+
"\n",
|
664 |
+
"raqa_prompt = SystemRolePrompt(RAQA_PROMPT_TEMPLATE)\n",
|
665 |
+
"\n",
|
666 |
+
"USER_PROMPT_TEMPLATE = \"\"\"\n",
|
667 |
+
"User Query:\n",
|
668 |
+
"{user_query}\n",
|
669 |
+
"\"\"\"\n",
|
670 |
+
"\n",
|
671 |
+
"user_prompt = UserRolePrompt(USER_PROMPT_TEMPLATE)\n",
|
672 |
+
"\n",
|
673 |
+
"class RetrievalAugmentedQAPipeline:\n",
|
674 |
+
" def __init__(self, llm: ChatOpenAI(), vector_db_retriever: VectorDatabase) -> None:\n",
|
675 |
+
" self.llm = llm\n",
|
676 |
+
" self.vector_db_retriever = vector_db_retriever\n",
|
677 |
+
"\n",
|
678 |
+
" def run_pipeline(self, user_query: str) -> str:\n",
|
679 |
+
" context_list = self.vector_db_retriever.search_by_text(user_query, k=4)\n",
|
680 |
+
" \n",
|
681 |
+
" context_prompt = \"\"\n",
|
682 |
+
" for context in context_list:\n",
|
683 |
+
" context_prompt += context[0] + \"\\n\"\n",
|
684 |
+
"\n",
|
685 |
+
" formatted_system_prompt = raqa_prompt.create_message(context=context_prompt)\n",
|
686 |
+
"\n",
|
687 |
+
" formatted_user_prompt = user_prompt.create_message(user_query=user_query)\n",
|
688 |
+
" \n",
|
689 |
+
" return self.llm.run([formatted_system_prompt, formatted_user_prompt])"
|
690 |
+
]
|
691 |
+
},
|
692 |
+
{
|
693 |
+
"cell_type": "code",
|
694 |
+
"execution_count": 24,
|
695 |
+
"metadata": {},
|
696 |
+
"outputs": [],
|
697 |
+
"source": [
|
698 |
+
"retrieval_augmented_qa_pipeline = RetrievalAugmentedQAPipeline(\n",
|
699 |
+
" vector_db_retriever=vector_db,\n",
|
700 |
+
" llm=chat_openai\n",
|
701 |
+
")"
|
702 |
+
]
|
703 |
+
},
|
704 |
+
{
|
705 |
+
"cell_type": "code",
|
706 |
+
"execution_count": 25,
|
707 |
+
"metadata": {},
|
708 |
+
"outputs": [
|
709 |
+
{
|
710 |
+
"data": {
|
711 |
+
"text/plain": [
|
712 |
+
"'King Lear is a character in William Shakespeare\\'s play called \"King Lear.\" He is an aging king who decides to divide his kingdom among his three daughters, Goneril, Regan, and Cordelia. However, his decision leads to a series of tragic events and the unraveling of his sanity.'"
|
713 |
+
]
|
714 |
+
},
|
715 |
+
"execution_count": 25,
|
716 |
+
"metadata": {},
|
717 |
+
"output_type": "execute_result"
|
718 |
+
}
|
719 |
+
],
|
720 |
+
"source": [
|
721 |
+
"retrieval_augmented_qa_pipeline.run_pipeline(\"Who is King Lear?\")"
|
722 |
+
]
|
723 |
+
},
|
724 |
+
{
|
725 |
+
"cell_type": "markdown",
|
726 |
+
"metadata": {},
|
727 |
+
"source": [
|
728 |
+
"### Visibility Tooling\n",
|
729 |
+
"\n",
|
730 |
+
"This is great, but what if we wanted to add some visibility to our pipeline?\n",
|
731 |
+
"\n",
|
732 |
+
"Let's use Weights and Biases as a visibility tool!\n",
|
733 |
+
"\n",
|
734 |
+
"The first thing we'll need to do is create a Weights and Biases account and get an API key. \n",
|
735 |
+
"\n",
|
736 |
+
"You can follow the process outlined [here](https://docs.wandb.ai/quickstart) to do exactly that!"
|
737 |
+
]
|
738 |
+
},
|
739 |
+
{
|
740 |
+
"cell_type": "markdown",
|
741 |
+
"metadata": {},
|
742 |
+
"source": [
|
743 |
+
"Now we can get the Weights and Biases dependency and add our key to our env. to begin!"
|
744 |
+
]
|
745 |
+
},
|
746 |
+
{
|
747 |
+
"cell_type": "code",
|
748 |
+
"execution_count": 26,
|
749 |
+
"metadata": {},
|
750 |
+
"outputs": [],
|
751 |
+
"source": [
|
752 |
+
"!pip install -q -U wandb"
|
753 |
+
]
|
754 |
+
},
|
755 |
+
{
|
756 |
+
"cell_type": "code",
|
757 |
+
"execution_count": 27,
|
758 |
+
"metadata": {},
|
759 |
+
"outputs": [],
|
760 |
+
"source": [
|
761 |
+
"wandb_key = getpass(\"Weights and Biases API Key: \")\n",
|
762 |
+
"os.environ[\"WANDB_API_KEY\"] = wandb_key"
|
763 |
+
]
|
764 |
+
},
|
765 |
+
{
|
766 |
+
"cell_type": "code",
|
767 |
+
"execution_count": 28,
|
768 |
+
"metadata": {},
|
769 |
+
"outputs": [
|
770 |
+
{
|
771 |
+
"name": "stderr",
|
772 |
+
"output_type": "stream",
|
773 |
+
"text": [
|
774 |
+
"\u001b[34m\u001b[1mwandb\u001b[0m: Currently logged in as: \u001b[33mgarygec8\u001b[0m (\u001b[33mdeepmediamachine\u001b[0m). Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n"
|
775 |
+
]
|
776 |
+
},
|
777 |
+
{
|
778 |
+
"data": {
|
779 |
+
"text/html": [
|
780 |
+
"wandb version 0.16.1 is available! To upgrade, please run:\n",
|
781 |
+
" $ pip install wandb --upgrade"
|
782 |
+
],
|
783 |
+
"text/plain": [
|
784 |
+
"<IPython.core.display.HTML object>"
|
785 |
+
]
|
786 |
+
},
|
787 |
+
"metadata": {},
|
788 |
+
"output_type": "display_data"
|
789 |
+
},
|
790 |
+
{
|
791 |
+
"data": {
|
792 |
+
"text/html": [
|
793 |
+
"Tracking run with wandb version 0.16.0"
|
794 |
+
],
|
795 |
+
"text/plain": [
|
796 |
+
"<IPython.core.display.HTML object>"
|
797 |
+
]
|
798 |
+
},
|
799 |
+
"metadata": {},
|
800 |
+
"output_type": "display_data"
|
801 |
+
},
|
802 |
+
{
|
803 |
+
"data": {
|
804 |
+
"text/html": [
|
805 |
+
"Run data is saved locally in <code>c:\\ai\\llmops3\\repos\\vsrepo\\my-first-raqa\\wandb\\run-20231205_135828-pd04j1u0</code>"
|
806 |
+
],
|
807 |
+
"text/plain": [
|
808 |
+
"<IPython.core.display.HTML object>"
|
809 |
+
]
|
810 |
+
},
|
811 |
+
"metadata": {},
|
812 |
+
"output_type": "display_data"
|
813 |
+
},
|
814 |
+
{
|
815 |
+
"data": {
|
816 |
+
"text/html": [
|
817 |
+
"Syncing run <strong><a href='https://wandb.ai/deepmediamachine/Visibility%20Example/runs/pd04j1u0' target=\"_blank\">northern-disco-1</a></strong> to <a href='https://wandb.ai/deepmediamachine/Visibility%20Example' target=\"_blank\">Weights & Biases</a> (<a href='https://wandb.me/run' target=\"_blank\">docs</a>)<br/>"
|
818 |
+
],
|
819 |
+
"text/plain": [
|
820 |
+
"<IPython.core.display.HTML object>"
|
821 |
+
]
|
822 |
+
},
|
823 |
+
"metadata": {},
|
824 |
+
"output_type": "display_data"
|
825 |
+
},
|
826 |
+
{
|
827 |
+
"data": {
|
828 |
+
"text/html": [
|
829 |
+
" View project at <a href='https://wandb.ai/deepmediamachine/Visibility%20Example' target=\"_blank\">https://wandb.ai/deepmediamachine/Visibility%20Example</a>"
|
830 |
+
],
|
831 |
+
"text/plain": [
|
832 |
+
"<IPython.core.display.HTML object>"
|
833 |
+
]
|
834 |
+
},
|
835 |
+
"metadata": {},
|
836 |
+
"output_type": "display_data"
|
837 |
+
},
|
838 |
+
{
|
839 |
+
"data": {
|
840 |
+
"text/html": [
|
841 |
+
" View run at <a href='https://wandb.ai/deepmediamachine/Visibility%20Example/runs/pd04j1u0' target=\"_blank\">https://wandb.ai/deepmediamachine/Visibility%20Example/runs/pd04j1u0</a>"
|
842 |
+
],
|
843 |
+
"text/plain": [
|
844 |
+
"<IPython.core.display.HTML object>"
|
845 |
+
]
|
846 |
+
},
|
847 |
+
"metadata": {},
|
848 |
+
"output_type": "display_data"
|
849 |
+
},
|
850 |
+
{
|
851 |
+
"data": {
|
852 |
+
"text/html": [
|
853 |
+
"<button onClick=\"this.nextSibling.style.display='block';this.style.display='none';\">Display W&B run</button><iframe src='https://wandb.ai/deepmediamachine/Visibility%20Example/runs/pd04j1u0?jupyter=true' style='border:none;width:100%;height:420px;display:none;'></iframe>"
|
854 |
+
],
|
855 |
+
"text/plain": [
|
856 |
+
"<wandb.sdk.wandb_run.Run at 0x1c66e162a50>"
|
857 |
+
]
|
858 |
+
},
|
859 |
+
"execution_count": 28,
|
860 |
+
"metadata": {},
|
861 |
+
"output_type": "execute_result"
|
862 |
+
}
|
863 |
+
],
|
864 |
+
"source": [
|
865 |
+
"import wandb\n",
|
866 |
+
"\n",
|
867 |
+
"os.environ[\"WANDB_NOTEBOOK_NAME\"] = \"Python RAQA Example.ipynb\"\n",
|
868 |
+
"wandb.init(project=\"Visibility Example\")"
|
869 |
+
]
|
870 |
+
},
|
871 |
+
{
|
872 |
+
"cell_type": "markdown",
|
873 |
+
"metadata": {},
|
874 |
+
"source": [
|
875 |
+
"Now we can integrate Weights and Biases into our `RetrievalAugmentedQAPipeline`.\n",
|
876 |
+
"\n",
|
877 |
+
"```python\n",
|
878 |
+
"if self.wandb_project:\n",
|
879 |
+
" root_span = Trace(\n",
|
880 |
+
" name=\"root_span\",\n",
|
881 |
+
" kind=\"llm\",\n",
|
882 |
+
" status_code=status,\n",
|
883 |
+
" status_message=status_message,\n",
|
884 |
+
" start_time_ms=start_time,\n",
|
885 |
+
" end_time_ms=end_time,\n",
|
886 |
+
" metadata={\n",
|
887 |
+
" \"token_usage\" : token_usage\n",
|
888 |
+
" },\n",
|
889 |
+
" inputs= {\"system_prompt\" : formatted_system_prompt, \"user_prompt\" : formatted_user_prompt},\n",
|
890 |
+
" outputs= {\"response\" : response_text}\n",
|
891 |
+
" )\n",
|
892 |
+
"\n",
|
893 |
+
" root_span.log(name=\"openai_trace\")\n",
|
894 |
+
"```\n",
|
895 |
+
"\n",
|
896 |
+
"The main things to consider here are how to populate the various fields to make sure we're tracking useful information. \n",
|
897 |
+
"\n",
|
898 |
+
"We'll use the `text_only` flag to ensure we can get detailed information about our LLM call!\n",
|
899 |
+
"\n",
|
900 |
+
"You can check out all the parameters for Weights and Biases `Trace` [here](https://github.com/wandb/wandb/blob/653015a014281f45770aaf43627f64d9c4f04a32/wandb/sdk/data_types/trace_tree.py#L166)"
|
901 |
+
]
|
902 |
+
},
|
903 |
+
{
|
904 |
+
"cell_type": "code",
|
905 |
+
"execution_count": 29,
|
906 |
+
"metadata": {},
|
907 |
+
"outputs": [],
|
908 |
+
"source": [
|
909 |
+
"import datetime\n",
|
910 |
+
"from wandb.sdk.data_types.trace_tree import Trace\n",
|
911 |
+
"\n",
|
912 |
+
"class RetrievalAugmentedQAPipeline:\n",
|
913 |
+
" def __init__(self, llm: ChatOpenAI(), vector_db_retriever: VectorDatabase, wandb_project = None) -> None:\n",
|
914 |
+
" self.llm = llm\n",
|
915 |
+
" self.vector_db_retriever = vector_db_retriever\n",
|
916 |
+
" self.wandb_project = wandb_project\n",
|
917 |
+
"\n",
|
918 |
+
" def run_pipeline(self, user_query: str) -> str:\n",
|
919 |
+
" context_list = self.vector_db_retriever.search_by_text(user_query, k=4)\n",
|
920 |
+
" \n",
|
921 |
+
" context_prompt = \"\"\n",
|
922 |
+
" for context in context_list:\n",
|
923 |
+
" context_prompt += context[0] + \"\\n\"\n",
|
924 |
+
"\n",
|
925 |
+
" formatted_system_prompt = raqa_prompt.create_message(context=context_prompt)\n",
|
926 |
+
"\n",
|
927 |
+
" formatted_user_prompt = user_prompt.create_message(user_query=user_query)\n",
|
928 |
+
"\n",
|
929 |
+
" \n",
|
930 |
+
" start_time = datetime.datetime.now().timestamp() * 1000\n",
|
931 |
+
"\n",
|
932 |
+
" try:\n",
|
933 |
+
" openai_response = self.llm.run([formatted_system_prompt, formatted_user_prompt], text_only=False)\n",
|
934 |
+
" end_time = datetime.datetime.now().timestamp() * 1000\n",
|
935 |
+
" status = \"success\"\n",
|
936 |
+
" status_message = (None, )\n",
|
937 |
+
" response_text = openai_response.choices[0].message.content\n",
|
938 |
+
" token_usage = dict(openai_response.usage)\n",
|
939 |
+
" model = openai_response.model\n",
|
940 |
+
"\n",
|
941 |
+
" except Exception as e:\n",
|
942 |
+
" end_time = datetime.datetime.now().timestamp() * 1000\n",
|
943 |
+
" status = \"error\"\n",
|
944 |
+
" status_message = str(e)\n",
|
945 |
+
" response_text = \"\"\n",
|
946 |
+
" token_usage = {}\n",
|
947 |
+
" model = \"\"\n",
|
948 |
+
"\n",
|
949 |
+
" if self.wandb_project:\n",
|
950 |
+
" root_span = Trace(\n",
|
951 |
+
" name=\"root_span\",\n",
|
952 |
+
" kind=\"llm\",\n",
|
953 |
+
" status_code=status,\n",
|
954 |
+
" status_message=status_message,\n",
|
955 |
+
" start_time_ms=start_time,\n",
|
956 |
+
" end_time_ms=end_time,\n",
|
957 |
+
" metadata={\n",
|
958 |
+
" \"token_usage\" : token_usage,\n",
|
959 |
+
" \"model_name\" : model\n",
|
960 |
+
" },\n",
|
961 |
+
" inputs= {\"system_prompt\" : formatted_system_prompt, \"user_prompt\" : formatted_user_prompt},\n",
|
962 |
+
" outputs= {\"response\" : response_text}\n",
|
963 |
+
" )\n",
|
964 |
+
"\n",
|
965 |
+
" root_span.log(name=\"openai_trace\")\n",
|
966 |
+
" \n",
|
967 |
+
" return response_text if response_text else \"We ran into an error. Please try again later. Full Error Message: \" + status_message"
|
968 |
+
]
|
969 |
+
},
|
970 |
+
{
|
971 |
+
"cell_type": "code",
|
972 |
+
"execution_count": 30,
|
973 |
+
"metadata": {},
|
974 |
+
"outputs": [],
|
975 |
+
"source": [
|
976 |
+
"retrieval_augmented_qa_pipeline = RetrievalAugmentedQAPipeline(\n",
|
977 |
+
" vector_db_retriever=vector_db,\n",
|
978 |
+
" llm=chat_openai,\n",
|
979 |
+
" wandb_project=\"LLM Visibility Example\"\n",
|
980 |
+
")"
|
981 |
+
]
|
982 |
+
},
|
983 |
+
{
|
984 |
+
"cell_type": "code",
|
985 |
+
"execution_count": 31,
|
986 |
+
"metadata": {},
|
987 |
+
"outputs": [
|
988 |
+
{
|
989 |
+
"data": {
|
990 |
+
"text/plain": [
|
991 |
+
"\"I don't know.\""
|
992 |
+
]
|
993 |
+
},
|
994 |
+
"execution_count": 31,
|
995 |
+
"metadata": {},
|
996 |
+
"output_type": "execute_result"
|
997 |
+
}
|
998 |
+
],
|
999 |
+
"source": [
|
1000 |
+
"retrieval_augmented_qa_pipeline.run_pipeline(\"Who is Batman?\")"
|
1001 |
+
]
|
1002 |
+
},
|
1003 |
+
{
|
1004 |
+
"cell_type": "code",
|
1005 |
+
"execution_count": 32,
|
1006 |
+
"metadata": {},
|
1007 |
+
"outputs": [
|
1008 |
+
{
|
1009 |
+
"data": {
|
1010 |
+
"text/plain": [
|
1011 |
+
"'Cordelia dies. In the provided context, King Lear is seen holding Cordelia\\'s dead body in his arms. The text describes how he mourns her, exclaiming \"Howl, howl, howl, howl!\" and expressing his grief over her death.'"
|
1012 |
+
]
|
1013 |
+
},
|
1014 |
+
"execution_count": 32,
|
1015 |
+
"metadata": {},
|
1016 |
+
"output_type": "execute_result"
|
1017 |
+
}
|
1018 |
+
],
|
1019 |
+
"source": [
|
1020 |
+
"retrieval_augmented_qa_pipeline.run_pipeline(\"What happens to Cordelia?\")"
|
1021 |
+
]
|
1022 |
+
},
|
1023 |
+
{
|
1024 |
+
"cell_type": "markdown",
|
1025 |
+
"metadata": {},
|
1026 |
+
"source": [
|
1027 |
+
"Navigate to the Weights and Biases \"run\" link to see how your LLM is performing!\n",
|
1028 |
+
"\n",
|
1029 |
+
"```\n",
|
1030 |
+
"View run at YOUR LINK HERE\n",
|
1031 |
+
"```"
|
1032 |
+
]
|
1033 |
+
},
|
1034 |
+
{
|
1035 |
+
"cell_type": "markdown",
|
1036 |
+
"metadata": {},
|
1037 |
+
"source": [
|
1038 |
+
"# Conclusion\n",
|
1039 |
+
"\n",
|
1040 |
+
"In this notebook, we've gone through the steps required to create your own simple RAQA application!\n",
|
1041 |
+
"\n",
|
1042 |
+
"Please feel free to extend this as much as you'd like. "
|
1043 |
+
]
|
1044 |
+
},
|
1045 |
+
{
|
1046 |
+
"cell_type": "markdown",
|
1047 |
+
"metadata": {},
|
1048 |
+
"source": [
|
1049 |
+
"# Bonus Challenges\n",
|
1050 |
+
"\n",
|
1051 |
+
"Challenge 1: \n",
|
1052 |
+
"- Implement a new distance measure\n",
|
1053 |
+
"- Implement a more efficient vector search\n",
|
1054 |
+
"\n",
|
1055 |
+
"Challenge 2: \n",
|
1056 |
+
"- Create an external VectorStore that can be run/hosted elsewhere\n",
|
1057 |
+
"- Build an adapter for that VectorStore here"
|
1058 |
+
]
|
1059 |
+
},
|
1060 |
+
{
|
1061 |
+
"cell_type": "code",
|
1062 |
+
"execution_count": 2,
|
1063 |
+
"metadata": {},
|
1064 |
+
"outputs": [
|
1065 |
+
{
|
1066 |
+
"ename": "ModuleNotFoundError",
|
1067 |
+
"evalue": "No module named 'chainlit'",
|
1068 |
+
"output_type": "error",
|
1069 |
+
"traceback": [
|
1070 |
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
1071 |
+
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
1072 |
+
"\u001b[1;32mc:\\ai\\llmops3\\repos\\vsrepo\\my-first-raqa\\Python RAQA Example.ipynb Cell 53\u001b[0m line \u001b[0;36m1\n\u001b[1;32m----> <a href='vscode-notebook-cell:/c%3A/ai/llmops3/repos/vsrepo/my-first-raqa/Python%20RAQA%20Example.ipynb#Y103sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mchainlit\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mcl\u001b[39;00m \u001b[39m# importing chainlit for our app\u001b[39;00m\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/ai/llmops3/repos/vsrepo/my-first-raqa/Python%20RAQA%20Example.ipynb#Y103sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mchainlit\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mprompt\u001b[39;00m \u001b[39mimport\u001b[39;00m Prompt, PromptMessage \u001b[39m# importing prompt tools\u001b[39;00m\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/ai/llmops3/repos/vsrepo/my-first-raqa/Python%20RAQA%20Example.ipynb#Y103sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mchainlit\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mplayground\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mproviders\u001b[39;00m \u001b[39mimport\u001b[39;00m ChatOpenAI \u001b[39m# importing ChatOpenAI tools\u001b[39;00m\n",
|
1073 |
+
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'chainlit'"
|
1074 |
+
]
|
1075 |
+
}
|
1076 |
+
],
|
1077 |
+
"source": [
|
1078 |
+
"import chainlit as cl # importing chainlit for our app\n",
|
1079 |
+
"from chainlit.prompt import Prompt, PromptMessage # importing prompt tools\n",
|
1080 |
+
"from chainlit.playground.providers import ChatOpenAI # importing ChatOpenAI tools"
|
1081 |
+
]
|
1082 |
+
}
|
1083 |
+
],
|
1084 |
+
"metadata": {
|
1085 |
+
"kernelspec": {
|
1086 |
+
"display_name": "buildyourownlangchain",
|
1087 |
+
"language": "python",
|
1088 |
+
"name": "python3"
|
1089 |
+
},
|
1090 |
+
"language_info": {
|
1091 |
+
"codemirror_mode": {
|
1092 |
+
"name": "ipython",
|
1093 |
+
"version": 3
|
1094 |
+
},
|
1095 |
+
"file_extension": ".py",
|
1096 |
+
"mimetype": "text/x-python",
|
1097 |
+
"name": "python",
|
1098 |
+
"nbconvert_exporter": "python",
|
1099 |
+
"pygments_lexer": "ipython3",
|
1100 |
+
"version": "3.11.5"
|
1101 |
+
},
|
1102 |
+
"orig_nbformat": 4
|
1103 |
+
},
|
1104 |
+
"nbformat": 4,
|
1105 |
+
"nbformat_minor": 2
|
1106 |
+
}
|
README.md
CHANGED
@@ -1,11 +1,50 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
<p align = "center" draggable=”false” ><img src="https://github.com/AI-Maker-Space/LLM-Dev-101/assets/37101144/d1343317-fa2f-41e1-8af1-1dbb18399719"
|
4 |
+
width="200px"
|
5 |
+
height="auto"/>
|
6 |
+
</p>
|
7 |
+
|
8 |
+
## <h1 align="center" id="heading">🔍Your First Retrieval Augmented Generation QA Application!</h1>
|
9 |
+
|
10 |
+
### Steps to Run:
|
11 |
+
|
12 |
+
1. Create a Python 3.11 environment
|
13 |
+
2. `pip install jupyter` so you can run the notebook
|
14 |
+
|
15 |
+
# Build 🏗️
|
16 |
+
Build a Chainlit App that uses this code.
|
17 |
+
|
18 |
+
# Ship 🚢
|
19 |
+
- Deploy your Chainlit App to Hugging Face
|
20 |
+
- Make a simple diagram of the RAQA process
|
21 |
+
|
22 |
+
# Share 🚀
|
23 |
+
- Show your App in a loom video and explain the diagram
|
24 |
+
- Make a social media post about your final application and tag @AIMakerspace
|
25 |
+
- Share 3 lessons learned
|
26 |
+
- Share 3 lessons not learned
|
27 |
+
|
28 |
+
Here's a template to get your post started!
|
29 |
+
|
30 |
+
```
|
31 |
+
🚀 Exciting News! 🎉
|
32 |
+
|
33 |
+
I just built and shipped my very first Retrieval Augmented Generation QA Application using Chainlit and the OpenAI API! 🤖💼
|
34 |
+
|
35 |
+
🔍 Three Key Takeaways:
|
36 |
+
1️⃣ The power of combining traditional search methods with state-of-the-art generative models is mind-blowing. 🧠✨
|
37 |
+
2️⃣ Collaboration and leveraging community resources like AI Makerspace can greatly accelerate the learning curve. 🌱📈
|
38 |
+
3️⃣ Dive deep, keep iterating, and never stop learning. Each project brings a new set of challenges and equally rewarding lessons. 🔄📚
|
39 |
+
|
40 |
+
A huge shoutout to the @AI Makerspace for their invaluable resources and guidance. 🙌
|
41 |
+
|
42 |
+
Looking forward to more AI-driven adventures! 🌟 Feel free to connect if you'd like to chat more about it! 🤝
|
43 |
+
|
44 |
+
#OpenAI #Chainlit #AIPowered #Innovation #TechJourney
|
45 |
+
```
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
|
__pycache__/app.cpython-310.pyc
ADDED
Binary file (3.15 kB). View file
|
|
aimakerspace/__init__.py
ADDED
File without changes
|
aimakerspace/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (158 Bytes). View file
|
|
aimakerspace/__pycache__/__init__.cpython-311.pyc
ADDED
Binary file (174 Bytes). View file
|
|
aimakerspace/__pycache__/text_utils.cpython-310.pyc
ADDED
Binary file (2.9 kB). View file
|
|
aimakerspace/__pycache__/text_utils.cpython-311.pyc
ADDED
Binary file (5.4 kB). View file
|
|
aimakerspace/__pycache__/vectordatabase.cpython-310.pyc
ADDED
Binary file (3.57 kB). View file
|
|
aimakerspace/__pycache__/vectordatabase.cpython-311.pyc
ADDED
Binary file (5.7 kB). View file
|
|
aimakerspace/openai_utils/__init__.py
ADDED
File without changes
|
aimakerspace/openai_utils/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (171 Bytes). View file
|
|
aimakerspace/openai_utils/__pycache__/__init__.cpython-311.pyc
ADDED
Binary file (187 Bytes). View file
|
|
aimakerspace/openai_utils/__pycache__/chatmodel.cpython-310.pyc
ADDED
Binary file (1.11 kB). View file
|
|
aimakerspace/openai_utils/__pycache__/chatmodel.cpython-311.pyc
ADDED
Binary file (1.71 kB). View file
|
|
aimakerspace/openai_utils/__pycache__/embedding.cpython-310.pyc
ADDED
Binary file (2.47 kB). View file
|
|
aimakerspace/openai_utils/__pycache__/embedding.cpython-311.pyc
ADDED
Binary file (4.11 kB). View file
|
|
aimakerspace/openai_utils/__pycache__/prompts.cpython-310.pyc
ADDED
Binary file (3.56 kB). View file
|
|
aimakerspace/openai_utils/__pycache__/prompts.cpython-311.pyc
ADDED
Binary file (5.44 kB). View file
|
|
aimakerspace/openai_utils/chatmodel.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from openai import OpenAI
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
import os
|
4 |
+
|
5 |
+
load_dotenv()
|
6 |
+
|
7 |
+
|
8 |
+
class ChatOpenAI:
|
9 |
+
def __init__(self, model_name: str = "gpt-3.5-turbo"):
|
10 |
+
self.model_name = model_name
|
11 |
+
self.openai_api_key = os.getenv("OPENAI_API_KEY")
|
12 |
+
if self.openai_api_key is None:
|
13 |
+
raise ValueError("OPENAI_API_KEY is not set")
|
14 |
+
|
15 |
+
def run(self, messages, text_only: bool = True):
|
16 |
+
if not isinstance(messages, list):
|
17 |
+
raise ValueError("messages must be a list")
|
18 |
+
|
19 |
+
client = OpenAI()
|
20 |
+
response = client.chat.completions.create(
|
21 |
+
model=self.model_name, messages=messages
|
22 |
+
)
|
23 |
+
|
24 |
+
if text_only:
|
25 |
+
return response.choices[0].message.content
|
26 |
+
|
27 |
+
return response
|
aimakerspace/openai_utils/embedding.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dotenv import load_dotenv
|
2 |
+
from openai import AsyncOpenAI, OpenAI
|
3 |
+
import openai
|
4 |
+
from typing import List
|
5 |
+
import os
|
6 |
+
import asyncio
|
7 |
+
|
8 |
+
|
9 |
+
class EmbeddingModel:
|
10 |
+
def __init__(self, embeddings_model_name: str = "text-embedding-ada-002"):
|
11 |
+
load_dotenv()
|
12 |
+
self.openai_api_key = os.getenv("OPENAI_API_KEY")
|
13 |
+
self.async_client = AsyncOpenAI()
|
14 |
+
self.client = OpenAI()
|
15 |
+
|
16 |
+
if self.openai_api_key is None:
|
17 |
+
raise ValueError(
|
18 |
+
"OPENAI_API_KEY environment variable is not set. Please set it to your OpenAI API key."
|
19 |
+
)
|
20 |
+
openai.api_key = self.openai_api_key
|
21 |
+
self.embeddings_model_name = embeddings_model_name
|
22 |
+
|
23 |
+
async def async_get_embeddings(self, list_of_text: List[str]) -> List[List[float]]:
|
24 |
+
embedding_response = await self.async_client.embeddings.create(
|
25 |
+
input=list_of_text, model=self.embeddings_model_name
|
26 |
+
)
|
27 |
+
|
28 |
+
return [embeddings.embedding for embeddings in embedding_response.data]
|
29 |
+
|
30 |
+
async def async_get_embedding(self, text: str) -> List[float]:
|
31 |
+
embedding = await self.async_client.embeddings.create(
|
32 |
+
input=text, model=self.embeddings_model_name
|
33 |
+
)
|
34 |
+
|
35 |
+
return embedding.data[0].embedding
|
36 |
+
|
37 |
+
def get_embeddings(self, list_of_text: List[str]) -> List[List[float]]:
|
38 |
+
embedding_response = self.client.embeddings.create(
|
39 |
+
input=list_of_text, model=self.embeddings_model_name
|
40 |
+
)
|
41 |
+
|
42 |
+
return [embeddings.embedding for embeddings in embedding_response.data]
|
43 |
+
|
44 |
+
def get_embedding(self, text: str) -> List[float]:
|
45 |
+
embedding = self.client.embeddings.create(
|
46 |
+
input=text, model=self.embeddings_model_name
|
47 |
+
)
|
48 |
+
|
49 |
+
return embedding.data[0].embedding
|
50 |
+
|
51 |
+
|
52 |
+
if __name__ == "__main__":
|
53 |
+
embedding_model = EmbeddingModel()
|
54 |
+
print(asyncio.run(embedding_model.async_get_embedding("Hello, world!")))
|
55 |
+
print(
|
56 |
+
asyncio.run(
|
57 |
+
embedding_model.async_get_embeddings(["Hello, world!", "Goodbye, world!"])
|
58 |
+
)
|
59 |
+
)
|
aimakerspace/openai_utils/prompts.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
|
3 |
+
|
4 |
+
class BasePrompt:
|
5 |
+
def __init__(self, prompt):
|
6 |
+
"""
|
7 |
+
Initializes the BasePrompt object with a prompt template.
|
8 |
+
|
9 |
+
:param prompt: A string that can contain placeholders within curly braces
|
10 |
+
"""
|
11 |
+
self.prompt = prompt
|
12 |
+
self._pattern = re.compile(r"\{([^}]+)\}")
|
13 |
+
|
14 |
+
def format_prompt(self, **kwargs):
|
15 |
+
"""
|
16 |
+
Formats the prompt string using the keyword arguments provided.
|
17 |
+
|
18 |
+
:param kwargs: The values to substitute into the prompt string
|
19 |
+
:return: The formatted prompt string
|
20 |
+
"""
|
21 |
+
matches = self._pattern.findall(self.prompt)
|
22 |
+
return self.prompt.format(**{match: kwargs.get(match, "") for match in matches})
|
23 |
+
|
24 |
+
def get_input_variables(self):
|
25 |
+
"""
|
26 |
+
Gets the list of input variable names from the prompt string.
|
27 |
+
|
28 |
+
:return: List of input variable names
|
29 |
+
"""
|
30 |
+
return self._pattern.findall(self.prompt)
|
31 |
+
|
32 |
+
|
33 |
+
class RolePrompt(BasePrompt):
|
34 |
+
def __init__(self, prompt, role: str):
|
35 |
+
"""
|
36 |
+
Initializes the RolePrompt object with a prompt template and a role.
|
37 |
+
|
38 |
+
:param prompt: A string that can contain placeholders within curly braces
|
39 |
+
:param role: The role for the message ('system', 'user', or 'assistant')
|
40 |
+
"""
|
41 |
+
super().__init__(prompt)
|
42 |
+
self.role = role
|
43 |
+
|
44 |
+
def create_message(self, **kwargs):
|
45 |
+
"""
|
46 |
+
Creates a message dictionary with a role and a formatted message.
|
47 |
+
|
48 |
+
:param kwargs: The values to substitute into the prompt string
|
49 |
+
:return: Dictionary containing the role and the formatted message
|
50 |
+
"""
|
51 |
+
return {"role": self.role, "content": self.format_prompt(**kwargs)}
|
52 |
+
|
53 |
+
|
54 |
+
class SystemRolePrompt(RolePrompt):
|
55 |
+
def __init__(self, prompt: str):
|
56 |
+
super().__init__(prompt, "system")
|
57 |
+
|
58 |
+
|
59 |
+
class UserRolePrompt(RolePrompt):
|
60 |
+
def __init__(self, prompt: str):
|
61 |
+
super().__init__(prompt, "user")
|
62 |
+
|
63 |
+
|
64 |
+
class AssistantRolePrompt(RolePrompt):
|
65 |
+
def __init__(self, prompt: str):
|
66 |
+
super().__init__(prompt, "assistant")
|
67 |
+
|
68 |
+
|
69 |
+
if __name__ == "__main__":
|
70 |
+
prompt = BasePrompt("Hello {name}, you are {age} years old")
|
71 |
+
print(prompt.format_prompt(name="John", age=30))
|
72 |
+
|
73 |
+
prompt = SystemRolePrompt("Hello {name}, you are {age} years old")
|
74 |
+
print(prompt.create_message(name="John", age=30))
|
75 |
+
print(prompt.get_input_variables())
|
aimakerspace/text_utils.py
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from typing import List
|
3 |
+
|
4 |
+
|
5 |
+
class TextFileLoader:
|
6 |
+
def __init__(self, path: str, encoding: str = "utf-8"):
|
7 |
+
self.documents = []
|
8 |
+
self.path = path
|
9 |
+
self.encoding = encoding
|
10 |
+
|
11 |
+
def load(self):
|
12 |
+
if os.path.isdir(self.path):
|
13 |
+
self.load_directory()
|
14 |
+
elif os.path.isfile(self.path) and self.path.endswith(".txt"):
|
15 |
+
self.load_file()
|
16 |
+
else:
|
17 |
+
raise ValueError(
|
18 |
+
"Provided path is neither a valid directory nor a .txt file."
|
19 |
+
)
|
20 |
+
|
21 |
+
def load_file(self):
|
22 |
+
with open(self.path, "r", encoding=self.encoding) as f:
|
23 |
+
self.documents.append(f.read())
|
24 |
+
|
25 |
+
def load_directory(self):
|
26 |
+
for root, _, files in os.walk(self.path):
|
27 |
+
for file in files:
|
28 |
+
if file.endswith(".txt"):
|
29 |
+
with open(
|
30 |
+
os.path.join(root, file), "r", encoding=self.encoding
|
31 |
+
) as f:
|
32 |
+
self.documents.append(f.read())
|
33 |
+
|
34 |
+
def load_documents(self):
|
35 |
+
self.load()
|
36 |
+
return self.documents
|
37 |
+
|
38 |
+
|
39 |
+
class CharacterTextSplitter:
|
40 |
+
def __init__(
|
41 |
+
self,
|
42 |
+
chunk_size: int = 1000,
|
43 |
+
chunk_overlap: int = 200,
|
44 |
+
):
|
45 |
+
assert (
|
46 |
+
chunk_size > chunk_overlap
|
47 |
+
), "Chunk size must be greater than chunk overlap"
|
48 |
+
|
49 |
+
self.chunk_size = chunk_size
|
50 |
+
self.chunk_overlap = chunk_overlap
|
51 |
+
|
52 |
+
def split(self, text: str) -> List[str]:
|
53 |
+
chunks = []
|
54 |
+
for i in range(0, len(text), self.chunk_size - self.chunk_overlap):
|
55 |
+
chunks.append(text[i : i + self.chunk_size])
|
56 |
+
return chunks
|
57 |
+
|
58 |
+
def split_texts(self, texts: List[str]) -> List[str]:
|
59 |
+
chunks = []
|
60 |
+
for text in texts:
|
61 |
+
chunks.extend(self.split(text))
|
62 |
+
return chunks
|
63 |
+
|
64 |
+
|
65 |
+
if __name__ == "__main__":
|
66 |
+
loader = TextFileLoader("data/KingLear.txt")
|
67 |
+
loader.load()
|
68 |
+
splitter = CharacterTextSplitter()
|
69 |
+
chunks = splitter.split_texts(loader.documents)
|
70 |
+
print(len(chunks))
|
71 |
+
print(chunks[0])
|
72 |
+
print("--------")
|
73 |
+
print(chunks[1])
|
74 |
+
print("--------")
|
75 |
+
print(chunks[-2])
|
76 |
+
print("--------")
|
77 |
+
print(chunks[-1])
|
aimakerspace/vectordatabase.py
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
from collections import defaultdict
|
3 |
+
from typing import List, Tuple, Callable
|
4 |
+
from aimakerspace.openai_utils.embedding import EmbeddingModel
|
5 |
+
import asyncio
|
6 |
+
|
7 |
+
|
8 |
+
def cosine_similarity(vector_a: np.array, vector_b: np.array) -> float:
|
9 |
+
"""Computes the cosine similarity between two vectors."""
|
10 |
+
dot_product = np.dot(vector_a, vector_b)
|
11 |
+
norm_a = np.linalg.norm(vector_a)
|
12 |
+
norm_b = np.linalg.norm(vector_b)
|
13 |
+
return dot_product / (norm_a * norm_b)
|
14 |
+
|
15 |
+
|
16 |
+
class VectorDatabase:
|
17 |
+
def __init__(self, embedding_model: EmbeddingModel = None):
|
18 |
+
self.vectors = defaultdict(np.array)
|
19 |
+
self.embedding_model = embedding_model or EmbeddingModel()
|
20 |
+
|
21 |
+
def insert(self, key: str, vector: np.array) -> None:
|
22 |
+
self.vectors[key] = vector
|
23 |
+
|
24 |
+
def search(
|
25 |
+
self,
|
26 |
+
query_vector: np.array,
|
27 |
+
k: int,
|
28 |
+
distance_measure: Callable = cosine_similarity,
|
29 |
+
) -> List[Tuple[str, float]]:
|
30 |
+
scores = [
|
31 |
+
(key, distance_measure(query_vector, vector))
|
32 |
+
for key, vector in self.vectors.items()
|
33 |
+
]
|
34 |
+
return sorted(scores, key=lambda x: x[1], reverse=True)[:k]
|
35 |
+
|
36 |
+
def search_by_text(
|
37 |
+
self,
|
38 |
+
query_text: str,
|
39 |
+
k: int,
|
40 |
+
distance_measure: Callable = cosine_similarity,
|
41 |
+
return_as_text: bool = False,
|
42 |
+
) -> List[Tuple[str, float]]:
|
43 |
+
query_vector = self.embedding_model.get_embedding(query_text)
|
44 |
+
results = self.search(query_vector, k, distance_measure)
|
45 |
+
return [result[0] for result in results] if return_as_text else results
|
46 |
+
|
47 |
+
def retrieve_from_key(self, key: str) -> np.array:
|
48 |
+
return self.vectors.get(key, None)
|
49 |
+
|
50 |
+
async def abuild_from_list(self, list_of_text: List[str]) -> "VectorDatabase":
|
51 |
+
embeddings = await self.embedding_model.async_get_embeddings(list_of_text)
|
52 |
+
for text, embedding in zip(list_of_text, embeddings):
|
53 |
+
self.insert(text, np.array(embedding))
|
54 |
+
return self
|
55 |
+
|
56 |
+
|
57 |
+
if __name__ == "__main__":
|
58 |
+
list_of_text = [
|
59 |
+
"I like to eat broccoli and bananas.",
|
60 |
+
"I ate a banana and spinach smoothie for breakfast.",
|
61 |
+
"Chinchillas and kittens are cute.",
|
62 |
+
"My sister adopted a kitten yesterday.",
|
63 |
+
"Look at this cute hamster munching on a piece of broccoli.",
|
64 |
+
]
|
65 |
+
|
66 |
+
vector_db = VectorDatabase()
|
67 |
+
vector_db = asyncio.run(vector_db.abuild_from_list(list_of_text))
|
68 |
+
k = 2
|
69 |
+
|
70 |
+
searched_vector = vector_db.search_by_text("I think fruit is awesome!", k=k)
|
71 |
+
print(f"Closest {k} vector(s):", searched_vector)
|
72 |
+
|
73 |
+
retrieved_vector = vector_db.retrieve_from_key(
|
74 |
+
"I like to eat broccoli and bananas."
|
75 |
+
)
|
76 |
+
print("Retrieved vector:", retrieved_vector)
|
77 |
+
|
78 |
+
relevant_texts = vector_db.search_by_text(
|
79 |
+
"I think fruit is awesome!", k=k, return_as_text=True
|
80 |
+
)
|
81 |
+
print(f"Closest {k} text(s):", relevant_texts)
|
app.py
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from aimakerspace.text_utils import TextFileLoader, CharacterTextSplitter
|
2 |
+
from aimakerspace.vectordatabase import VectorDatabase
|
3 |
+
import asyncio
|
4 |
+
import os
|
5 |
+
import openai
|
6 |
+
from getpass import getpass
|
7 |
+
from aimakerspace.openai_utils.prompts import (
|
8 |
+
UserRolePrompt,
|
9 |
+
SystemRolePrompt,
|
10 |
+
AssistantRolePrompt,
|
11 |
+
)
|
12 |
+
|
13 |
+
from aimakerspace.openai_utils.chatmodel import ChatOpenAI
|
14 |
+
import chainlit as cl # importing chainlit for our app
|
15 |
+
from chainlit.prompt import Prompt, PromptMessage # importing prompt tools
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
text_loader = TextFileLoader("data/KingLear.txt")
|
21 |
+
documents = text_loader.load_documents()
|
22 |
+
len(documents)
|
23 |
+
|
24 |
+
print(documents[0][:600])
|
25 |
+
|
26 |
+
|
27 |
+
text_splitter = CharacterTextSplitter()
|
28 |
+
split_documents = text_splitter.split_texts(documents)
|
29 |
+
len(split_documents)
|
30 |
+
|
31 |
+
split_documents[0:1]
|
32 |
+
|
33 |
+
vector_db = VectorDatabase()
|
34 |
+
vector_db = asyncio.run(vector_db.abuild_from_list(split_documents))
|
35 |
+
|
36 |
+
#vector_db.search_by_text("Your servant Kent. Where is your servant Caius?", k=3)
|
37 |
+
|
38 |
+
|
39 |
+
chat_openai = ChatOpenAI()
|
40 |
+
user_prompt_template = "{content}"
|
41 |
+
user_role_prompt = UserRolePrompt(user_prompt_template)
|
42 |
+
system_prompt_template = (
|
43 |
+
"You are an expert in {expertise}, you always answer in a kind way."
|
44 |
+
)
|
45 |
+
system_role_prompt = SystemRolePrompt(system_prompt_template)
|
46 |
+
|
47 |
+
messages = [
|
48 |
+
user_role_prompt.create_message(
|
49 |
+
content="What is the best way to write a loop?"
|
50 |
+
),
|
51 |
+
system_role_prompt.create_message(expertise="Python"),
|
52 |
+
]
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
#response = chat_openai.run(messages)
|
58 |
+
|
59 |
+
#print(response)
|
60 |
+
|
61 |
+
RAQA_PROMPT_TEMPLATE = """
|
62 |
+
Use the provided context to answer the user's query.
|
63 |
+
|
64 |
+
You may not answer the user's query unless there is specific context in the following text.
|
65 |
+
|
66 |
+
If you do not know the answer, or cannot answer, please respond with "I don't know".
|
67 |
+
|
68 |
+
Context:
|
69 |
+
{context}
|
70 |
+
"""
|
71 |
+
|
72 |
+
raqa_prompt = SystemRolePrompt(RAQA_PROMPT_TEMPLATE)
|
73 |
+
|
74 |
+
|
75 |
+
USER_PROMPT_TEMPLATE = """
|
76 |
+
User Query:
|
77 |
+
{user_query}
|
78 |
+
"""
|
79 |
+
|
80 |
+
user_prompt = UserRolePrompt(USER_PROMPT_TEMPLATE)
|
81 |
+
|
82 |
+
class RetrievalAugmentedQAPipeline:
|
83 |
+
def __init__(self, llm: ChatOpenAI(), vector_db_retriever: VectorDatabase) -> None:
|
84 |
+
self.llm = llm
|
85 |
+
self.vector_db_retriever = vector_db_retriever
|
86 |
+
|
87 |
+
def run_pipeline(self, user_query: str) -> str:
|
88 |
+
context_list = self.vector_db_retriever.search_by_text(user_query, k=4)
|
89 |
+
|
90 |
+
context_prompt = ""
|
91 |
+
for context in context_list:
|
92 |
+
context_prompt += context[0] + "\n"
|
93 |
+
|
94 |
+
formatted_system_prompt = raqa_prompt.create_message(context=context_prompt)
|
95 |
+
|
96 |
+
formatted_user_prompt = user_prompt.create_message(user_query=user_query)
|
97 |
+
|
98 |
+
return self.llm.run([formatted_system_prompt, formatted_user_prompt])
|
99 |
+
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
|
104 |
+
retrieval_augmented_qa_pipeline = RetrievalAugmentedQAPipeline(
|
105 |
+
vector_db_retriever=vector_db,
|
106 |
+
llm=chat_openai
|
107 |
+
)
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
|
112 |
+
#print(retrieval_augmented_qa_pipeline.run_pipeline("Who is King Lear?"))
|
113 |
+
|
114 |
+
|
115 |
+
|
116 |
+
@cl.on_chat_start # marks a function that will be executed at the start of a user session
|
117 |
+
async def start_chat():
|
118 |
+
settings = {
|
119 |
+
"model": "gpt-3.5-turbo",
|
120 |
+
"temperature": 0,
|
121 |
+
"max_tokens": 500,
|
122 |
+
"top_p": 1,
|
123 |
+
"frequency_penalty": 0,
|
124 |
+
"presence_penalty": 0,
|
125 |
+
}
|
126 |
+
|
127 |
+
cl.user_session.set("settings", settings)
|
128 |
+
|
129 |
+
|
130 |
+
|
131 |
+
|
132 |
+
@cl.on_message # marks a function that should be run each time the chatbot receives a message from a user
|
133 |
+
async def main(message: cl.Message):
|
134 |
+
|
135 |
+
await cl.Message(content=retrieval_augmented_qa_pipeline.run_pipeline(message.content), elements=[]).send()
|
136 |
+
|
137 |
+
|
chainlit.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Welcome to Chainlit! 🚀🤖
|
2 |
+
|
3 |
+
Hi there, Developer! 👋 We're excited to have you on board. Chainlit is a powerful tool designed to help you prototype, debug and share applications built on top of LLMs.
|
4 |
+
|
5 |
+
## Useful Links 🔗
|
6 |
+
|
7 |
+
- **Documentation:** Get started with our comprehensive [Chainlit Documentation](https://docs.chainlit.io) 📚
|
8 |
+
- **Discord Community:** Join our friendly [Chainlit Discord](https://discord.gg/k73SQ3FyUh) to ask questions, share your projects, and connect with other developers! 💬
|
9 |
+
|
10 |
+
We can't wait to see what you create with Chainlit! Happy coding! 💻😊
|
11 |
+
|
12 |
+
## Welcome screen
|
13 |
+
|
14 |
+
To modify the welcome screen, edit the `chainlit.md` file at the root of your project. If you do not want a welcome screen, just leave this file empty.
|
data/KingLear.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
images/docchain_img.png
ADDED
images/raqaapp_img.png
ADDED
images/texsplitter_img.png
ADDED
requirements.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
numpy==1.25.2
|
2 |
+
openai
|
3 |
+
python-dotenv==1.0.0
|
4 |
+
pandas
|
5 |
+
scikit-learn
|
6 |
+
ipykernel
|
7 |
+
matplotlib
|
8 |
+
plotly
|
9 |
+
chainlit==0.7.700
|
10 |
+
cohere==4.37
|
11 |
+
openai==1.3.5
|
12 |
+
tiktoken==0.5.1
|
wandb/run-20231205_135828-pd04j1u0/files/conda-environment.yaml
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: my-first-raqa
|
2 |
+
channels:
|
3 |
+
- defaults
|
4 |
+
- conda-forge
|
5 |
+
dependencies:
|
6 |
+
- asttokens=2.4.1=pyhd8ed1ab_0
|
7 |
+
- bzip2=1.0.8=he774522_0
|
8 |
+
- ca-certificates=2023.11.17=h56e8100_0
|
9 |
+
- colorama=0.4.6=pyhd8ed1ab_0
|
10 |
+
- comm=0.1.4=pyhd8ed1ab_0
|
11 |
+
- debugpy=1.6.7=py311hd77b12b_0
|
12 |
+
- decorator=5.1.1=pyhd8ed1ab_0
|
13 |
+
- exceptiongroup=1.2.0=pyhd8ed1ab_0
|
14 |
+
- executing=2.0.1=pyhd8ed1ab_0
|
15 |
+
- importlib-metadata=7.0.0=pyha770c72_0
|
16 |
+
- importlib_metadata=7.0.0=hd8ed1ab_0
|
17 |
+
- ipykernel=6.26.0=pyha63f2e9_0
|
18 |
+
- ipython=8.18.1=pyh5737063_2
|
19 |
+
- jedi=0.19.1=pyhd8ed1ab_0
|
20 |
+
- jupyter_client=8.6.0=pyhd8ed1ab_0
|
21 |
+
- jupyter_core=5.5.0=py311h1ea47a8_0
|
22 |
+
- libffi=3.4.4=hd77b12b_0
|
23 |
+
- libsodium=1.0.18=h8d14728_1
|
24 |
+
- matplotlib-inline=0.1.6=pyhd8ed1ab_0
|
25 |
+
- nest-asyncio=1.5.8=pyhd8ed1ab_0
|
26 |
+
- openssl=3.0.12=h2bbff1b_0
|
27 |
+
- packaging=23.2=pyhd8ed1ab_0
|
28 |
+
- parso=0.8.3=pyhd8ed1ab_0
|
29 |
+
- pickleshare=0.7.5=py_1003
|
30 |
+
- pip=23.3.1=py311haa95532_0
|
31 |
+
- platformdirs=4.1.0=pyhd8ed1ab_0
|
32 |
+
- prompt-toolkit=3.0.41=pyha770c72_0
|
33 |
+
- psutil=5.9.0=py311h2bbff1b_0
|
34 |
+
- pure_eval=0.2.2=pyhd8ed1ab_0
|
35 |
+
- pygments=2.17.2=pyhd8ed1ab_0
|
36 |
+
- python=3.11.5=he1021f5_0
|
37 |
+
- python-dateutil=2.8.2=pyhd8ed1ab_0
|
38 |
+
- python_abi=3.11=2_cp311
|
39 |
+
- pywin32=305=py311h2bbff1b_0
|
40 |
+
- pyzmq=25.1.0=py311hd77b12b_0
|
41 |
+
- setuptools=68.0.0=py311haa95532_0
|
42 |
+
- six=1.16.0=pyh6c4a22f_0
|
43 |
+
- sqlite=3.41.2=h2bbff1b_0
|
44 |
+
- stack_data=0.6.2=pyhd8ed1ab_0
|
45 |
+
- tk=8.6.12=h2bbff1b_0
|
46 |
+
- tornado=6.3.3=py311h2bbff1b_0
|
47 |
+
- traitlets=5.14.0=pyhd8ed1ab_0
|
48 |
+
- typing_extensions=4.8.0=pyha770c72_0
|
49 |
+
- vc=14.2=h21ff451_1
|
50 |
+
- vs2015_runtime=14.27.29016=h5e58377_2
|
51 |
+
- wcwidth=0.2.12=pyhd8ed1ab_0
|
52 |
+
- wheel=0.41.2=py311haa95532_0
|
53 |
+
- xz=5.4.5=h8cc25b3_0
|
54 |
+
- zeromq=4.3.4=h0e60522_1
|
55 |
+
- zipp=3.17.0=pyhd8ed1ab_0
|
56 |
+
- zlib=1.2.13=h8cc25b3_0
|
57 |
+
- pip:
|
58 |
+
- annotated-types==0.6.0
|
59 |
+
- anyio==3.7.1
|
60 |
+
- appdirs==1.4.4
|
61 |
+
- certifi==2023.11.17
|
62 |
+
- charset-normalizer==3.3.2
|
63 |
+
- click==8.1.7
|
64 |
+
- contourpy==1.2.0
|
65 |
+
- cycler==0.12.1
|
66 |
+
- distro==1.8.0
|
67 |
+
- docker-pycreds==0.4.0
|
68 |
+
- fonttools==4.46.0
|
69 |
+
- gitdb==4.0.11
|
70 |
+
- gitpython==3.1.40
|
71 |
+
- h11==0.14.0
|
72 |
+
- httpcore==1.0.2
|
73 |
+
- httpx==0.25.2
|
74 |
+
- idna==3.6
|
75 |
+
- joblib==1.3.2
|
76 |
+
- kiwisolver==1.4.5
|
77 |
+
- matplotlib==3.8.2
|
78 |
+
- numpy==1.26.2
|
79 |
+
- openai==1.3.7
|
80 |
+
- pandas==2.1.3
|
81 |
+
- pillow==10.1.0
|
82 |
+
- plotly==5.18.0
|
83 |
+
- protobuf==4.25.1
|
84 |
+
- pydantic==2.5.2
|
85 |
+
- pydantic-core==2.14.5
|
86 |
+
- pyparsing==3.1.1
|
87 |
+
- python-dotenv==1.0.0
|
88 |
+
- pytz==2023.3.post1
|
89 |
+
- pyyaml==6.0.1
|
90 |
+
- requests==2.31.0
|
91 |
+
- scikit-learn==1.3.2
|
92 |
+
- scipy==1.11.4
|
93 |
+
- sentry-sdk==1.38.0
|
94 |
+
- setproctitle==1.3.3
|
95 |
+
- smmap==5.0.1
|
96 |
+
- sniffio==1.3.0
|
97 |
+
- tenacity==8.2.3
|
98 |
+
- threadpoolctl==3.2.0
|
99 |
+
- tqdm==4.66.1
|
100 |
+
- tzdata==2023.3
|
101 |
+
- urllib3==2.1.0
|
102 |
+
- wandb==0.16.0
|
103 |
+
prefix: C:\Users\Bizon\anaconda3\envs\my-first-raqa
|
wandb/run-20231205_135828-pd04j1u0/files/config.yaml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
wandb_version: 1
|
2 |
+
|
3 |
+
_wandb:
|
4 |
+
desc: null
|
5 |
+
value:
|
6 |
+
python_version: 3.11.5
|
7 |
+
cli_version: 0.16.0
|
8 |
+
is_jupyter_run: true
|
9 |
+
is_kaggle_kernel: false
|
10 |
+
start_time: 1701802708.120483
|
11 |
+
t:
|
12 |
+
1:
|
13 |
+
- 55
|
14 |
+
- 95
|
15 |
+
2:
|
16 |
+
- 55
|
17 |
+
- 95
|
18 |
+
3:
|
19 |
+
- 23
|
20 |
+
4: 3.11.5
|
21 |
+
5: 0.16.0
|
22 |
+
8:
|
23 |
+
- 1
|
24 |
+
- 3
|
25 |
+
- 5
|
26 |
+
13: windows-amd64
|
wandb/run-20231205_135828-pd04j1u0/files/requirements.txt
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
annotated-types==0.6.0
|
2 |
+
anyio==3.7.1
|
3 |
+
appdirs==1.4.4
|
4 |
+
asttokens==2.4.1
|
5 |
+
certifi==2023.11.17
|
6 |
+
charset-normalizer==3.3.2
|
7 |
+
click==8.1.7
|
8 |
+
colorama==0.4.6
|
9 |
+
comm==0.1.4
|
10 |
+
contourpy==1.2.0
|
11 |
+
cycler==0.12.1
|
12 |
+
debugpy==1.6.7
|
13 |
+
decorator==5.1.1
|
14 |
+
distro==1.8.0
|
15 |
+
docker-pycreds==0.4.0
|
16 |
+
exceptiongroup==1.2.0
|
17 |
+
executing==2.0.1
|
18 |
+
fonttools==4.46.0
|
19 |
+
gitdb==4.0.11
|
20 |
+
gitpython==3.1.40
|
21 |
+
h11==0.14.0
|
22 |
+
httpcore==1.0.2
|
23 |
+
httpx==0.25.2
|
24 |
+
idna==3.6
|
25 |
+
importlib-metadata==7.0.0
|
26 |
+
ipykernel==6.26.0
|
27 |
+
ipython==8.18.1
|
28 |
+
jedi==0.19.1
|
29 |
+
joblib==1.3.2
|
30 |
+
jupyter-client==8.6.0
|
31 |
+
jupyter-core==5.5.0
|
32 |
+
kiwisolver==1.4.5
|
33 |
+
matplotlib-inline==0.1.6
|
34 |
+
matplotlib==3.8.2
|
35 |
+
nest-asyncio==1.5.8
|
36 |
+
numpy==1.26.2
|
37 |
+
openai==1.3.7
|
38 |
+
packaging==23.2
|
39 |
+
pandas==2.1.3
|
40 |
+
parso==0.8.3
|
41 |
+
pickleshare==0.7.5
|
42 |
+
pillow==10.1.0
|
43 |
+
pip==23.3.1
|
44 |
+
platformdirs==4.1.0
|
45 |
+
plotly==5.18.0
|
46 |
+
prompt-toolkit==3.0.41
|
47 |
+
protobuf==4.25.1
|
48 |
+
psutil==5.9.0
|
49 |
+
pure-eval==0.2.2
|
50 |
+
pydantic-core==2.14.5
|
51 |
+
pydantic==2.5.2
|
52 |
+
pygments==2.17.2
|
53 |
+
pyparsing==3.1.1
|
54 |
+
python-dateutil==2.8.2
|
55 |
+
python-dotenv==1.0.0
|
56 |
+
pytz==2023.3.post1
|
57 |
+
pywin32==305.1
|
58 |
+
pyyaml==6.0.1
|
59 |
+
pyzmq==25.1.0
|
60 |
+
requests==2.31.0
|
61 |
+
scikit-learn==1.3.2
|
62 |
+
scipy==1.11.4
|
63 |
+
sentry-sdk==1.38.0
|
64 |
+
setproctitle==1.3.3
|
65 |
+
setuptools==68.0.0
|
66 |
+
six==1.16.0
|
67 |
+
smmap==5.0.1
|
68 |
+
sniffio==1.3.0
|
69 |
+
stack-data==0.6.2
|
70 |
+
tenacity==8.2.3
|
71 |
+
threadpoolctl==3.2.0
|
72 |
+
tornado==6.3.3
|
73 |
+
tqdm==4.66.1
|
74 |
+
traitlets==5.14.0
|
75 |
+
typing-extensions==4.8.0
|
76 |
+
tzdata==2023.3
|
77 |
+
urllib3==2.1.0
|
78 |
+
wandb==0.16.0
|
79 |
+
wcwidth==0.2.12
|
80 |
+
wheel==0.41.2
|
81 |
+
zipp==3.17.0
|
wandb/run-20231205_135828-pd04j1u0/files/wandb-metadata.json
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"os": "Windows-10-10.0.19045-SP0",
|
3 |
+
"python": "3.11.5",
|
4 |
+
"heartbeatAt": "2023-12-05T18:58:29.805384",
|
5 |
+
"startedAt": "2023-12-05T18:58:28.090482",
|
6 |
+
"docker": null,
|
7 |
+
"cuda": null,
|
8 |
+
"args": [],
|
9 |
+
"state": "running",
|
10 |
+
"program": "Python RAQA Example.ipynb",
|
11 |
+
"codePathLocal": "Python RAQA Example.ipynb",
|
12 |
+
"git": {
|
13 |
+
"remote": "https://github.com/GarrettG-AI/my-first-raqa.git",
|
14 |
+
"commit": "6768601ad99a97af33bbd157342d020a39e37f7a"
|
15 |
+
},
|
16 |
+
"email": "[email protected]",
|
17 |
+
"root": "C:/ai/llmops3/repos/vsrepo/my-first-raqa",
|
18 |
+
"host": "DESKTOP-36DNTBA",
|
19 |
+
"username": "Bizon",
|
20 |
+
"executable": "c:\\Users\\Bizon\\anaconda3\\envs\\my-first-raqa\\python.exe",
|
21 |
+
"cpu_count": 10,
|
22 |
+
"cpu_count_logical": 20,
|
23 |
+
"cpu_freq": {
|
24 |
+
"current": 1200.0,
|
25 |
+
"min": 0.0,
|
26 |
+
"max": 3701.0
|
27 |
+
},
|
28 |
+
"cpu_freq_per_core": [
|
29 |
+
{
|
30 |
+
"current": 1200.0,
|
31 |
+
"min": 0.0,
|
32 |
+
"max": 3701.0
|
33 |
+
}
|
34 |
+
],
|
35 |
+
"disk": {
|
36 |
+
"/": {
|
37 |
+
"total": 1862.4150085449219,
|
38 |
+
"used": 1205.1566047668457
|
39 |
+
}
|
40 |
+
},
|
41 |
+
"gpu": "Quadro RTX 8000",
|
42 |
+
"gpu_count": 1,
|
43 |
+
"gpu_devices": [
|
44 |
+
{
|
45 |
+
"name": "Quadro RTX 8000",
|
46 |
+
"memory_total": 48318382080
|
47 |
+
}
|
48 |
+
],
|
49 |
+
"memory": {
|
50 |
+
"total": 191.6897430419922
|
51 |
+
}
|
52 |
+
}
|
wandb/run-20231205_135828-pd04j1u0/files/wandb-summary.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"openai_trace": {"_type": "wb_trace_tree", "root_span_dumps": "{\"span_id\": null, \"name\": \"root_span\", \"start_time_ms\": 1701802867580.3179, \"end_time_ms\": 1701802869741.7852, \"status_code\": \"SUCCESS\", \"status_message\": [null], \"attributes\": {\"token_usage\": {\"completion_tokens\": 57, \"prompt_tokens\": 1221, \"total_tokens\": 1278}, \"model_name\": \"gpt-3.5-turbo-0613\"}, \"results\": [{\"inputs\": {\"system_prompt\": {\"role\": \"system\", \"content\": \"\\nUse the provided context to answer the user's query. \\n\\nYou may not answer the user's query unless there is specific context in the following text.\\n\\nIf you do not know the answer, or cannot answer, please respond with \\\"I don't know\\\".\\n\\nContext:\\nhang Cordelia in the prison, and\\nTo lay the blame upon her own despair,\\nThat she fordid herself.\\nALBANY\\nThe gods defend her! Bear him hence awhile.\\nEDMUND is borne off\\n\\nRe-enter KING LEAR, with CORDELIA dead in his arms; EDGAR, Captain, and others following\\n\\nKING LEAR\\nHowl, howl, howl, howl! O, you are men of stones:\\nHad I your tongues and eyes, I'ld use them so\\nThat heaven's vault should crack. She's gone for ever!\\nI know when one is dead, and when one lives;\\nShe's dead as earth. Lend me a looking-glass;\\nIf that her breath will mist or stain the stone,\\nWhy, then she lives.\\nKENT\\nIs this the promised end\\nEDGAR\\nOr image of that horror?\\nALBANY\\nFall, and cease!\\nKING LEAR\\nThis feather stirs; she lives! if it be so,\\nIt is a chance which does redeem all sorrows\\nThat ever I have felt.\\nKENT\\n[Kneeling] O my good master!\\nKING LEAR\\nPrithee, away.\\nEDGAR\\n'Tis noble Kent, your friend.\\nKING LEAR\\nA plague upon you, murderers, traitors all!\\nI might have saved her; now she's gone for ever!\\nCordelia, Cord\\n\\nA third more opulent than your sisters? Speak.\\nCORDELIA\\nNothing, my lord.\\nKING LEAR\\nNothing!\\nCORDELIA\\nNothing.\\nKING LEAR\\nNothing will come of nothing: speak again.\\nCORDELIA\\nUnhappy that I am, I cannot heave\\nMy heart into my mouth: I love your majesty\\nAccording to my bond; nor more nor less.\\nKING LEAR\\nHow, how, Cordelia! mend your speech a little,\\nLest it may mar your fortunes.\\nCORDELIA\\nGood my lord,\\nYou have begot me, bred me, loved me: I\\nReturn those duties back as are right fit,\\nObey you, love you, and most honour you.\\nWhy have my sisters husbands, if they say\\nThey love you all? Haply, when I shall wed,\\nThat lord whose hand must take my plight shall carry\\nHalf my love with him, half my care and duty:\\nSure, I shall never marry like my sisters,\\nTo love my father all.\\nKING LEAR\\nBut goes thy heart with this?\\nCORDELIA\\nAy, good my lord.\\nKING LEAR\\nSo young, and so untender?\\nCORDELIA\\nSo young, my lord, and true.\\nKING LEAR\\nLet it be so; thy truth, then, be thy dower:\\nFor, by the sacred radia\\ne known\\nThat are to censure them.\\nCORDELIA\\nWe are not the first\\nWho, with best meaning, have incurr'd the worst.\\nFor thee, oppressed king, am I cast down;\\nMyself could else out-frown false fortune's frown.\\nShall we not see these daughters and these sisters?\\nKING LEAR\\nNo, no, no, no! Come, let's away to prison:\\nWe two alone will sing like birds i' the cage:\\nWhen thou dost ask me blessing, I'll kneel down,\\nAnd ask of thee forgiveness: so we'll live,\\nAnd pray, and sing, and tell old tales, and laugh\\nAt gilded butterflies, and hear poor rogues\\nTalk of court news; and we'll talk with them too,\\nWho loses and who wins; who's in, who's out;\\nAnd take upon's the mystery of things,\\nAs if we were God's spies: and we'll wear out,\\nIn a wall'd prison, packs and sects of great ones,\\nThat ebb and flow by the moon.\\nEDMUND\\nTake them away.\\nKING LEAR\\nUpon such sacrifices, my Cordelia,\\nThe gods themselves throw incense. Have I caught thee?\\nHe that parts us shall bring a brand from heaven,\\nAnd fire us hence \\nar's i' the town;\\nWho sometime, in his better tune, remembers\\nWhat we are come about, and by no means\\nWill yield to see his daughter.\\nGentleman\\nWhy, good sir?\\nKENT\\nA sovereign shame so elbows him: his own unkindness,\\nThat stripp'd her from his benediction, turn'd her\\nTo foreign casualties, gave her dear rights\\nTo his dog-hearted daughters, these things sting\\nHis mind so venomously, that burning shame\\nDetains him from Cordelia.\\nGentleman\\nAlack, poor gentleman!\\nKENT\\nOf Albany's and Cornwall's powers you heard not?\\nGentleman\\n'Tis so, they are afoot.\\nKENT\\nWell, sir, I'll bring you to our master Lear,\\nAnd leave you to attend him: some dear cause\\nWill in concealment wrap me up awhile;\\nWhen I am known aright, you shall not grieve\\nLending me this acquaintance. I pray you, go\\nAlong with me.\\nExeunt\\n\\nSCENE IV. The same. A tent.\\nEnter, with drum and colours, CORDELIA, Doctor, and Soldiers\\nCORDELIA\\nAlack, 'tis he: why, he was met even now\\nAs mad as the vex'd sea; singing aloud;\\nCrown'd with rank fu\\n\\n\"}, \"user_prompt\": {\"role\": \"user\", \"content\": \"\\nUser Query:\\nWhat happens to Cordelia?\\n\"}}, \"outputs\": {\"response\": \"Cordelia dies. In the provided context, King Lear is seen holding Cordelia's dead body in his arms. The text describes how he mourns her, exclaiming \\\"Howl, howl, howl, howl!\\\" and expressing his grief over her death.\"}}], \"child_spans\": null, \"span_kind\": \"LLM\"}"}, "_timestamp": 1701802869.7427788, "_runtime": 161.62229585647583, "_step": 1}
|
wandb/run-20231205_135828-pd04j1u0/logs/debug-internal.log
ADDED
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
2023-12-05 13:58:28,118 INFO StreamThr :22152 [internal.py:wandb_internal():86] W&B internal server running at pid: 22152, started at: 2023-12-05 13:58:28.117486
|
2 |
+
2023-12-05 13:58:28,121 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status
|
3 |
+
2023-12-05 13:58:28,130 INFO WriterThread:22152 [datastore.py:open_for_write():85] open: c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\run-pd04j1u0.wandb
|
4 |
+
2023-12-05 13:58:28,132 DEBUG SenderThread:22152 [sender.py:send():380] send: header
|
5 |
+
2023-12-05 13:58:28,195 DEBUG SenderThread:22152 [sender.py:send():380] send: run
|
6 |
+
2023-12-05 13:58:28,972 INFO SenderThread:22152 [dir_watcher.py:__init__():211] watching files in: c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\files
|
7 |
+
2023-12-05 13:58:28,972 INFO SenderThread:22152 [sender.py:_start_run_threads():1124] run started: pd04j1u0 with start time 1701802708.120483
|
8 |
+
2023-12-05 13:58:29,010 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: check_version
|
9 |
+
2023-12-05 13:58:29,011 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: check_version
|
10 |
+
2023-12-05 13:58:29,651 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: run_start
|
11 |
+
2023-12-05 13:58:29,767 DEBUG HandlerThread:22152 [system_info.py:__init__():32] System info init
|
12 |
+
2023-12-05 13:58:29,767 DEBUG HandlerThread:22152 [system_info.py:__init__():47] System info init done
|
13 |
+
2023-12-05 13:58:29,767 INFO HandlerThread:22152 [system_monitor.py:start():194] Starting system monitor
|
14 |
+
2023-12-05 13:58:29,767 INFO SystemMonitor:22152 [system_monitor.py:_start():158] Starting system asset monitoring threads
|
15 |
+
2023-12-05 13:58:29,767 INFO HandlerThread:22152 [system_monitor.py:probe():214] Collecting system info
|
16 |
+
2023-12-05 13:58:29,789 INFO SystemMonitor:22152 [interfaces.py:start():190] Started cpu monitoring
|
17 |
+
2023-12-05 13:58:29,790 INFO SystemMonitor:22152 [interfaces.py:start():190] Started disk monitoring
|
18 |
+
2023-12-05 13:58:29,790 INFO SystemMonitor:22152 [interfaces.py:start():190] Started gpu monitoring
|
19 |
+
2023-12-05 13:58:29,791 INFO SystemMonitor:22152 [interfaces.py:start():190] Started memory monitoring
|
20 |
+
2023-12-05 13:58:29,805 INFO SystemMonitor:22152 [interfaces.py:start():190] Started network monitoring
|
21 |
+
2023-12-05 13:58:29,805 DEBUG HandlerThread:22152 [system_info.py:probe():196] Probing system
|
22 |
+
2023-12-05 13:58:29,807 DEBUG HandlerThread:22152 [system_info.py:_probe_git():181] Probing git
|
23 |
+
2023-12-05 13:58:29,886 DEBUG HandlerThread:22152 [system_info.py:_probe_git():189] Probing git done
|
24 |
+
2023-12-05 13:58:29,886 DEBUG HandlerThread:22152 [system_info.py:probe():244] Probing system done
|
25 |
+
2023-12-05 13:58:29,886 DEBUG HandlerThread:22152 [system_monitor.py:probe():223] {'os': 'Windows-10-10.0.19045-SP0', 'python': '3.11.5', 'heartbeatAt': '2023-12-05T18:58:29.805384', 'startedAt': '2023-12-05T18:58:28.090482', 'docker': None, 'cuda': None, 'args': (), 'state': 'running', 'program': 'Python RAQA Example.ipynb', 'codePathLocal': 'Python RAQA Example.ipynb', 'git': {'remote': 'https://github.com/GarrettG-AI/my-first-raqa.git', 'commit': '6768601ad99a97af33bbd157342d020a39e37f7a'}, 'email': '[email protected]', 'root': 'C:/ai/llmops3/repos/vsrepo/my-first-raqa', 'host': 'DESKTOP-36DNTBA', 'username': 'Bizon', 'executable': 'c:\\Users\\Bizon\\anaconda3\\envs\\my-first-raqa\\python.exe', 'cpu_count': 10, 'cpu_count_logical': 20, 'cpu_freq': {'current': 1200.0, 'min': 0.0, 'max': 3701.0}, 'cpu_freq_per_core': [{'current': 1200.0, 'min': 0.0, 'max': 3701.0}], 'disk': {'/': {'total': 1862.4150085449219, 'used': 1205.1566047668457}}, 'gpu': 'Quadro RTX 8000', 'gpu_count': 1, 'gpu_devices': [{'name': 'Quadro RTX 8000', 'memory_total': 48318382080}], 'memory': {'total': 191.6897430419922}}
|
26 |
+
2023-12-05 13:58:29,887 INFO HandlerThread:22152 [system_monitor.py:probe():224] Finished collecting system info
|
27 |
+
2023-12-05 13:58:29,887 INFO HandlerThread:22152 [system_monitor.py:probe():227] Publishing system info
|
28 |
+
2023-12-05 13:58:29,887 DEBUG HandlerThread:22152 [system_info.py:_save_pip():52] Saving list of pip packages installed into the current environment
|
29 |
+
2023-12-05 13:58:29,888 DEBUG HandlerThread:22152 [system_info.py:_save_pip():68] Saving pip packages done
|
30 |
+
2023-12-05 13:58:29,888 DEBUG HandlerThread:22152 [system_info.py:_save_conda():75] Saving list of conda packages installed into the current environment
|
31 |
+
2023-12-05 13:58:29,981 INFO Thread-16 :22152 [dir_watcher.py:_on_file_created():271] file/dir created: c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\files\requirements.txt
|
32 |
+
2023-12-05 13:58:29,982 INFO Thread-16 :22152 [dir_watcher.py:_on_file_created():271] file/dir created: c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\files\conda-environment.yaml
|
33 |
+
2023-12-05 13:58:38,431 DEBUG HandlerThread:22152 [system_info.py:_save_conda():87] Saving conda packages done
|
34 |
+
2023-12-05 13:58:38,433 INFO HandlerThread:22152 [system_monitor.py:probe():229] Finished publishing system info
|
35 |
+
2023-12-05 13:58:38,439 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
36 |
+
2023-12-05 13:58:38,439 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: keepalive
|
37 |
+
2023-12-05 13:58:38,440 DEBUG SenderThread:22152 [sender.py:send():380] send: files
|
38 |
+
2023-12-05 13:58:38,440 INFO SenderThread:22152 [sender.py:_save_file():1380] saving file wandb-metadata.json with policy now
|
39 |
+
2023-12-05 13:58:38,462 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
40 |
+
2023-12-05 13:58:38,462 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
41 |
+
2023-12-05 13:58:38,465 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
42 |
+
2023-12-05 13:58:38,467 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: pause
|
43 |
+
2023-12-05 13:58:38,467 INFO HandlerThread:22152 [handler.py:handle_request_pause():705] stopping system metrics thread
|
44 |
+
2023-12-05 13:58:38,467 INFO HandlerThread:22152 [system_monitor.py:finish():203] Stopping system monitor
|
45 |
+
2023-12-05 13:58:38,467 DEBUG SystemMonitor:22152 [system_monitor.py:_start():172] Starting system metrics aggregation loop
|
46 |
+
2023-12-05 13:58:38,468 DEBUG SystemMonitor:22152 [system_monitor.py:_start():179] Finished system metrics aggregation loop
|
47 |
+
2023-12-05 13:58:38,468 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined cpu monitor
|
48 |
+
2023-12-05 13:58:38,490 DEBUG SystemMonitor:22152 [system_monitor.py:_start():183] Publishing last batch of metrics
|
49 |
+
2023-12-05 13:58:38,491 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined disk monitor
|
50 |
+
2023-12-05 13:58:38,598 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined gpu monitor
|
51 |
+
2023-12-05 13:58:38,599 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined memory monitor
|
52 |
+
2023-12-05 13:58:38,599 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined network monitor
|
53 |
+
2023-12-05 13:58:39,082 INFO Thread-16 :22152 [dir_watcher.py:_on_file_modified():288] file/dir modified: c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\files\conda-environment.yaml
|
54 |
+
2023-12-05 13:58:39,083 INFO Thread-16 :22152 [dir_watcher.py:_on_file_created():271] file/dir created: c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\files\wandb-metadata.json
|
55 |
+
2023-12-05 13:58:39,128 DEBUG SenderThread:22152 [sender.py:send():380] send: telemetry
|
56 |
+
2023-12-05 13:58:39,128 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
57 |
+
2023-12-05 13:58:39,128 DEBUG SenderThread:22152 [sender.py:send():380] send: stats
|
58 |
+
2023-12-05 13:58:39,431 INFO wandb-upload_0:22152 [upload_job.py:push():131] Uploaded file C:\Users\Bizon\AppData\Local\Temp\tmpyfhf2asowandb\5h5xbe6r-wandb-metadata.json
|
59 |
+
2023-12-05 13:58:44,174 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
60 |
+
2023-12-05 13:58:49,228 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
61 |
+
2023-12-05 13:58:53,462 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
62 |
+
2023-12-05 13:58:53,463 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
63 |
+
2023-12-05 13:58:53,476 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
64 |
+
2023-12-05 13:58:54,565 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
65 |
+
2023-12-05 13:58:59,621 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
66 |
+
2023-12-05 13:59:00,291 INFO Thread-16 :22152 [dir_watcher.py:_on_file_modified():288] file/dir modified: c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\files\config.yaml
|
67 |
+
2023-12-05 13:59:04,748 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
68 |
+
2023-12-05 13:59:08,471 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
69 |
+
2023-12-05 13:59:08,472 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
70 |
+
2023-12-05 13:59:08,486 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
71 |
+
2023-12-05 13:59:10,614 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
72 |
+
2023-12-05 13:59:15,651 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
73 |
+
2023-12-05 13:59:20,694 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
74 |
+
2023-12-05 13:59:23,475 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
75 |
+
2023-12-05 13:59:23,475 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
76 |
+
2023-12-05 13:59:23,476 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
77 |
+
2023-12-05 13:59:26,623 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
78 |
+
2023-12-05 13:59:31,691 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
79 |
+
2023-12-05 13:59:36,756 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
80 |
+
2023-12-05 13:59:38,482 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
81 |
+
2023-12-05 13:59:38,498 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
82 |
+
2023-12-05 13:59:38,499 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
83 |
+
2023-12-05 13:59:42,674 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
84 |
+
2023-12-05 13:59:47,707 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
85 |
+
2023-12-05 13:59:50,721 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: resume
|
86 |
+
2023-12-05 13:59:50,722 INFO HandlerThread:22152 [handler.py:handle_request_resume():696] starting system metrics thread
|
87 |
+
2023-12-05 13:59:50,722 INFO HandlerThread:22152 [system_monitor.py:start():194] Starting system monitor
|
88 |
+
2023-12-05 13:59:50,722 INFO SystemMonitor:22152 [system_monitor.py:_start():158] Starting system asset monitoring threads
|
89 |
+
2023-12-05 13:59:50,733 INFO SystemMonitor:22152 [interfaces.py:start():190] Started cpu monitoring
|
90 |
+
2023-12-05 13:59:50,733 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: pause
|
91 |
+
2023-12-05 13:59:50,733 INFO HandlerThread:22152 [handler.py:handle_request_pause():705] stopping system metrics thread
|
92 |
+
2023-12-05 13:59:50,734 INFO HandlerThread:22152 [system_monitor.py:finish():203] Stopping system monitor
|
93 |
+
2023-12-05 13:59:50,734 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined cpu monitor
|
94 |
+
2023-12-05 13:59:50,734 INFO SystemMonitor:22152 [interfaces.py:start():190] Started disk monitoring
|
95 |
+
2023-12-05 13:59:50,734 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined disk monitor
|
96 |
+
2023-12-05 13:59:50,735 DEBUG SystemMonitor:22152 [system_monitor.py:_start():172] Starting system metrics aggregation loop
|
97 |
+
2023-12-05 13:59:50,735 DEBUG SystemMonitor:22152 [system_monitor.py:_start():179] Finished system metrics aggregation loop
|
98 |
+
2023-12-05 13:59:50,735 DEBUG SystemMonitor:22152 [system_monitor.py:_start():183] Publishing last batch of metrics
|
99 |
+
2023-12-05 13:59:50,736 DEBUG SenderThread:22152 [sender.py:send():380] send: stats
|
100 |
+
2023-12-05 13:59:52,739 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
101 |
+
2023-12-05 13:59:53,495 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
102 |
+
2023-12-05 13:59:53,496 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
103 |
+
2023-12-05 13:59:53,496 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
104 |
+
2023-12-05 13:59:58,644 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
105 |
+
2023-12-05 14:00:01,986 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: resume
|
106 |
+
2023-12-05 14:00:01,986 INFO HandlerThread:22152 [handler.py:handle_request_resume():696] starting system metrics thread
|
107 |
+
2023-12-05 14:00:01,986 INFO HandlerThread:22152 [system_monitor.py:start():194] Starting system monitor
|
108 |
+
2023-12-05 14:00:01,986 INFO SystemMonitor:22152 [system_monitor.py:_start():158] Starting system asset monitoring threads
|
109 |
+
2023-12-05 14:00:01,987 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: pause
|
110 |
+
2023-12-05 14:00:01,999 INFO HandlerThread:22152 [handler.py:handle_request_pause():705] stopping system metrics thread
|
111 |
+
2023-12-05 14:00:01,999 INFO SystemMonitor:22152 [interfaces.py:start():190] Started cpu monitoring
|
112 |
+
2023-12-05 14:00:01,999 INFO HandlerThread:22152 [system_monitor.py:finish():203] Stopping system monitor
|
113 |
+
2023-12-05 14:00:02,000 INFO SystemMonitor:22152 [interfaces.py:start():190] Started disk monitoring
|
114 |
+
2023-12-05 14:00:02,000 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined cpu monitor
|
115 |
+
2023-12-05 14:00:02,000 DEBUG SystemMonitor:22152 [system_monitor.py:_start():172] Starting system metrics aggregation loop
|
116 |
+
2023-12-05 14:00:02,001 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined disk monitor
|
117 |
+
2023-12-05 14:00:02,001 DEBUG SystemMonitor:22152 [system_monitor.py:_start():179] Finished system metrics aggregation loop
|
118 |
+
2023-12-05 14:00:02,001 DEBUG SystemMonitor:22152 [system_monitor.py:_start():183] Publishing last batch of metrics
|
119 |
+
2023-12-05 14:00:02,002 DEBUG SenderThread:22152 [sender.py:send():380] send: stats
|
120 |
+
2023-12-05 14:00:04,022 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
121 |
+
2023-12-05 14:00:06,241 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: resume
|
122 |
+
2023-12-05 14:00:06,241 INFO HandlerThread:22152 [handler.py:handle_request_resume():696] starting system metrics thread
|
123 |
+
2023-12-05 14:00:06,241 INFO HandlerThread:22152 [system_monitor.py:start():194] Starting system monitor
|
124 |
+
2023-12-05 14:00:06,242 INFO SystemMonitor:22152 [system_monitor.py:_start():158] Starting system asset monitoring threads
|
125 |
+
2023-12-05 14:00:06,254 INFO SystemMonitor:22152 [interfaces.py:start():190] Started cpu monitoring
|
126 |
+
2023-12-05 14:00:06,255 INFO SystemMonitor:22152 [interfaces.py:start():190] Started disk monitoring
|
127 |
+
2023-12-05 14:00:06,256 INFO SystemMonitor:22152 [interfaces.py:start():190] Started gpu monitoring
|
128 |
+
2023-12-05 14:00:06,257 INFO SystemMonitor:22152 [interfaces.py:start():190] Started memory monitoring
|
129 |
+
2023-12-05 14:00:06,266 INFO SystemMonitor:22152 [interfaces.py:start():190] Started network monitoring
|
130 |
+
2023-12-05 14:00:08,308 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: partial_history
|
131 |
+
2023-12-05 14:00:08,310 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: pause
|
132 |
+
2023-12-05 14:00:08,312 DEBUG SenderThread:22152 [sender.py:send():380] send: history
|
133 |
+
2023-12-05 14:00:08,312 INFO HandlerThread:22152 [handler.py:handle_request_pause():705] stopping system metrics thread
|
134 |
+
2023-12-05 14:00:08,312 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: summary_record
|
135 |
+
2023-12-05 14:00:08,312 INFO HandlerThread:22152 [system_monitor.py:finish():203] Stopping system monitor
|
136 |
+
2023-12-05 14:00:08,312 DEBUG SystemMonitor:22152 [system_monitor.py:_start():172] Starting system metrics aggregation loop
|
137 |
+
2023-12-05 14:00:08,329 DEBUG SystemMonitor:22152 [system_monitor.py:_start():179] Finished system metrics aggregation loop
|
138 |
+
2023-12-05 14:00:08,330 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined cpu monitor
|
139 |
+
2023-12-05 14:00:08,330 DEBUG SystemMonitor:22152 [system_monitor.py:_start():183] Publishing last batch of metrics
|
140 |
+
2023-12-05 14:00:08,331 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined disk monitor
|
141 |
+
2023-12-05 14:00:08,332 INFO SenderThread:22152 [sender.py:_save_file():1380] saving file wandb-summary.json with policy end
|
142 |
+
2023-12-05 14:00:08,427 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined gpu monitor
|
143 |
+
2023-12-05 14:00:08,427 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined memory monitor
|
144 |
+
2023-12-05 14:00:08,427 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined network monitor
|
145 |
+
2023-12-05 14:00:08,428 DEBUG SenderThread:22152 [sender.py:send():380] send: stats
|
146 |
+
2023-12-05 14:00:08,513 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
147 |
+
2023-12-05 14:00:08,514 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
148 |
+
2023-12-05 14:00:08,514 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
149 |
+
2023-12-05 14:00:09,099 INFO Thread-16 :22152 [dir_watcher.py:_on_file_created():271] file/dir created: c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\files\wandb-summary.json
|
150 |
+
2023-12-05 14:00:09,619 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
151 |
+
2023-12-05 14:00:14,665 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
152 |
+
2023-12-05 14:00:19,724 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
153 |
+
2023-12-05 14:00:23,524 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
154 |
+
2023-12-05 14:00:23,525 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
155 |
+
2023-12-05 14:00:23,525 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
156 |
+
2023-12-05 14:00:25,135 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
157 |
+
2023-12-05 14:00:30,181 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
158 |
+
2023-12-05 14:00:35,226 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
159 |
+
2023-12-05 14:00:38,538 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
160 |
+
2023-12-05 14:00:38,539 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
161 |
+
2023-12-05 14:00:38,540 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
162 |
+
2023-12-05 14:00:40,723 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
163 |
+
2023-12-05 14:00:45,779 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
164 |
+
2023-12-05 14:00:50,839 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
165 |
+
2023-12-05 14:00:53,539 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
166 |
+
2023-12-05 14:00:53,540 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
167 |
+
2023-12-05 14:00:53,555 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
168 |
+
2023-12-05 14:00:56,690 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
169 |
+
2023-12-05 14:01:01,733 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
170 |
+
2023-12-05 14:01:06,786 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
171 |
+
2023-12-05 14:01:07,315 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: resume
|
172 |
+
2023-12-05 14:01:07,315 INFO HandlerThread:22152 [handler.py:handle_request_resume():696] starting system metrics thread
|
173 |
+
2023-12-05 14:01:07,315 INFO HandlerThread:22152 [system_monitor.py:start():194] Starting system monitor
|
174 |
+
2023-12-05 14:01:07,315 INFO SystemMonitor:22152 [system_monitor.py:_start():158] Starting system asset monitoring threads
|
175 |
+
2023-12-05 14:01:07,324 INFO SystemMonitor:22152 [interfaces.py:start():190] Started cpu monitoring
|
176 |
+
2023-12-05 14:01:07,325 INFO SystemMonitor:22152 [interfaces.py:start():190] Started disk monitoring
|
177 |
+
2023-12-05 14:01:07,325 INFO SystemMonitor:22152 [interfaces.py:start():190] Started gpu monitoring
|
178 |
+
2023-12-05 14:01:07,326 INFO SystemMonitor:22152 [interfaces.py:start():190] Started memory monitoring
|
179 |
+
2023-12-05 14:01:07,334 INFO SystemMonitor:22152 [interfaces.py:start():190] Started network monitoring
|
180 |
+
2023-12-05 14:01:08,555 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
181 |
+
2023-12-05 14:01:08,556 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
182 |
+
2023-12-05 14:01:08,570 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
183 |
+
2023-12-05 14:01:09,743 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: partial_history
|
184 |
+
2023-12-05 14:01:09,745 DEBUG SenderThread:22152 [sender.py:send():380] send: history
|
185 |
+
2023-12-05 14:01:09,745 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: summary_record
|
186 |
+
2023-12-05 14:01:09,748 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: pause
|
187 |
+
2023-12-05 14:01:09,749 INFO HandlerThread:22152 [handler.py:handle_request_pause():705] stopping system metrics thread
|
188 |
+
2023-12-05 14:01:09,750 INFO HandlerThread:22152 [system_monitor.py:finish():203] Stopping system monitor
|
189 |
+
2023-12-05 14:01:09,750 DEBUG SystemMonitor:22152 [system_monitor.py:_start():172] Starting system metrics aggregation loop
|
190 |
+
2023-12-05 14:01:09,768 DEBUG SystemMonitor:22152 [system_monitor.py:_start():179] Finished system metrics aggregation loop
|
191 |
+
2023-12-05 14:01:09,769 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined cpu monitor
|
192 |
+
2023-12-05 14:01:09,769 DEBUG SystemMonitor:22152 [system_monitor.py:_start():183] Publishing last batch of metrics
|
193 |
+
2023-12-05 14:01:09,769 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined disk monitor
|
194 |
+
2023-12-05 14:01:09,770 INFO SenderThread:22152 [sender.py:_save_file():1380] saving file wandb-summary.json with policy end
|
195 |
+
2023-12-05 14:01:09,774 INFO Thread-16 :22152 [dir_watcher.py:_on_file_modified():288] file/dir modified: c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\files\wandb-summary.json
|
196 |
+
2023-12-05 14:01:09,884 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined gpu monitor
|
197 |
+
2023-12-05 14:01:09,885 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined memory monitor
|
198 |
+
2023-12-05 14:01:09,885 INFO HandlerThread:22152 [interfaces.py:finish():202] Joined network monitor
|
199 |
+
2023-12-05 14:01:09,886 DEBUG SenderThread:22152 [sender.py:send():380] send: stats
|
200 |
+
2023-12-05 14:01:11,905 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
201 |
+
2023-12-05 14:01:16,959 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
202 |
+
2023-12-05 14:01:21,995 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
203 |
+
2023-12-05 14:01:23,560 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
204 |
+
2023-12-05 14:01:23,561 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
205 |
+
2023-12-05 14:01:23,576 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
206 |
+
2023-12-05 14:01:27,735 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
207 |
+
2023-12-05 14:01:32,783 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
208 |
+
2023-12-05 14:01:37,841 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
209 |
+
2023-12-05 14:01:38,566 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
210 |
+
2023-12-05 14:01:38,567 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
211 |
+
2023-12-05 14:01:38,582 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
212 |
+
2023-12-05 14:01:43,732 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
213 |
+
2023-12-05 14:01:48,790 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
214 |
+
2023-12-05 14:01:53,576 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
215 |
+
2023-12-05 14:01:53,577 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
216 |
+
2023-12-05 14:01:53,592 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
217 |
+
2023-12-05 14:01:54,744 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
218 |
+
2023-12-05 14:01:59,791 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
219 |
+
2023-12-05 14:02:04,844 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
220 |
+
2023-12-05 14:02:08,571 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
221 |
+
2023-12-05 14:02:08,572 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
222 |
+
2023-12-05 14:02:08,602 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
223 |
+
2023-12-05 14:02:10,754 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
224 |
+
2023-12-05 14:02:15,815 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
225 |
+
2023-12-05 14:02:20,862 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
226 |
+
2023-12-05 14:02:23,581 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
227 |
+
2023-12-05 14:02:23,582 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
228 |
+
2023-12-05 14:02:23,613 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
229 |
+
2023-12-05 14:02:26,684 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
230 |
+
2023-12-05 14:02:31,734 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
231 |
+
2023-12-05 14:02:36,780 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
232 |
+
2023-12-05 14:02:38,596 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
233 |
+
2023-12-05 14:02:38,597 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
234 |
+
2023-12-05 14:02:38,628 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
235 |
+
2023-12-05 14:02:42,714 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
236 |
+
2023-12-05 14:02:47,754 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
237 |
+
2023-12-05 14:02:52,816 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
238 |
+
2023-12-05 14:02:53,601 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
239 |
+
2023-12-05 14:02:53,601 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
240 |
+
2023-12-05 14:02:53,633 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
241 |
+
2023-12-05 14:02:58,758 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
242 |
+
2023-12-05 14:03:03,816 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
243 |
+
2023-12-05 14:03:08,604 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: stop_status
|
244 |
+
2023-12-05 14:03:08,605 DEBUG SenderThread:22152 [sender.py:send_request():407] send_request: stop_status
|
245 |
+
2023-12-05 14:03:08,635 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: internal_messages
|
246 |
+
2023-12-05 14:03:09,727 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
247 |
+
2023-12-05 14:03:14,785 DEBUG HandlerThread:22152 [handler.py:handle_request():146] handle_request: status_report
|
wandb/run-20231205_135828-pd04j1u0/logs/debug.log
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
2023-12-05 13:58:28,097 INFO MainThread:8972 [wandb_setup.py:_flush():76] Current SDK version is 0.16.0
|
2 |
+
2023-12-05 13:58:28,097 INFO MainThread:8972 [wandb_setup.py:_flush():76] Configure stats pid to 8972
|
3 |
+
2023-12-05 13:58:28,097 INFO MainThread:8972 [wandb_setup.py:_flush():76] Loading settings from C:\Users\Bizon\.config\wandb\settings
|
4 |
+
2023-12-05 13:58:28,097 INFO MainThread:8972 [wandb_setup.py:_flush():76] Loading settings from c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\settings
|
5 |
+
2023-12-05 13:58:28,097 INFO MainThread:8972 [wandb_setup.py:_flush():76] Loading settings from environment variables: {'api_key': '***REDACTED***', 'notebook_name': 'Python RAQA Example.ipynb'}
|
6 |
+
2023-12-05 13:58:28,097 INFO MainThread:8972 [wandb_setup.py:_flush():76] Applying setup settings: {'_disable_service': False}
|
7 |
+
2023-12-05 13:58:28,108 INFO MainThread:8972 [wandb_setup.py:_flush():76] Inferring run settings from compute environment: {'program': '<python with no main file>'}
|
8 |
+
2023-12-05 13:58:28,109 INFO MainThread:8972 [wandb_init.py:_log_setup():524] Logging user logs to c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\logs\debug.log
|
9 |
+
2023-12-05 13:58:28,109 INFO MainThread:8972 [wandb_init.py:_log_setup():525] Logging internal logs to c:\ai\llmops3\repos\vsrepo\my-first-raqa\wandb\run-20231205_135828-pd04j1u0\logs\debug-internal.log
|
10 |
+
2023-12-05 13:58:28,109 INFO MainThread:8972 [wandb_init.py:_jupyter_setup():470] configuring jupyter hooks <wandb.sdk.wandb_init._WandbInit object at 0x000001C66E1A6FD0>
|
11 |
+
2023-12-05 13:58:28,110 INFO MainThread:8972 [wandb_init.py:init():564] calling init triggers
|
12 |
+
2023-12-05 13:58:28,110 INFO MainThread:8972 [wandb_init.py:init():571] wandb.init called with sweep_config: {}
|
13 |
+
config: {}
|
14 |
+
2023-12-05 13:58:28,110 INFO MainThread:8972 [wandb_init.py:init():614] starting backend
|
15 |
+
2023-12-05 13:58:28,110 INFO MainThread:8972 [wandb_init.py:init():618] setting up manager
|
16 |
+
2023-12-05 13:58:28,115 INFO MainThread:8972 [backend.py:_multiprocessing_setup():105] multiprocessing start_methods=spawn, using: spawn
|
17 |
+
2023-12-05 13:58:28,119 INFO MainThread:8972 [wandb_init.py:init():624] backend started and connected
|
18 |
+
2023-12-05 13:58:28,128 INFO MainThread:8972 [wandb_run.py:_label_probe_notebook():1294] probe notebook
|
19 |
+
2023-12-05 13:58:28,129 INFO MainThread:8972 [wandb_init.py:init():716] updated telemetry
|
20 |
+
2023-12-05 13:58:28,193 INFO MainThread:8972 [wandb_init.py:init():749] communicating run to backend with 90.0 second timeout
|
21 |
+
2023-12-05 13:58:29,009 INFO MainThread:8972 [wandb_run.py:_on_init():2254] communicating current version
|
22 |
+
2023-12-05 13:58:29,634 INFO MainThread:8972 [wandb_run.py:_on_init():2263] got version response upgrade_message: "wandb version 0.16.1 is available! To upgrade, please run:\n $ pip install wandb --upgrade"
|
23 |
+
|
24 |
+
2023-12-05 13:58:29,635 INFO MainThread:8972 [wandb_init.py:init():800] starting run threads in backend
|
25 |
+
2023-12-05 13:58:38,462 INFO MainThread:8972 [wandb_run.py:_console_start():2233] atexit reg
|
26 |
+
2023-12-05 13:58:38,463 INFO MainThread:8972 [wandb_run.py:_redirect():2088] redirect: wrap_raw
|
27 |
+
2023-12-05 13:58:38,463 INFO MainThread:8972 [wandb_run.py:_redirect():2153] Wrapping output streams.
|
28 |
+
2023-12-05 13:58:38,463 INFO MainThread:8972 [wandb_run.py:_redirect():2178] Redirects installed.
|
29 |
+
2023-12-05 13:58:38,463 INFO MainThread:8972 [wandb_init.py:init():841] run started, returning control to user process
|
30 |
+
2023-12-05 13:58:38,467 INFO MainThread:8972 [jupyter.py:save_ipynb():373] not saving jupyter notebook
|
31 |
+
2023-12-05 13:58:38,467 INFO MainThread:8972 [wandb_init.py:_pause_backend():435] pausing backend
|
32 |
+
2023-12-05 13:59:50,720 INFO MainThread:8972 [wandb_init.py:_resume_backend():440] resuming backend
|
33 |
+
2023-12-05 13:59:50,724 INFO MainThread:8972 [jupyter.py:save_ipynb():373] not saving jupyter notebook
|
34 |
+
2023-12-05 13:59:50,724 INFO MainThread:8972 [wandb_init.py:_pause_backend():435] pausing backend
|
35 |
+
2023-12-05 14:00:01,984 INFO MainThread:8972 [wandb_init.py:_resume_backend():440] resuming backend
|
36 |
+
2023-12-05 14:00:01,986 INFO MainThread:8972 [jupyter.py:save_ipynb():373] not saving jupyter notebook
|
37 |
+
2023-12-05 14:00:01,987 INFO MainThread:8972 [wandb_init.py:_pause_backend():435] pausing backend
|
38 |
+
2023-12-05 14:00:06,240 INFO MainThread:8972 [wandb_init.py:_resume_backend():440] resuming backend
|
39 |
+
2023-12-05 14:00:08,309 INFO MainThread:8972 [jupyter.py:save_ipynb():373] not saving jupyter notebook
|
40 |
+
2023-12-05 14:00:08,310 INFO MainThread:8972 [wandb_init.py:_pause_backend():435] pausing backend
|
41 |
+
2023-12-05 14:01:07,314 INFO MainThread:8972 [wandb_init.py:_resume_backend():440] resuming backend
|
42 |
+
2023-12-05 14:01:09,745 INFO MainThread:8972 [jupyter.py:save_ipynb():373] not saving jupyter notebook
|
43 |
+
2023-12-05 14:01:09,745 INFO MainThread:8972 [wandb_init.py:_pause_backend():435] pausing backend
|
wandb/run-20231205_135828-pd04j1u0/run-pd04j1u0.wandb
ADDED
Binary file (8.18 kB). View file
|
|