Part 1: AI Based Search using SearXNG, Ollama and Perplexia
Satish Srinivasan
Cloud Architect I Cloud Security Analyst I Specialist - AWS & Azure Cloud. AWS Community Builder| AWS APN Ambassador
AI-based search has revolutionized how we access and interact with information online. By leveraging advanced algorithms. These systems utilize machine learning and deep learning techniques to analyse vast amounts of data, improving accuracy and efficiency in retrieving information34. Additionally, AI-driven search capabilities extend beyond traditional web searches, influencing various applications including e-commerce, social media, and content streaming platforms by tailoring experiences to individual users5. As AI continues to evolve, its impact on search technology promises.
?In this blog we will be covering implementation of AI Based Search using Open-Source tools searxng, Ollama and Perplexia.
Key Features of AI based Search.
·???????? Natural Language Processing
·???????? Personalization
·???????? Multi-modal Search Capabilities
·???????? Continuous Learning
·???????? Semantic Search
We will be using the Open-source project “Perplexia†implemented by “Kushagra†and will be making necessary changes to use Ollama models. In the next part of this series, we will be rewriting the whole code base backend to support Bedrock.
We will not be covering the steps to create ec2 instance. we will assume this is already available. We will start from associating an Elastic IP to the EC2 instance and installing the required software’s.
?Prerequisites
- Security Groups
- EC2 instance
?
?Walkthrough
The EC2 instance is running. Let us first start with installing necessary software.
?
?Steps to install Docker.
?Steps to Install Docker compose.
?
?Steps to Install Make in Amazon Linx2 instance.
Steps to install git in Amazon Linx2 instance.
Steps to Install Searxng for AI Search engine.
?Steps to install Ollama and pull llama3 and Phi-4.
?
The EC2 instance is running. Now let us assign an elastic IP for the same.
Press “Allocateâ€.
Now associate this to the EC2 instance
Press “Associateâ€.
We have done the first part.
Let us connect to the instance via putty.
Let us install Docker and docker-compose
Next docker-compose.
Next, we will install the make and git in Amazon linux 2
?Next we will create a virtual environment and deploy Searxng and Ollama . In Ollama we will load llama3 and phi-4 model which we will use for AI based search.
?Create a Virtaul environment.
Load required packages.
Git clone the searxng source
under searx directory in settings.yml file, change following:
?search:
? formats:
??? - html
??? - json
???
Build the image.
领英推è
Deploy the container and test.Get the private IP address associated with the EC2 instance.
docker run --rm -d -p 8181:8080 -v "${PWD}/searxng:/etc/searxng" -e "BASE_URL=https://172.31.44.174:$PORT/" -e "INSTANCE_NAME=my-instance" searxng/searxng
We will test the Search engine.
?
This is up and running. Next, we will install Ollama and pull the required models.
Next, we will load the models llama3 and Phi-4
The container id for ollama is “c4dd74416228â€.
Next, we will test Ollama API server
Next, we will configure Perplexia and demonstrate AI based search.
In the Folder Perplexia we will have the file .env make the changes in the file as shown below.
.env file
First, we will test the search with Llama3 model.
Then build and run the backend and UI.
?Starting the backend and UI services.
For the backend
For the UI.
?
Let us open https://localhost:3000 from browser.
Ask the First Question
?
We will refine the search further and see if the Model is able to reason.
Let us check the Answer.
Next, we will repeat the test for Phi-4 model.
Make changes to the .env file.
Make the build and then run.
?Not very convincing.
In the next part, we will integrate Perplexia with AWS bedrock models. We will be modifying the full code base to use AWS Bedrock libraries. Additionally, we should also see how we can scrape data from Websites for analysing data that are controlled .
Cleanup
Stop all the services in ec2 instance and terminate the instance.
?