Skip to content

Commit dd15a59

Browse files
committed
Added first pass at local RAG with anythingllm
Added a first pass at anythingllm rag Signed-off-by: JJ Asghar <[email protected]>
1 parent c871f1a commit dd15a59

File tree

7 files changed

+117
-0
lines changed

7 files changed

+117
-0
lines changed

docs/images/adding_pdf.png

216 KB
Loading

docs/images/budget_workspace.png

157 KB
Loading

docs/images/doent_know.png

163 KB
Loading
274 KB
Loading

docs/images/success.png

181 KB
Loading

docs/lab-6/README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
title: Using AnythingLLM for a local RAG
3+
description: Learn how to build a simple local RAG
4+
logo: images/ibm-blue-background.png
5+
---
6+
7+
## Configuration and Sanity Check
8+
9+
Open up AnyThingLLM, and you should see something like the following:
10+
![default screen](../images/anythingllm_open_screen.png)
11+
12+
If you see this that means AnythingLLM is installed correctly, and we can continue configuration, if not, please find a workshop TA or
13+
raise your hand we'll be there to help you ASAP.
14+
15+
Next as a sanity check, run the following command to confirm you have the [granite3.1-dense](https://ollama.com/library/granite3.1-dense)
16+
model downloaded in `ollama`. This may take a bit, but we should have a way to copy it directly on your laptop.
17+
18+
```bash
19+
ollama pull granite3.1-dense:8b
20+
```
21+
22+
If you didn't know, the supported languages with `granite3.1-dense` now include:
23+
24+
- English, German, Spanish, French, Japanese, Portuguese, Arabic, Czech, Italian, Korean, Dutch, Chinese (Simplified)
25+
26+
And the Capabilities also include:
27+
28+
- Summarization
29+
- Text classification
30+
- Text extraction
31+
- Question-answering
32+
- Retrieval Augmented Generation (RAG)
33+
- Code related tasks
34+
- Function-calling tasks
35+
- Multilingual dialog use cases
36+
- Long-context tasks including long document/meeting summarization, long document QA, etc.
37+
38+
Next click on the `wrench` icon, and open up the settings. For now we are going to configure the global settings for `ollama`
39+
but you may want to change it in the future.
40+
41+
![wrench icon](../images/anythingllm_wrench_icon.png)
42+
43+
Click on the "LLM" section, and select **Ollama** as the LLM Provider. Also select the `granite3-dense:8b` model. (You should be able to
44+
see all the models you have access to through `ollama` there.)
45+
46+
![llm configuration](../images/anythingllm_llm_config.png)
47+
48+
Click the "Back to workspaces" button where the wrench was. And Click "New Workspace."
49+
50+
![new workspace](../images/anythingllm_new_workspace.png)
51+
52+
Name it something like "learning llm" or the name of the event we are right now, something so you know it's somewhere you are learning
53+
how to use this LLM.
54+
55+
![naming new workspace](../images/anythingllm_naming_workspace.png)
56+
57+
Now we can test our connections _through_ AnythingLLM! I like the "Who is Batman?" question, as a sanity check on connections and that
58+
it knows _something_.
59+
60+
![who is batman](../images/anythingllm_who_is_batman.png)
61+
62+
Now you may notice that the answer is slighty different then the screen shot above. That's expected and nothing to worry about. If
63+
you have more questions about it raise your hand and one of the helpers would love to talk you about it.
64+
65+
Congratulations! You have AnythingLLM running now, configured to work with `granite3.1-dense` and `ollama`!
66+
67+
## Creating your own local RAG
68+
69+
Now that you have everything set up, lets build our own RAG. You need a document, of some sort to questions to answer against
70+
it. Lets start with something fun. As of right now, our Granite model doesn't know about the US Federal Budget in 2024, so lets
71+
ask it a question about it to verify.
72+
73+
Create a new workspace, and call it whatever you want:
74+
75+
![new budget workspace](../images/new_budget_workspace.png)
76+
77+
Now you have a new workspace, ask it a question like:
78+
79+
```
80+
What was the US federal budget for 2024?
81+
```
82+
83+
You should come back with something like the following, it may be different, but the gist is there.
84+
85+
![doesnt know the budget](../images/doesnt_know.png)
86+
87+
Not great right? Well now we need to give it a way to look up this data, luckly, we have a backed up
88+
copy of the budget pdf [here](https://github.com/user-attachments/files/18510560/budget_fy2024.pdf).
89+
Go ahead and save it to your local machine, and be ready to grab it.
90+
91+
Now spin up a new workspace, (yes, please a new workspace, it seems that sometimes AnythingLLM has
92+
issues with adding things, so a clean environment is always easier to teach in) and call it
93+
something else.
94+
95+
![budget workspace](../images/budget_workspace.png)
96+
97+
Click on the "upload a document" to get the pdf added.
98+
99+
Next we need to add it to the workspace.
100+
101+
![adding pdf](../images/adding_pdf.png)
102+
103+
Next click the upload or drag and drop and put the pdf in there, and then the arrow to move it to the
104+
workspace. Click Save and Embed.
105+
106+
You have now added the pdf to the workspace.
107+
108+
Now when the chat comes back up ask the same question, and you should see some new answers!
109+
110+
![success pdf](../images/success.png)
111+
112+
It won't be exactly what we are looking for, but it's enough to now see that the Granite model can
113+
leverage the local RAG and in turn can _look things up_ for you. You'll need some prompt engineering
114+
to get exactly what you want but this is just the start of leveraging the AI!
115+
116+

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ nav:
2020
- Lab 3.5 Configuring Open-WebUI: lab-3.5/README.md
2121
- Lab 4. Prompt engineering overview: lab-4/README.md
2222
- Lab 5. Useful prompts and use cases: lab-5/README.md
23+
- Lab 6. Using AnythingLLM for a Local RAG: lab-6/README.md
2324
- References:
2425
- Additional Resources: resources/RESOURCES.md
2526
- MkDocs Cheatsheet: resources/MKDOCS.md

0 commit comments

Comments
 (0)