Skip to content

Commit ff9654a

Browse files
authored
Merge pull request #28 from jbusche/jim-rag-draft1
First draft at OpenWebUI RAG lab
2 parents 5e878f9 + 5f3164c commit ff9654a

File tree

8 files changed

+129
-0
lines changed

8 files changed

+129
-0
lines changed
548 KB
Loading

docs/images/ceo_list_with_rag.png

472 KB
Loading
250 KB
Loading
-18.5 KB
Loading

docs/images/rag_doc_added.png

220 KB
Loading

docs/images/small_llm_ceo_list.png

451 KB
Loading

docs/lab-7.5/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: Using Open-WebUI for a local RAG
3+
description: Learn how to build a simple local RAG
4+
logo: images/ibm-blue-background.png
5+
---
6+
7+
## Retrieval-Augmented Generation overview
8+
The LLMs we're using for these labs have been trained on billions of parameters, but they haven't been trained on everything, and the smaller models have less general knowledge to work with.
9+
For example, even the latest models are trained with aged data, and they couldn't know about current events or the unique data your use-case might need.
10+
11+
RAG allows the user to supplement the LLM's data with up-to-date information from external sources, like databases and documents.
12+
13+
In this lab we're going to use one of the smallest IBM Granite models and show that it's answer is not complete. Then we'll add a small RAG document and allow it render a much better answer
14+
utilizing both it's internal data combined with the RAG data you give it.
15+
16+
## Configuration and Sanity Check
17+
18+
Open up [Open-WebUI](http://localhost:8080/), and you should see something like the following:
19+
![default screen](../images/openwebui_open_screen.png)
20+
21+
If you see this that means Open-WebUI is installed correctly, and we can continue configuration, if not, please find a workshop TA or
22+
raise your hand we'll be there to help you ASAP.
23+
24+
Next as a sanity check, run the following command to confirm you have the [granite3.3:2b](https://ollama.com/library/granite3.3:2b)
25+
model downloaded in `ollama`. This may take a bit, but we should have a way to copy it directly on your laptop.
26+
27+
```bash
28+
ollama pull granite3.3:2b
29+
```
30+
31+
If you didn't know, the supported languages with `granite3.3:2b` now include:
32+
33+
- English, German, Spanish, French, Japanese, Portuguese, Arabic, Czech, Italian, Korean, Dutch, Chinese (Simplified)
34+
35+
And the Capabilities also include:
36+
37+
- Thinking
38+
- Summarization
39+
- Text classification
40+
- Text extraction
41+
- Question-answering
42+
- Retrieval Augmented Generation (RAG)
43+
- Code related tasks
44+
- Function-calling tasks
45+
- Multilingual dialog use cases
46+
- Fill-in-the-middle
47+
- Long-context tasks including long document/meeting summarization, long document QA, etc.
48+
49+
50+
Next click on the down arrow at the top and select the "granite3.3:2b" if it's not already selected.
51+
52+
![model selection](../images/openwebui_model_selection.png)
53+
54+
Click on the "New Chat" icon to clear the context. Then, ask the model for:
55+
```bash
56+
List all the past and current CEOs of the IBM corporation in order of their term as CEO
57+
```
58+
For example:
59+
![Small LLM CEO list](../images/small_llm_ceo_list.png)
60+
61+
At first glance, the list looks pretty good. But if you know your IBM CEOs, you'll notice that it misses a few of them, and sometimes adds new names that weren't ever IBM CEOs!
62+
(Note: the larger granite3.3:8b does a much better job on the IBM CEOs, you can try it later)
63+
But we can provide the small LLM with a RAG document that supplements the model's missing informaiton with a correct list, so it will generate a better answer.
64+
65+
Click on the "New Chat" icon to clear the context. Then download a small text file with the correct list of IBM CEOs to your Downloads folder:
66+
67+
[IBM.txt](../resources/IBM.txt)
68+
69+
Right click on the IBM.txt URL and select "Save Link As" and save it as IBM in your Downloads folder.
70+
71+
In your Open-WebUI browser, click on the "+" under the "send a message" prompt and then select "Upload files"
72+
73+
Select the IBM.txt file that you just downloaded in your Downloads folder and press Open.
74+
75+
![RAG Doc Added](../images/rag_doc_added.png)
76+
77+
Now ask it our question about the CEOs of IBM:
78+
```bash
79+
List all the past and current CEOs of the IBM corporation in order of their term as CEO
80+
```
81+
The answer should now be correct. (For example, always before it forgets John Akers)
82+
83+
![CEO list with RAG](../images/ceo_list_with_rag.png)
84+
85+
We can also find and download information to pdf from Wikipedia:
86+
For example: [History of IBM](https://en.wikipedia.org/wiki/History_of_IBM)
87+
88+
On the right of the Wikipedia page, click on "Tools" and click on "Download as PDF"
89+
90+
Then use this History_of_IBM.pdf as a RAG by clicking on the + and select "History_of_IBM.pdf" as a file from your Downloads folder.
91+
92+
Next, use the Open-WebUI to ask more questions about IBM, or have it summarize the document itself. For example:
93+
```bash
94+
Write a short 300 word summary of the History_of_IBM.pdf
95+
```
96+
![Summary of IBM History](../images/History_of_IBM_summary.png)
97+
98+
Congratulations, you've completed the Open-WebUI RAG example.

docs/resources/IBM.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
List of all the past and current CEOs of the IBM corporation in order of their term as CEO
2+
3+
Arvind Krishna (2021 - present) Male
4+
years as CEO: CEO 2021 - Present
5+
6+
Virginia M. (Ginni) Rometty (2012 - 2020) Female
7+
years as CEO: CEO 2012 - 2020
8+
9+
Samuel J. Palmisano (2002 - 2011) Male
10+
years as CEO: CEO 2002 - 2011
11+
12+
Louis V. Gerstner, Jr. (1993 - 2002) Male
13+
years as CEO: CEO 1993 - 2002
14+
15+
John F. Akers (1985 - 1993) Male
16+
years as CEO: CEO 1985 - 1993
17+
18+
John R. Opel (1981 - 1985) Male
19+
years as CEO: CEO 1981 - 1985
20+
21+
Frank T. Cary (1973 - 1981) Male
22+
years as CEO: CEO 1973 - 1981
23+
24+
T. Vincent Learson (1971 - 1973) Male
25+
years as CEO: CEO 1971 - 1973
26+
27+
Thomas J. Watson, Jr. (1956 - 1971) Male
28+
years as CEO: CEO 1956 - 1971
29+
30+
Thomas J. Watson (1914 - 1956) Male
31+
years as CEO: CEO 1914 - 1956

0 commit comments

Comments
 (0)