diff --git a/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/_index.md b/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/_index.md deleted file mode 100644 index f4f925daa7..0000000000 --- a/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/_index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: RAG example - -minutes_to_complete: 30 - -who_is_this_for: This is an introductory topic for developers interested in running LLMs on Arm-based servers. - -learning_objectives: - - Download and build llama.cpp on your Arm server. - - Download a pre-quantized Llama 3.1 model from Hugging Face. - - Re-quantize the model weights to take advantage of the Arm KleidiAI kernels. - - Compare the pre-quantized Llama 3.1 model weights performance to the re-quantized weights on your Arm CPU. - -prerequisites: - - An AWS Graviton3 c7g.16xlarge instance to test Arm performance optimizations, or any [Arm based instance](/learning-paths/servers-and-cloud-computing/csp/) from a cloud service provider or an on-premise Arm server. - -author_primary: Pareena Verma, Jason Andrews, and Zach Lasiuk - -### Tags -skilllevels: Introductory -subjects: ML -armips: - - Neoverse -operatingsystems: - - Linux -tools_software_languages: - - LLM - - GenAI - - Python - - -### FIXED, DO NOT MODIFY -# ================================================================================ -weight: 1 # _index.md always has weight of 1 to order correctly -layout: "learningpathall" # All files under learning paths have this same wrapper -learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content. ---- diff --git a/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/llama-chatbot.md b/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/llama-chatbot.md deleted file mode 100644 index 1f3b41cce7..0000000000 --- a/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/llama-chatbot.md +++ /dev/null @@ -1,279 +0,0 @@ ---- -title: Run a Large Language model (LLM) chatbot on Arm servers -weight: 3 - -### FIXED, DO NOT MODIFY -layout: learningpathall ---- - -## Before you begin -The instructions in this Learning Path are for any Arm server running Ubuntu 22.04 LTS. You need an Arm server instance with at least four cores and 8GB of RAM to run this example. Configure disk storage up to at least 32 GB. The instructions have been tested on an AWS Graviton3 c7g.16xlarge instance. - -## Overview - -Arm CPUs are widely used in traditional ML and AI use cases. In this Learning Path, you learn how to run generative AI inference-based use cases like a LLM chatbot on Arm-based CPUs. You do this by deploying the [Llama-3.1-8B model](https://huggingface.co/cognitivecomputations/dolphin-2.9.4-llama3.1-8b-gguf) on your Arm-based CPU using `llama.cpp`. - -[llama.cpp](https://github.com/ggerganov/llama.cpp) is an open source C/C++ project developed by Georgi Gerganov that enables efficient LLM inference on a variety of hardware - both locally, and in the cloud. - -## About the Llama 3.1 model and GGUF model format - -The [Llama-3.1-8B model](https://huggingface.co/cognitivecomputations/dolphin-2.9.4-llama3.1-8b-gguf) from Meta belongs to the Llama 3.1 model family and is free to use for research and commercial purposes. Before you use the model, visit the Llama [website](https://llama.meta.com/llama-downloads/) and fill in the form to request access. - - -The [Meta Llama 3.1 collection of models](https://github.com/meta-llama/llama-models/blob/main/models/llama3_1/MODEL_CARD.md) perform general natural language processing (NLP) tasks such as text generation. -The Llama 3.1 family of models range in size from 8 billion to 405 billion parameters. The greater the number of parameters, the more information the model can store. This directly affects how well the model understands language and the model's general capabilities. LLMs that run efficiently on CPUs typically have lower numbers of parameters. For this example, the 8 billion (8B) model is ideal for retaining quality chatbot capability while also running efficiently on your Arm-based CPU. - -Traditionally, the training and inference of LLMs has been done on GPUs using full-precision 32-bit (FP32) or half-precision 16-bit (FP16) data type formats for the model parameter and weights. Recently, a new binary model format called GGUF was introduced by the `llama.cpp` team. This new GGUF model format uses compression and quantization techniques that remove the dependency on using FP32 and FP16 data type formats. For example, GGUF supports quantization where model weights that are generally stored as FP16 data types are scaled down to 4-bit integers. This significantly reduces the need for computational resources and the amount of RAM required. These advancements made in the model format and the data types used make Arm CPUs a great fit for running LLM inferences. - -## Install dependencies - -Install the following packages on your Arm based server instance: - -```bash -sudo apt update -sudo apt install make cmake -y -``` - -You also need to install `gcc` on your machine: - -```bash -sudo apt install gcc g++ -y -sudo apt install build-essential -y -``` - -## Download and build llama.cpp - -You are now ready to start building `llama.cpp`. - -Clone the source repository for llama.cpp: - -```bash -git clone https://github.com/ggerganov/llama.cpp -``` - -By default, `llama.cpp` builds for CPU only on Linux and Windows. You don't need to provide any extra switches to build it for the Arm CPU that you run it on. - -Run `make` to build it: - -```bash -cd llama.cpp -make GGML_NO_LLAMAFILE=1 -j$(nproc) -``` - -Check that `llama.cpp` has built correctly by running the help command: - -```bash -./llama-cli -h -``` - -If `llama.cpp` has built correctly on your machine, you will see the help options being displayed. A snippet of the output is shown below: - -```output -usage: ./llama-cli [options] - -general: - - -h, --help, --usage print usage and exit - --version show version and build info - -v, --verbose print verbose information - --verbosity N set specific verbosity level (default: 0) - --verbose-prompt print a verbose prompt before generation (default: false) - --no-display-prompt don't print prompt at generation (default: false) - -co, --color colorise output to distinguish prompt and user input from generations (default: false) - -s, --seed SEED RNG seed (default: -1, use random seed for < 0) - -t, --threads N number of threads to use during generation (default: 4) - -tb, --threads-batch N number of threads to use during batch and prompt processing (default: same as --threads) - -td, --threads-draft N number of threads to use during generation (default: same as --threads) - -tbd, --threads-batch-draft N number of threads to use during batch and prompt processing (default: same as --threads-draft) - --draft N number of tokens to draft for speculative decoding (default: 5) - -ps, --p-split N speculative decoding split probability (default: 0.1) - -lcs, --lookup-cache-static FNAME - path to static lookup cache to use for lookup decoding (not updated by generation) - -lcd, --lookup-cache-dynamic FNAME - path to dynamic lookup cache to use for lookup decoding (updated by generation) - -c, --ctx-size N size of the prompt context (default: 0, 0 = loaded from model) - -n, --predict N number of tokens to predict (default: -1, -1 = infinity, -2 = until context filled) - -b, --batch-size N logical maximum batch size (default: 2048) -``` - - -## Install Hugging Face Hub - -There are a few different ways you can download the Meta Llama-3.1 8B model. In this Learning Path, you download the model from Hugging Face. - -{{% notice Note %}} Use of Llama 3.1 8B model is governed by the Meta license. Before you proceed to download the model, please visit the Llama [website](https://llama.meta.com/llama-downloads/) and fill in the form. {{% /notice %}} - -[Hugging Face](https://huggingface.co/) is an open source AI community where you can host your own AI models, train them and collaborate with others in the community. You can browse through the thousands of models that are available for a variety of use cases like NLP, audio, and computer vision. - -The `huggingface_hub` library provides APIs and tools that let you easily download and fine-tune pre-trained models. You will use `huggingface-cli` to download the [Llama-3.1 8B model](https://huggingface.co/cognitivecomputations/dolphin-2.9.4-llama3.1-8b-gguf). - -Install the required Python packages: - -```bash -sudo apt install python-is-python3 python3-pip python3-venv -y -``` - -Create and activate a Python virtual environment: - -```bash -python -m venv venv -source venv/bin/activate -``` - -Your terminal prompt now has the `(venv)` prefix indicating the virtual environment is active. Use this virtual environment for the remaining commands. - -Install the `huggingface_hub` python library using `pip`: - -```bash -pip install huggingface_hub -``` - -You can now download the model using the huggingface cli: - -```bash -huggingface-cli download cognitivecomputations/dolphin-2.9.4-llama3.1-8b-gguf dolphin-2.9.4-llama3.1-8b-Q4_0.gguf --local-dir . --local-dir-use-symlinks False -``` -Before you proceed and run this model, take a quick look at what `Q4_0` in the model name denotes. - -## Quantization format - -`Q4_0` in the model name refers to the quantization method the model uses. The goal of quantization is to reduce the size of the model (to reduce the memory space required) and faster (to reduce memory bandwidth bottlenecks transferring large amounts of data from memory to a processor). The primary trade-off to keep in mind when reducing a model's size is maintaining quality of performance. Ideally, a model is quantized to meet size and speed requirements while not having a negative impact on performance. - -This model is `llama3.1-8b-Q4_0.gguf`, so what does each component mean in relation to the quantization level? The main thing to note is the number of bits per parameter, which is denoted by 'Q4' in this case or 4-bit integer. As a result, by only using 4 bits per parameter for 8 billion parameters, the model drops to be 4.7Gb in size. - -Here is a quick lookup to the rest of the quantization parts for the Llama-2 model family as it exists today: - -| quantization-method | # of bits per parameter | quantization format (does not apply to quantization method 'IQ') | quantization method specifics | -| ------------------- | ----------------------- | ---------------------------------------------------------------- | ------------------ | -| Q, IQ, F, FP | 2,3,4,5,6,7,8,16,32 | _0, _1, _K | _XXS, _XS, _S, _M, _L | - -Some examples: - -* Q8_0 --> Straightforward quantization method (indicated with _0 or _1), with an 8 bit integer per parameter. -* Q4_K_M --> K-quant method (indicated with _K), with a 4 bit integer per parameter, with the _M quantization mix type used. -* IQ2_XXS --> I-quant method (indicated with _IQ), with the _XXS quantization mix type used. -* F16 --> Using a 16 bit floating point number per parameter (no other quantization method used, only rounding a number if starting from a 32 bit floating point number). - -Each quantization method has a unique approach to quantizing parameters. The deeper technical details of different quantization methodologies are outside the scope of this guide. The main takeaway is that selecting the right model quantization is critical to running an LLM effectively on your hardware, and the most impactful quantization decision is the number of bits per parameter. You will need also need to check you have enough system memory before deploying larger models or models with higher precision/quantization. - -In this guide, you will not use any other quantization methods, because Arm has not made kernel optimizations for other quantization types. - -## Re-quantize the model weights - -To see improvements for Arm optimized kernels, you need to generate a new weights file with rearranged Q4_0 weights. As of [llama.cpp commit 0f1a39f3](https://github.com/ggerganov/llama.cpp/commit/0f1a39f3), Arm has contributed code for three types of GEMV/GEMM kernels corresponding to three processor types: - -* AWS Graviton2, where you only have NEON support (you will see less improvement for these GEMV/GEMM kernels), -* AWS Graviton3, where the GEMV/GEMM kernels exploit both SVE 256 and MATMUL INT8 support, and -* AWS Graviton4, where the GEMV/GEMM kernels exploit NEON/SVE 128 and MATMUL_INT8 support - -To re-quantize optimally for Graviton3, run - -```bash -./llama-quantize --allow-requantize dolphin-2.9.4-llama3.1-8b-Q4_0.gguf dolphin-2.9.4-llama3.1-8b-Q4_0_8_8.gguf Q4_0_8_8 -``` - -This will output a new file, `dolphin-2.9.4-llama3.1-8b-Q4_0_8_8.gguf`, which contains reconfigured weights that allow `llama-cli` to use SVE 256 and MATMUL_INT8 support. - -{{% notice Note %}} -This requantization is optimal only for Graviton3. For Graviton2, requantization should optimally be done in `Q4_0_4_4` format, and for Graviton4, `Q4_0_4_8` is the optimal requantization format. -{{% /notice %}} - -## Compare the pre-quantized Llama-3.1-8B LLM model weights to the optimized weights - -First, run the pre-quantized llama-3.1-8b model exactly as the weights were downloaded from huggingface: - -```bash -./llama-cli -m dolphin-2.9.4-llama3.1-8b-Q4_0.gguf -p "Building a visually appealing website can be done in ten simple steps:" -n 512 -t 64 -``` - -This command will use the downloaded model (`-m` flag), with the specified prompt (`-p` flag), and target a 512 token completion (`-n` flag), using 64 threads (`-t` flag). - -You will see lots of interesting statistics being printed from llama.cpp about the model and the system, followed by the prompt and completion. The tail of the output from running this model on an AWS Graviton3 c7g.16xlarge instance is shown below: - -```output -llm_load_tensors: ggml ctx size = 0.14 MiB -llm_load_tensors: CPU buffer size = 4437.82 MiB -....................................................................................... -llama_new_context_with_model: n_ctx = 131072 -llama_new_context_with_model: n_batch = 2048 -llama_new_context_with_model: n_ubatch = 512 -llama_new_context_with_model: flash_attn = 0 -llama_new_context_with_model: freq_base = 500000.0 -llama_new_context_with_model: freq_scale = 1 -llama_kv_cache_init: CPU KV buffer size = 16384.00 MiB -llama_new_context_with_model: KV self size = 16384.00 MiB, K (f16): 8192.00 MiB, V (f16): 8192.00 MiB -llama_new_context_with_model: CPU output buffer size = 0.49 MiB -llama_new_context_with_model: CPU compute buffer size = 8480.01 MiB -llama_new_context_with_model: graph nodes = 1030 -llama_new_context_with_model: graph splits = 1 - -system_info: n_threads = 64 (n_threads_batch = 64) / 64 | AVX = 0 | AVX_VNNI = 0 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | AVX512_BF16 = 0 | FMA = 0 | NEON = 1 | SVE = 1 | ARM_FMA = 1 | F16C = 0 | FP16_VA = 1 | RISCV_VECT = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 0 | SSSE3 = 0 | VSX = 0 | MATMUL_INT8 = 1 | LLAMAFILE = 0 | -sampling seed: 4210375779 -sampling params: - repeat_last_n = 64, repeat_penalty = 1.000, frequency_penalty = 0.000, presence_penalty = 0.000 - top_k = 40, tfs_z = 1.000, top_p = 0.950, min_p = 0.050, typical_p = 1.000, temp = 0.800 - mirostat = 0, mirostat_lr = 0.100, mirostat_ent = 5.000 -sampler constr: - logits -> logit-bias -> penalties -> top-k -> tail-free -> typical -> top-p -> min-p -> temp-ext -> softmax -> dist -generate: n_ctx = 131072, n_batch = 2048, n_predict = 512, n_keep = 1 - - -Building a visually appealing website can be done in ten simple steps: Plan, design, wireframe, write content, optimize for SEO, choose the right platform, add interactive elements, test and fix bugs, launch, and finally, maintain. These steps are crucial for creating a user-friendly and effective website that attracts visitors and converts them into customers. -1. Planning the Website -Planning is the first and most crucial stage in building a website. It involves determining your target audience, identifying their needs, and outlining what the website will offer them. The planning process also includes setting goals for the website and figuring out how it will be used. This stage is essential as it will guide the design, content, and functionality of your website. -2. Designing the Website -Once you have a clear plan, you can proceed to design the website. The design stage involves creating a visual representation of your website, including its layout, color scheme, typography, and imagery. A well-designed website is crucial for capturing the attention of your target audience and encouraging them to engage with your content. -3. Creating a Wireframe -A wireframe is a simple, low-fidelity version of your website that outlines its structure and layout. It is a critical stage in the website-building process as it helps you visualize how your website will look and function before you invest in the design and development stages. A wireframe also allows you to gather feedback from stakeholders and refine your design before it goes live. -4. Writing Quality Content -Content is the lifeblood of any website. It is essential to create high-quality, engaging, and informative content that resonates with your target audience. The content should be well-researched, optimized for SEO, and written in a style that is easy to understand. It is also essential to keep your content fresh and up-to-date to keep your audience engaged. -5. Optimizing for SEO -Search Engine Optimization (SEO) is the process of optimizing your website to rank higher in search engine results pages (SERPs). It involves optimizing your website's content, structure, and technical aspects to make it more visible and accessible to search engines. SEO is critical for driving organic traffic to your website and increasing its visibility online. -6. Choosing the Right Platform -Choosing the right platform for your website is essential for its success. There are various website-building platforms available, such as WordPress, Squarespace, and Wix. Each platform has its strengths and weaknesses, and it is essential to choose the one that best suits your needs. -7. Adding Interactive Elements -Interactive elements, such as videos, quizzes, and gam -llama_perf_sampler_print: sampling time = 41.44 ms / 526 runs ( 0.08 ms per token, 12692.44 tokens per second) -llama_perf_context_print: load time = 4874.27 ms -llama_perf_context_print: prompt eval time = 87.00 ms / 14 tokens ( 6.21 ms per token, 160.92 tokens per second) -llama_perf_context_print: eval time = 11591.53 ms / 511 runs ( 22.68 ms per token, 44.08 tokens per second) -llama_perf_context_print: total time = 11782.00 ms / 525 tokens -``` - -The `system_info` printed from llama.cpp highlights important architectural features present on your hardware that improve the performance of the model execution. In the output shown above from running on an AWS Graviton3 instance, you will see: - - * NEON = 1 This flag indicates support for Arm's Neon technology which is an implementation of the Advanced SIMD instructions - * ARM_FMA = 1 This flag indicates support for Arm Floating-point Multiply and Accumulate instructions - * MATMUL_INT8 = 1 This flag indicates support for Arm int8 matrix multiplication instructions - * SVE = 1 This flag indicates support for the Arm Scalable Vector Extension - - -The end of the output shows several model timings: - -* load time refers to the time taken to load the model. -* prompt eval time refers to the time taken to process the prompt before generating the new text. In this example, it shows that it evaluated 16 tokens in 1998.79 ms. -* eval time refers to the time taken to generate the output. Generally anything above 10 tokens per second is faster than what humans can read. - -You can compare these timings to the optimized model weights by running: - -```bash -./llama-cli -m dolphin-2.9.4-llama3.1-8b-Q4_0_8_8.gguf -p "Building a visually appealing website can be done in ten simple steps:" -n 512 -t 64 -``` - -This is the same command as before, but with the model file swapped out for the re-quantized file. - -The timings on this one look like: - -```output -llama_perf_sampler_print: sampling time = 41.13 ms / 526 runs ( 0.08 ms per token, 12789.96 tokens per second) -llama_perf_context_print: load time = 4846.73 ms -llama_perf_context_print: prompt eval time = 48.22 ms / 14 tokens ( 3.44 ms per token, 290.32 tokens per second) -llama_perf_context_print: eval time = 11233.92 ms / 511 runs ( 21.98 ms per token, 45.49 tokens per second) -llama_perf_context_print: total time = 11385.65 ms / 525 tokens - -``` - -As you can see, load time improves, but the biggest improvement can be seen in prompt eval times. - -You have successfully run a LLM chatbot with Arm optimizations, all running on your Arm AArch64 CPU on your server. You can continue experimenting and trying out the model with different prompts. - diff --git a/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/llama-server.md b/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/llama-server.md deleted file mode 100644 index 2729e44860..0000000000 --- a/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/llama-server.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -title: Access the chatbot using the OpenAI-compatible API -weight: 4 - -### FIXED, DO NOT MODIFY -layout: learningpathall ---- - -You can use the `llama.cpp` server program and submit requests using an OpenAI-compatible API. -This enables applications to be created which access the LLM multiple times without starting and stopping it. You can also access the server over the network to another machine hosting the LLM. - -One additional software package is required for this section. Install `jq` on your computer using: - -```bash -sudo apt install jq -y -``` - -The server executable has already compiled during the stage detailed in the previous section, when you ran `make`. - -Start the server from the command line, it listens on port 8080: - -```bash -./llama-server -m dolphin-2.9.4-llama3.1-8b-Q4_0_8_8.gguf --port 8080 -``` - -## Use curl - -You can access the API using the `curl` command. - -In another terminal, use a text editor to create a file named `curl-test.sh` with the commands below: - -```bash -curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{ - "model": "any-model", - "messages": [ - { - "role": "system", - "content": "You are a coding assistant, skilled in programming." - }, - { - "role": "user", - "content": "Write a hello world program in C++." - } - ] - }' 2>/dev/null | jq -C -``` - -The `model` value in the API is not used, you can enter any value. This is because there is only one model loaded in the server. - -Run the script: - -```bash -bash ./curl-test.sh -``` - -The `curl` command accesses the LLM and you see the output: - -```output -{ - "choices": [ - { - "finish_reason": "stop", - "index": 0, - "message": { - "content": "#include \n\nint main() {\n std::cout << \"Hello, World!\" << std::endl;\n return 0;\n}", - "role": "assistant" - } - } - ], - "created": 1726252907, - "model": "any-model", - "object": "chat.completion", - "usage": { - "completion_tokens": 30, - "prompt_tokens": 33, - "total_tokens": 63 - }, - "id": "chatcmpl-wh33d82OqWKibRF0s7waublCpl9YytkI" -} -``` - -In the returned JSON data you see the LLM output, including the content created from the prompt. - -## Use Python - -You can also use a Python program to access the OpenAI-compatible API. - -Create a Python `venv`: - -```bash -python -m venv pytest -source pytest/bin/activate -``` - -Install the OpenAI Python package: -```bash -pip install openai==1.45.0 -``` - -Use a text editor to create a file named `python-test.py` with the content below: - -```python -from openai import OpenAI - -client = OpenAI( - base_url='http://localhost:8080/v1', - api_key='no-key' - ) - -completion = client.chat.completions.create( - model="not-used", - messages=[ - {"role": "system", "content": "You are a coding assistant, skilled in programming.."}, - {"role": "user", "content": "Write a hello world program in C++."} - ], - stream=True, -) - -for chunk in completion: - print(chunk.choices[0].delta.content or "", end="") -``` - -Run the Python file (make sure the server is still running): - -```bash -python ./python-test.py -``` - -You see the output generated by the LLM: - -```output -Here's a simple Hello World program in C++: - -```cpp -#include - -int main() { - std::cout << "Hello, World!" << std::endl; - return 0; -} - -This program includes the standard input/output library, `iostream`. It defines a `main` function, which is the entry point of the program. Inside `main`, `std::cout` is used to output the string "Hello, World!" to the console, and then `std::endl` is used to print a new line. The `return 0;` statement indicates that the program exited successfully -``` - -You can continue to experiment with different large language models and write scripts to try them. diff --git a/content/learning-paths/servers-and-cloud-computing/rag/_demo.md b/content/learning-paths/servers-and-cloud-computing/rag/_demo.md index 20af058137..b8f321a74e 100644 --- a/content/learning-paths/servers-and-cloud-computing/rag/_demo.md +++ b/content/learning-paths/servers-and-cloud-computing/rag/_demo.md @@ -2,13 +2,17 @@ title: Run a llama.cpp chatbot powered by Arm Kleidi technology overview: | - Some description of this sucker. + This Arm learning path shows how to use a single c4a-standard-64 Google Axion instance -- powered by an Arm Neoverse CPU -- to build a simple "Token as a Service" RAG-enabled server, used below to provide a chatbot to serve a small number of concurrent users. + + This architecture would be suitable for businesses looking to deploy the latest Generative AI technologies with RAG capabilities using their existing CPU compute capacity and deployment pipelines. It enables semantic search over chunked documents using FAISS vector store. The demo uses the open source llama.cpp framework, which Arm has enhanced by contributing the latest Arm Kleidi technologies. Further optimizations are achieved by using the smaller 8 billion parameter Llama 3.1 model, which has been quantized to optimize memory usage. + + Chat with the Llama-3.1-8B RAG-enabled LLM below to see the performance for yourself, then follow the learning path to build your own Generative AI service on Arm Neoverse. demo_steps: - Type & send a message to the chatbot. - - Receive the chatbot's reply. - - View stats showing how well AWS Graviton runs LLMs. + - Receive the chatbot's reply, including references from RAG data. + - View stats showing how well Google Axion runs LLMs. diagram: config-diagram-dark.png diagram_blowup: config-diagram.png @@ -18,9 +22,10 @@ terms_and_conditions: demo-terms-and-conditions.txt prismjs: true # enable prismjs rendering of code snippets example_user_prompts: - - Do Hyperscan and Snort3 work on Graviton4? - - How can I easily build multi-architecture Docker images? - + - How can I build multi-architecture Docker images? + - How do I test Java performance on Google Axion instances? + + rag_data_cutoff_date: 2025/01/17 title_chatbot_area: Arm RAG Demo diff --git a/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/_next-steps.md b/content/learning-paths/servers-and-cloud-computing/rag/_next-steps.md similarity index 79% rename from content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/_next-steps.md rename to content/learning-paths/servers-and-cloud-computing/rag/_next-steps.md index 01f4b230cb..683e14ef4a 100644 --- a/content/learning-paths/servers-and-cloud-computing/aaaaaaRAGexample/_next-steps.md +++ b/content/learning-paths/servers-and-cloud-computing/rag/_next-steps.md @@ -1,6 +1,6 @@ --- next_step_guidance: > - Thank you for completing this Learning path on how to run a LLM chatbot on an Arm-based server. You might be interested in learning how to run a NLP sentiment analysis model on an Arm-based server. + Thank you for completing this Learning path on how to run a RAG-enabled LLM chatbot on an Arm-based server. You might be interested in learning how to run a NLP sentiment analysis model on an Arm-based server. recommended_path: "/learning-paths/servers-and-cloud-computing/nlp-hugging-face/" @@ -17,10 +17,6 @@ further_reading: title: Democratizing Generative AI with CPU-based inference link: https://blogs.oracle.com/ai-and-datascience/post/democratizing-generative-ai-with-cpu-based-inference type: blog - - resource: - title: Llama-2-7B-Chat-GGUF - link: https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF - type: website # ================================================================================ diff --git a/content/learning-paths/servers-and-cloud-computing/rag/_review.md b/content/learning-paths/servers-and-cloud-computing/rag/_review.md deleted file mode 100644 index df0d24aaf6..0000000000 --- a/content/learning-paths/servers-and-cloud-computing/rag/_review.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -review: - - questions: - question: > - What is the primary purpose of using RAG in an LLM chatbot? - answers: - - To reduce the size of the model. - - To enhance the chatbot's responses with contextually-relevant information. - - To increase the training speed of the model. - - To simplify the deployment process. - correct_answer: 2 - explanation: > - RAG (Retrieval Augmented Generation) enhances the chatbot's responses by retrieving and incorporating contextually-relevant information from a vector database. - - - questions: - question: > - Which framework is used to create the web interface for the RAG-based LLM server? - answers: - - Django. - - Flask. - - Streamlit. - - FastAPI. - correct_answer: 3 - explanation: > - Streamlit is used to create the web interface for the RAG-based LLM server, allowing users to interact with the backend. - - - questions: - question: > - What is the role of FAISS in the RAG-based LLM server? - answers: - - To train the LLM model. - - To store and retrieve vectorized documents. - - To handle HTTP requests. - - To manage user authentication. - correct_answer: 2 - explanation: > - FAISS is used to store and retrieve vectorized documents, enabling the RAG-based LLM server to provide contextually relevant responses. - -# ================================================================================ -# FIXED, DO NOT MODIFY -# ================================================================================ -title: "Review" # Always the same title -weight: 6 # Set to always be larger than the content in this path -layout: "learningpathall" # All files under learning paths have this same wrapper ---- diff --git a/content/learning-paths/servers-and-cloud-computing/rag/config-diagram-dark.png b/content/learning-paths/servers-and-cloud-computing/rag/config-diagram-dark.png index 356c8c1abc..72c2c1fc3f 100644 Binary files a/content/learning-paths/servers-and-cloud-computing/rag/config-diagram-dark.png and b/content/learning-paths/servers-and-cloud-computing/rag/config-diagram-dark.png differ diff --git a/content/learning-paths/servers-and-cloud-computing/rag/config-diagram.png b/content/learning-paths/servers-and-cloud-computing/rag/config-diagram.png index 494aa07c2c..01fc738ce5 100644 Binary files a/content/learning-paths/servers-and-cloud-computing/rag/config-diagram.png and b/content/learning-paths/servers-and-cloud-computing/rag/config-diagram.png differ diff --git a/themes/arm-design-system-hugo-theme/layouts/partials/demo-components/config-rag.html b/themes/arm-design-system-hugo-theme/layouts/partials/demo-components/config-rag.html index d5dcac1876..0f266dce4a 100644 --- a/themes/arm-design-system-hugo-theme/layouts/partials/demo-components/config-rag.html +++ b/themes/arm-design-system-hugo-theme/layouts/partials/demo-components/config-rag.html @@ -22,7 +22,10 @@

RAG Vector Store Details

-

This app uses all data on this site, learn.arm.com, as the RAG data set. The Markdown formatted content across Learning Paths and Install Guides was segmented into labeled chunks, and vector embeddings were generated. FAISS is used for the embedded similarity search. The LLM demo below references this vector store for your query.

+

This application uses all data on learn.arm.com + as the RAG dataset. The content across Learning Paths and Install Guides is segmented into labeled chunks, + and vector embeddings are generated. + This LLM demo references the FAISS vector store to answer your query.

Note: Data was sourced on {{.Params.rag_data_cutoff_date}}.

diff --git a/themes/arm-design-system-hugo-theme/layouts/partials/demo-components/llm-chatbot/javascript--llm-chatbot.html b/themes/arm-design-system-hugo-theme/layouts/partials/demo-components/llm-chatbot/javascript--llm-chatbot.html index 8ceb165680..fdbefbf28c 100644 --- a/themes/arm-design-system-hugo-theme/layouts/partials/demo-components/llm-chatbot/javascript--llm-chatbot.html +++ b/themes/arm-design-system-hugo-theme/layouts/partials/demo-components/llm-chatbot/javascript--llm-chatbot.html @@ -232,6 +232,38 @@ const renderer = new marked.Renderer(); + renderer.link = (link) => { + // Extract the link parts + const href = link.href; + const text = link.text; + const title = link.title; + + // Escape href to prevent XSS attacks + const escapedHref = href + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + + // Escape title if it exists + const escapedTitle = title + ? title + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + : ''; + + // Create the link element with target="_blank" + return ` + + ${text} + + `.replace(/\n\s+/g, ''); // Remove unnecessary newlines and spaces + }; + // Customize the code block rendering renderer.code = (code, language) => { var language = code['lang'];