Skip to content

Commit d3ed444

Browse files
committed
merged Bobs pages
1 parent 177b28f commit d3ed444

File tree

10 files changed

+229
-91
lines changed

10 files changed

+229
-91
lines changed
478 KB
Loading
215 KB
Loading
256 KB
Loading

documentation/modules/ROOT/nav.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
* xref:index.adoc[{counter:module}. Home page]
1+
* xref:index.adoc[{counter:module}. Introduction]
22
** xref:index.adoc#use-cases[{module}.{counter:submodule1} Use cases]
33
** xref:index.adoc#_the_story_behind_this_solution_pattern[{module}.{counter:submodule1} The story behind this solution pattern]
44
** xref:index#_the_solution[{module}.{counter:submodule1} The solution]
55
66
* xref:02-architecture.adoc[{counter:module}. Architecture]
7+
** xref:02-architecture.adoc#challenges[{module}.{counter:submodule2}. Common Challenges]
78
** xref:02-architecture.adoc#tech_stack[{module}.{counter:submodule2}. Technology stack]
89
** xref:02-architecture.adoc#in_depth[{module}.{counter:submodule2}. An in-depth look at the solution's architecture]
910
** xref:02-architecture.adoc#more_tech[{module}.{counter:submodule2}. More about the technology stack]
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
== The story behind this solution pattern
22

3-
A description of the story that was used to build the demo and architectures of this SP.
3+
This solution pattern uses a Retreival Augmented Generation (RAG) AI workflow to to summarize financial data
4+
from a stock symbol API service. The use of AI in this scenario provides a financial analyst
5+
with a starting point and is especially helpfull when comparing a number of different stock symbols at once.
6+
Data returned from a stock symbol service is often terse including many acronyms and abreviations. The goal is to
7+
demonstrate how AI technologies can be used to summarize the financial data in a way that is
8+
more concise and meaningful in a short period of time with minimal human intervention.
9+
10+
The solution begins by using Red Hat Build of Apache Camel to ingest and syncronize publicly aviable financial data
11+
into a vector database powered by Weaviate. The json formatted data returned from the stock symbol service conists of a company description followed by a number of
12+
financial metrics such as revenue, profit, market capitalization, etc.
13+
14+
The RAG workflow consists of a vector database, an embeddings model (used to convert
15+
words into vectors) and a large language model (LLM) to summarize the results which is presented to the user.
16+
This approach is desirable when information changes frequently or in semi-real time.
17+
For example, new stock prices are published every 15 minutes.
18+
As an alternative to fine tuning an LLM to recognize your private knowledge, Retreival Augmented Generation (RAG)
19+
provides a reasonable approach to this solution with good accuracy.
420

521
== The Solution
622

7-
This is a summary of the solution
23+
This solution patterns consists of the following open source components which are hosted on the Red Hat Openshift
24+
container platform:
25+
26+
- Red Hat Build of Apache Camel
27+
- Weaviate Vector Database
28+
- The Ollama model server
29+
- A Cloud Native User Interface built with Gradio

documentation/modules/ROOT/pages/02-architecture.adoc

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,98 +7,99 @@
77

88
Introduction for the architecture of this solution pattern.
99

10+
[#challenges]
1011
== Common Challenges
1112

13+
This solution pattern address the following challenges:
14+
15+
- Integrating private knowledge into a generative AI workflow.
16+
17+
- Capturing and syncronizing near real-time stock exchange data makes periodic fine tuning
18+
of LLMs prohibitive.
19+
20+
- Exposing private data sources via externally hosted API services Hosting AI services raises security
21+
and privacy concerns for most enterprises.
22+
1223
[#tech_stack]
1324
== Technology Stack
1425

1526
// Change links and text here as you see fit.
16-
* Red Hat supported products
27+
* Red Hat supported products:
1728
** https://www.redhat.com/en/technologies/cloud-computing/openshift[Red Hat OpenShift]
18-
** Red Hat Application Foundation
19-
*** https://access.redhat.com/products/quarkus[Quarkus]
20-
*** https://www.redhat.com/en/technologies/cloud-computing/openshift/openshift-streams-for-apache-kafka[Kafka Streams]
29+
*** https://https://developers.redhat.com/products/openshift-dev-spaces/overview[Red Hat Openshift Dev Spaces]
30+
** https://access.redhat.com/products/red-hat-application-foundations[Red Hat Application Foundation]
31+
*** https://docs.redhat.com/en/documentation/red_hat_build_of_apache_camel/4.0[Red Hat build of Apache Camel] (included
32+
with Red Hat Application Foundation)
2133
* Other open source products:
22-
** https://www.postgresql.org/[PostgreSQL database]
23-
** https://helm.sh/[Helm]
34+
** https://weaviate.io/[Weaviate vector database]
35+
** https://ollama.com/[Ollama Model Server and model files]
36+
** https://https://huggingface.co/gradio[Gradio]
2437

2538

2639
[#in_depth]
2740
== An in-depth look at the solution's architecture
2841

29-
Technical description including all or some of the following: architecture ir ed diagrams. In-depth details of the decisions made and solutions used. Description of each service and what it is used for. Description of any integration.
30-
31-
=== Using images
32-
33-
image::red_hat_open-hybrid-cloud.png[width=30%]
42+
A closer look at the services and components that make up this solution pattern.
3443

35-
{empty}
36-
37-
=== Embedding HTML
38-
39-
++++
40-
<br>
41-
<h3> Embed HTML by surrounding it with with four +s before and after. </h3>
42-
<span>View the ascii doc to learn more</span>
43-
<br>
44-
++++
44+
=== Data Flow
4545

46+
image::dataflow.jpg[width=100%]
4647

47-
=== Different decorators
48+
==== Ingest Engine
49+
Data flow begins at the source with stock information made available
50+
via a RESTful API service hosted by Alpha Vantage. The ingest engine consisting
51+
of two Camel services takes care of keeping data fresh in the Weaviate
52+
vector database. The ingest processes are highly configurable and perform
53+
filtering and discarding of invalid or null data. As stock symbol information is
54+
read in, vector embeddings are generated and stored in the Weaviate vector database along
55+
with the financial entities for each stock symbol. An example json record is available
56+
in the https://www.alphavantage.co/query?function=OVERVIEW&symbol=IBM&apikey=demo[AlphaVantage API documentation].
4857

49-
[TIP]
50-
====
51-
This is a Tip
52-
====
58+
==== Vector Database
59+
The vector database used is Weaviate. Weaviate is a highly performant and scalable open-source vector database
60+
that simplifies the development of AI applications. Built-in vector and hybrid search, easy-to-connect machine
61+
learning models, and a focus on data privacy enable developers of all levels to build, iterate, and scale AI
62+
capabilities faster.
5363

54-
[NOTE]
55-
====
56-
This is a NOTE
57-
====
64+
==== Machine Learning (ML) models
65+
This solution pattern makes use of two ML models, an enbeddings model (`all-minilm`) and an LLM (`granite3-dense:8b`)
66+
which is configurable at run time. The enbeddings model is used to generate vector embeddings for each stock symbol and
67+
the LLM summarizes the stock information. Granite a series of LLMs developed by IBM, specifically designed
68+
for enterprise applications, focusing on business use cases like code generation, summarization, and classification,
69+
with a strong emphasis on security and data privacy, all while being open-source under the Apache 2.0 license.
5870

59-
[WARNING]
60-
====
61-
This is a WARNING
62-
====
6371

64-
[IMPORTANT]
65-
====
66-
This is IMPORTANT
67-
====
72+
image::rag-architecture.jpg[width=100%]
6873

74+
{empty}
6975

70-
=== Creating tables
71-
72-
[cols="1a,1a,1a"]
73-
|===
74-
| *Column A* | Column *A* | _Column C_
75-
|
76-
* Lorem Ipsum
77-
* Lorem Ipsum
78-
79-
|
80-
* Lorem Ipsum
81-
* Lorem Ipsum
82-
83-
|
84-
* Lorem Ipsum
85-
* Lorem Ipsum
86-
|===
76+
=== Architecture
8777

78+
=== Ingest Engine
8879

80+
==== Weaviate vector database
81+
The Weaviate vector database is installed using the helm installer which allows for enterprise features to be enabled including
82+
API key token authentication and data sharding. Weaviate's cloud-native design supports horizontal scaling and efficient resource consumption,
83+
allowing it to handle large volumes of data and user requests easily. Interested readers are encouraged to find out more
84+
about https://www.redhat.com/en/blog/building-powerful-applications-weaviate-and-red-hat-openshift-retrieval-augmented-generation-workflow[the benefits of hosting Weaviate on Openshift].
8985

90-
=== Content that can be copied
86+
==== Ollama Model Server
87+
https://github.com/ollama/ollama[Ollama] is a popular and easy to use platform to host and serve LLMs. It supports a number of
88+
operating systems and provides good integration and compatibility with the open source ecosystem including Weaviate. Ollama
89+
is deployed on Openshift using a https://github.com/openshift/source-to-image[standard source-to-image workflow]. Details
90+
can be found in this repository.
9191

92-
Click below to copy the content
93-
[.console-input]
94-
[source,shell script]
95-
----
96-
oc version #openshift cli client
97-
oc login --token=<token> --server=<server>
98-
----
92+
==== User Interface
93+
The UI is written in Python using the Gradio framework and is deployed using Openshift source-to-image workflow.
94+
Example queries are presented to the user as pushbuttons to perform semantic
95+
and generative queries. Users may also enter custom queries and prompts.
9996

97+
==== Developer IDE
98+
Provided by Red Hat Openshift DevSpaces, this IDE allows developers to work with the codebase and test their changes
99+
in a live environment.
100100

101101
[#more_tech]
102102
== About the Technology Stack
103103

104-
If you want to include more details about the tech stack you used, this is the place.
104+
https://weaviate.io/[Weaviate] is an open-source vector database that makes it easy to build AI applications.
105+
https://ollama.com/[Ollama] is a popular and easy to use platform to host and serve LLMs.

documentation/modules/ROOT/pages/03-demo.adoc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@ Include here content related to potential existing demos: blogs, articles, recor
1212
[#demo-video]
1313
=== Watch a demonstration
1414

15-
In this video you can see xpto:
15+
In this video you can see a brief demonstration:
1616

17-
video::3yULVMdqJ98[youtube, width=800, height=480]
17+
video::https://people.redhat.com/bkozdemb/downloads/fsi-rag.m4v[width=100%]
1818

19-
Next, you can learn how to walkthrough this demo.
19+
=== Application Screen Shot
20+
image::app-screenshot.png[width=100%]
2021

21-
== Run the demonstration
22+
Next, you can learn how to install this demo.
2223

23-
=== Before getting started
24-
To run this demo, you will need xpto. Adding to that, make sure to have:
24+
== Installing and running the demonstration
2525

26-
* ABC
27-
* XYZ
28-
* XPTO
26+
=== Prequisites
27+
To run this demo, you will need an Openshift v4.16.x cluster with the following resources:
2928

30-
=== Installing the demo
31-
Installation guide and basic test of the demo installation if needed
29+
* A worker node that is configured with 8 virtual CPUS, 16GB of RAM and an NVIDIA accelerator with >= 16GB of GPU memory.
30+
* 100GB of storage available for persistent volumes.
3231

33-
=== Walkthrough guide
34-
How to run through the demo
32+
=== Installing the demo
33+
** Follow the https://github.com/redhat-na-ssa/demo-ai-weaviate[installation guide]

documentation/modules/ROOT/pages/04-workshop.adoc

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,111 @@
44
:doctype: book
55

66
= Workshop
7+
During this workshop youwill learn how to:
78

8-
what is this workshop and what will be learned
9+
- Get experience with a Weaviate enterprise installation.
10+
- Learn how to use the Weaviate Python client.
11+
- Learn how python application are deployed on Openshift
12+
- Work with the Gradio library to build a user interface.
13+
- Work with an LLM server on Openshift
14+
- Understand the various components that make up a RAG solution
915

1016
== Installing the workshop environment
1117
=== Before getting started
18+
19+
==== Prequisites
20+
21+
- An OpenShift Cluster
22+
* Version 4.16 or greater
23+
* A worker node with a minimum of 4 CPUs, 16 GB of memory and
24+
a single NVIDIA T4 GPU with 16GB of memory. (AWS `g4dn.xlarge` or equivalent)
25+
* The https://docs.openshift.com/container-platform/4.17/web_console/web_terminal/installing-web-terminal.html[web-terminal]
26+
operator
27+
- A client system with the following software installed:
28+
* https://mirror.openshift.com/pub/openshift-v4/clients/helm/latest[Helm]
29+
* https://maven.apache.org/download.cgi[Maven]
30+
* https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/[The Openshift `oc` cli]
31+
- An https://www.alphavantage.co/support/#api-key[AlphaVantage API Key] if you want to periodically
32+
refresh the stock symbol data.
33+
1234
=== Installing the environment
13-
== Delivering the workshop
35+
36+
The following services on OpenShift are required:
37+
38+
==== Weaviate Vector Database
39+
40+
- `git clone https://github.com/redhat-na-ssa/demo-ai-weaviate`
41+
- `cd demo-ai-weaviate`
42+
- `oc apply -k deploy`
43+
44+
==== Ollama LLM Server
45+
46+
- `oc apply -k ollama/deploy`
47+
48+
Pull the necessary ML models:
49+
50+
Login to the Openshift console, open a terminal window in the `ollama` project
51+
and run the following commands.
52+
53+
- `curl http://ollama.ollama/api/pull -d '{"model" : "all-minilm"}'`
54+
55+
- `curl http://ollama.ollama/api/pull -d '{"model" : "granite3-dense:8b"}'`
56+
57+
==== Stock Overview Ingestion Engine
58+
59+
===== Caching Proxy
60+
61+
Follow the instructions to install the caching proxy in the `camel` namespace.
62+
63+
- `oc new-project camel`
64+
- `git clone https://github.com/joshdreagan/av-caching-proxy.git`
65+
- `cd av-caching-proxy`
66+
- `cp src/main/jkube/deployment.yml.template src/main/jkube/deployment.yml`
67+
- `cp src/main/jkube/configmap.yml.template src/main/jkube/configmap.yml`
68+
- `mvn -P openshift clean package oc:deploy`
69+
70+
The default values for `deployment.yml`, and `configmap.yml` should be fine.
71+
72+
===== Stock Overview Syncronizer
73+
74+
Install the AlphaVantage syncronizer in the `camel` namespace.
75+
76+
- `git clone https://github.com/joshdreagan/av-overview-sync.git`
77+
- `cd av-overview-sync`
78+
- `cp src/main/jkube/deployment.yml.template src/main/jkube/deployment.yml`
79+
- `cp src/main/jkube/configmap.yml.template src/main/jkube/configmap.yml`
80+
- `cp src/main/jkube/secret.yml.template src/main/jkube/secret.yml`
81+
- `mvn -P openshift clean package oc:deploy`
82+
83+
Configure the `src/main/jkube/configmap.yml` to use the `all-minilm` vectorizer model
84+
and the `granite3-dense:8b` generative model.
85+
86+
Update your base64 encoded AlphaVantage API Key in the `src/main/jkube/secret.yml` file.
87+
88+
==== Gradio UI and application.
89+
90+
From a terminal, create an OpenShift application.
91+
92+
[NOTE]
93+
====
94+
Obtain the
95+
https://raw.githubusercontent.com/redhat-na-ssa/demo-ai-weaviate/refs/heads/main/deploy/weaviate/configmap.yaml[Weaviate API key]
96+
and use it to create the RAG application.
97+
====
98+
99+
- `oc new-app python~https://github.com/redhat-na-ssa/demo-ai-weaviate --name rag --context-dir=/src --env WEAVIATE_API_KEY=your_weaviate_admin-api-key`
100+
101+
Expose the app with an external route and have fun.
102+
103+
- `oc create route edge --service rag --insecure-policy=Redirect`
104+
105+
=== Running the workshop
106+
107+
- Review the https://www.alphavantage.co/query?function=OVERVIEW&symbol=IBM&apikey=demo[IBM stock symbol json] to
108+
explain the use case.
109+
- Review the dataflow diagram to explain the workflow.
110+
- Review the architecture diagram to explain the Openshift services.
111+
- Run the `rag` application.
112+
* Try different search terms and see how the results change.
113+
* Vary the limits and see the different number of returned results.
114+
* Try different LLM prompts.

documentation/modules/ROOT/pages/developer-resources.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
= Developer Resources
88

9-
* Add link to the git repo of the code
10-
* Add links to whitepapers, ebooks, learning paths, product pages
9+
== Deployment
10+
* https://github.com/redhat-na-ssa/demo-ai-weaviate[The git repo of the source code]
11+
12+
== Further reading
13+
* https://www.redhat.com/en/blog/building-powerful-applications-weaviate-and-red-hat-openshift-retrieval-augmented-generation-workflow[A blog post related to running vector databases on Red Hat Openshift]
1114

0 commit comments

Comments
 (0)