Skip to content

Commit e16b542

Browse files
authored
11850 Lab 4 RAG Update Finance Lab (#588)
* My changes1 * Json challenge * New Json handson * Complete * Business Requirements updates * Manifest * Feedback updates * Editing-out name * Updating Dom's name * updated screenshots for Dom * New Manifest for paramount * Removed est. time in Intro * Adding Feature PM's * updated introduction.md * Added par file (zip file of code) * adding videos * #4195 Created new folders for Retail and Healthcare * WMS: 11850 Updating lab 1 task 3 markdown * 11850: Finance lab 4 update * Lab 4 RAG Updated
1 parent 63684c5 commit e16b542

File tree

686 files changed

+8331
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

686 files changed

+8331
-0
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Code with AI Vector Search step-by-step
2+
3+
## Introduction
4+
5+
In this coding challenge, you’ll focus on **AI Vector Search**. Your mission is to implement a key update to change the way similarities are calculated, improving the accuracy of predictions.
6+
7+
At SeerEquites, the data science team has been using Cosine similarity to assess similarities between customer profiles and predict loan risks. While effective in some contexts, the team recently realized that Cosine similarity wasn’t capturing the full picture of their customers financial profiles.
8+
9+
**Why switch to Euclidean distance?**
10+
11+
Cosine similarity is great when you care about the pattern or direction of someone’s data — not how big or small the numbers are. But in finance, the actual size of the numbers often matters a lot.
12+
13+
Let’s say you’re comparing two customers based on their debt, income, and credit usage. These numbers matter significantly, and big differences can indicate very different levels of risk.
14+
15+
Here’s an example:
16+
17+
* Both customers have the same debt-to-income ratio of 2:1.
18+
19+
* But one earns $20,000 a year, while the other earns $200,000.
20+
21+
Cosine similarity would say these customers are quite similar, because their ratios follow the same pattern. But that’s misleading — the person earning $20,000 is much riskier.
22+
23+
That’s where Euclidean distance comes in. Unlike Cosine similarity, Euclidean distance looks at the actual difference in the numbers. In this case, it would correctly flag that these customers are not similar in a meaningful way, since the scale of their incomes is vastly different.
24+
25+
In finance, where decisions are often made based on key figures like income, debt, and credit usage, Euclidean distance is often a better tool. It takes the size of the numbers into account, which is crucial for making accurate risk predictions.
26+
27+
In this lab, you’ll update the code to switch the similarity measure from Cosine to Euclidean. This change will improve the system’s ability to assess loan risks more accurately, providing more reliable insights for decision-making.
28+
29+
This is your opportunity to sharpen your skills, explore the power of AI-driven search, and make a meaningful impact on a application. Let’s get started!
30+
31+
Estimated Time: 30 minutes
32+
33+
### Objectives
34+
35+
In this lab, you will:
36+
* Enhance your understanding of AI Vector Search by applying it to a developer coding challenge.
37+
* Gain hands-on experience with integrating AI Vector Search and refining application features to meet specific development requirements.
38+
39+
### Prerequisites
40+
41+
This lab assumes you have:
42+
* An Oracle Cloud account
43+
* Successfully completed Lab 1: Run the Demo
44+
* Successfully completed Lab 3: Connect to Development Environment
45+
46+
## Task 1: Challenge Requirements
47+
48+
Based on the data scientists' evaluation, the company has decided to switch from using Cosine similarity to Euclidean distance. This change aims to enhance the system’s ability to assess loan risks more accurately, ultimately providing more reliable insights to support better decision-making.
49+
50+
Follow the prompts below to update the code based on the new company standard.
51+
52+
## Task 2: Launch the Application
53+
54+
1. Select the **Launcher** tab and open the **terminal**
55+
56+
![Open Terminal](./images/open-terminal.png " ")
57+
58+
2. Copy the ./run.sh command and paste it into the terminal.
59+
60+
````bash
61+
$<copy>
62+
./run.sh
63+
</copy>
64+
````
65+
66+
3. Click the URL displayed in the terminal to launch the SeerEquities Loan Management application.
67+
68+
![Click the URL](./images/click-url.png " ")
69+
70+
4. Enter in a username and click **Login**.
71+
72+
![Login](./images/login.png " ")
73+
74+
## Task 3: View the current AI chat bot return variables using Cosine
75+
76+
1. On the Dashboard page, from the pending review list, select the Customer ID for **James Smith**.
77+
78+
![Select James Smith](./images/james-smith.png " ")
79+
80+
2. This will display the customers loan application details. In approximately 15 seconds, the AI generated loan recommendations will be displayed.
81+
82+
![James Smith AI generated recommendations](./images/ai-exercise.png " ")
83+
84+
3. Ask the following question to the AI Chat bot.
85+
86+
````text
87+
<copy>
88+
What about a 4th loan?
89+
</copy>
90+
````
91+
92+
Note how the return variables are shown:
93+
94+
![AI Loan chatbot](./images/cosine-ai.png " ")
95+
96+
## Task 4: Modify the Customers.py File
97+
98+
1. Click **Pages**.
99+
100+
![Click Pages](./images/click-pages.png " ")
101+
102+
2. Select the **Customers.py** file.
103+
104+
![Click Customers.py](./images/customers-py.png " ")
105+
106+
3. Update the Customers.py file to make the necessary changes in the code at lines 845 and 846
107+
108+
![Update Customers.py](./images/euclidean-2.png " ")
109+
110+
4. Save the Customers.py file.
111+
112+
![Save Customers.py](./images/save-customers-py.png " ")
113+
114+
## Task 5: View results in the Loan application
115+
116+
1. On the Dashboard page, from the pending review list, select the Customer ID for **James Smith**.
117+
118+
![Select James Smith](./images/james-smith.png " ")
119+
120+
2. This will display the customers loan application details. In approximately 15 seconds, the AI generated loan recommendations will be displayed.
121+
122+
![James Smith AI generated recommendations](./images/ai-exercise.png " ")
123+
124+
3. Ask the following question to the AI Chat bot.
125+
126+
````text
127+
<copy>
128+
What about a 4th loan?
129+
</copy>
130+
````
131+
4. View the new prompt return from the AI chat bot
132+
133+
![AI Chatbot](./images/euclidean-2-ai.png " ")
134+
135+
136+
137+
**Congratulations, you have successfully completed the AI Vector Search Challenge!** By switching to Euclidean distance, SeerEquites ensures more precise loan risk evaluations and improves the overall effectiveness of their loan management system.
138+
139+
## Learn More
140+
141+
* [Oracle Database 23ai Documentation](https://docs.oracle.com/en/database/oracle/oracle-database/23/)
142+
143+
## Acknowledgements
144+
* **Authors** - Linda Foinding, Francis Regalado
145+
* **Contributors** - Kamryn Vinson, Eddie Ambler, Kevin Lazarz
146+
* **Last Updated By/Date** - Kamryn Vinson, April 2025
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/* NOTE: Files cannot contain empty lines (line breaks) */
2+
/* Specify the base URL that you copied from your files in OCI Object Storage in the define base_URL line below*/
3+
/* change idthydc0kinr to your real namespace. The name is case-sensitive. */
4+
/* change ADWCLab to your real bucket name. The name is case-sensitive. */
5+
/* change us-phoenix-1 to your real region name. The name is case-sensitive. */
6+
/* you can find these values on the OCI Console .. Storage .. Object Storage screen */
7+
set define on
8+
define base_URL='https://objectstorage.us-phoenix-1.oraclecloud.com/n/idthydc0kinr/b/ADWCLab/o'
9+
/* copy Channels table */
10+
begin
11+
dbms_cloud.copy_data(
12+
table_name =>'CHANNELS',
13+
credential_name =>'OBJ_STORE_CRED',
14+
file_uri_list =>'&base_URL/chan_v3.dat',
15+
format => json_object('ignoremissingcolumns' value 'true', 'removequotes' value 'true')
16+
);
17+
end;
18+
/
19+
/* copy Countries table */
20+
begin
21+
dbms_cloud.copy_data(
22+
table_name =>'COUNTRIES',
23+
credential_name =>'OBJ_STORE_CRED',
24+
file_uri_list =>'&base_URL/coun_v3.dat',
25+
format => json_object('ignoremissingcolumns' value 'true', 'removequotes' value 'true')
26+
);
27+
end;
28+
/
29+
/* Copy customers */
30+
begin
31+
dbms_cloud.copy_data(
32+
table_name =>'CUSTOMERS',
33+
credential_name =>'OBJ_STORE_CRED',
34+
file_uri_list =>'&base_URL/cust1v3.dat',
35+
format => json_object('ignoremissingcolumns' value 'true', 'removequotes' value 'true', 'dateformat' value 'YYYY-MM-DD-HH24-MI-SS')
36+
);
37+
end;
38+
/
39+
begin
40+
dbms_cloud.copy_data(
41+
table_name =>'SUPPLEMENTARY_DEMOGRAPHICS',
42+
credential_name =>'OBJ_STORE_CRED',
43+
file_uri_list =>'&base_URL/dem1v3.dat',
44+
format => json_object('ignoremissingcolumns' value 'true', 'removequotes' value 'true')
45+
);
46+
end;
47+
/
48+
begin
49+
dbms_cloud.copy_data(
50+
table_name =>'SALES',
51+
credential_name =>'OBJ_STORE_CRED',
52+
file_uri_list =>'&base_URL/dmsal_v3.dat',
53+
format => json_object('ignoremissingcolumns' value 'true', 'removequotes' value 'true', 'dateformat' value 'YYYY-MM-DD')
54+
);
55+
end;
56+
/
57+
begin
58+
dbms_cloud.copy_data(
59+
table_name =>'PRODUCTS',
60+
credential_name =>'OBJ_STORE_CRED',
61+
file_uri_list =>'&base_URL/prod1v3.dat',
62+
format => json_object('delimiter' value '|', 'quote' value '^', 'ignoremissingcolumns' value 'true', 'dateformat' value 'YYYY-MM-DD-HH24-MI-SS', 'blankasnull' value 'true')
63+
);
64+
end;
65+
/
66+
begin
67+
dbms_cloud.copy_data(
68+
table_name =>'PROMOTIONS',
69+
credential_name =>'OBJ_STORE_CRED',
70+
file_uri_list =>'&base_URL/prom1v3.dat',
71+
format => json_object('ignoremissingcolumns' value 'true', 'removequotes' value 'true', 'dateformat' value 'YYYY-MM-DD-HH24-MI-SS', 'blankasnull' value 'true')
72+
);
73+
end;
74+
/
75+
begin
76+
dbms_cloud.copy_data(
77+
table_name =>'SALES',
78+
credential_name =>'OBJ_STORE_CRED',
79+
file_uri_list =>'&base_URL/sale1v3.dat',
80+
format => json_object('ignoremissingcolumns' value 'true', 'removequotes' value 'true', 'dateformat' value 'YYYY-MM-DD', 'blankasnull' value 'true')
81+
);
82+
end;
83+
/
84+
begin
85+
dbms_cloud.copy_data(
86+
table_name =>'TIMES',
87+
credential_name =>'OBJ_STORE_CRED',
88+
file_uri_list =>'&base_URL/time_v3.dat',
89+
format => json_object('ignoremissingcolumns' value 'true', 'removequotes' value 'true', 'dateformat' value 'YYYY-MM-DD-HH24-MI-SS', 'blankasnull' value 'true')
90+
);
91+
end;
92+
/
93+
begin
94+
dbms_cloud.copy_data(
95+
table_name =>'COSTS',
96+
credential_name =>'OBJ_STORE_CRED',
97+
file_uri_list =>'&base_URL/costs.dat',
98+
format => json_object('ignoremissingcolumns' value 'true', 'dateformat' value 'YYYY-MM-DD', 'blankasnull' value 'true')
99+
);
100+
end;
101+
/
235 KB
Loading
14.6 KB
Loading
18.7 KB
Loading
37 KB
Loading
54.5 KB
Loading
63.8 KB
Loading
39.9 KB
Loading
43 KB
Loading

0 commit comments

Comments
 (0)