|
| 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 | + |
| 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 | + |
| 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 | + |
| 47 | + |
| 48 | +Click the "Back to workspaces" button where the wrench was. And Click "New Workspace." |
| 49 | + |
| 50 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
0 commit comments