Building a Local Perplexity Alternative with Perplexica, Ollama, and SearXNG

Olares
5 min readJul 31, 2024

--

You’ve probably heard of Perplexity, the AI search engine that’s been making waves. Compared to traditional searching, it provides concise, synthesized answers to queries rather than just a list of links to boost efficiency and productivity. However, Perplexity’s unique capability comes with a price tag — $20 a month for the Pro Search, with free users limited to just 5 pro searches a day.

But what if you could build something similar on your own hardware, without monthly fees or usage limits? In this guide, we’ll walk you through the process of creating your local Perplexity alternative using Terminus, an open-source, self-hosted operating system based on Kubernetes, along with other powerful open-source AI tools.

Recreating Perplexity’s workflow

Before we dive into our self-hosted solution, let’s briefly explore how Perplexity works. Note that this is a simplified version, the actual workflow is much more sophisticated.

Perplexity workflow
  1. User sends a question to Perplexity.
  2. Perplexity understands the question and sends it to search engines like Google
  3. Google searches the web in real-time.
  4. Google returns sorted results to Perplexity.
  5. Perplexity creates a prompt using the question and results and sends it to an AI model like OpenAI’s GPT-4.
  6. AI compiles everything into a coherent answer.

This workflow boils down to three key components:

  • Perplexity as the AI search platform and interface.
  • Google as the search engine.
  • OpenAI as the AI model provider.

To recreate this, we will replace them with open source tools:

Local AI search engine workflow
  • Ollama: A popular open-source project that enables users to host large language models like Gemma2.
  • SearXNG: An open-source, privacy-respecting internet metasearch engine, fetching real-time results from the web.
  • Perplexica: An AI-powered search engine that ties everything together.

Why deploy on Terminus?

Compared to regular installation methods, Terminus provides a more streamlined, user-friendly experience for users looking to self-host applications:

  • Simple and fast deployment
    Terminus offers one-click installations for apps like Ollama and Perplexica through its marketplace. This allows for rapid deployment and testing of new projects.
  • Flexible app and service combination
    Applications and services in Terminus can be deployed once and flexibly assembled as needed. This allows for easy experimentation with different configurations and service combinations without complex redeployments.
  • Anywhere access with a unique domain name.
    Terminus provides a dedicated domain name for each application and service out-of-the-box, enabling access from any device with a browser.

Prerequisites

  • A Windows (Windows 10 or 11) or Linux PC, with a Nvidia GPU
  • Terminus installed. Please refer to the Quick Start guides to install Terminus.

Step-by-step guide

Take the steps below to build your local AI engine on Terminus.

Step1: Launch Terminus

Launch Terminus from your browser, and open Terminus Market from the desktop.

Note: You can access Terminus using your personal domain name in any browser.

Terminus Market

Step 2: Install the apps

  1. In Market, find Ollama, SearXNG, and Perplexica.
  2. Click Get under each app to install them. Wait until installation finishes.

Step3: Configure Ollama

Configure Ollama with the AI model. For our setup here, we will use Gemma2, Google’s latest open-source language model.

Configure Ollama
  1. Open Ollama from launcher.
  2. Navigate to Admin Panel > Models > Pull a model from Ollama.com, and select gemma2:27b as the target model to pull.
  3. Click the download button on the right to start pulling the model. Exit the app when the pulling completes.

Step 4: Configure Perplexica

We are almost ready. Let’s configure Perplexica, the glue that ties everything together.

  1. Open Perplexica from launcher.
  2. In the Settings window, specify as shown in the screenshot.
Configure Perplexica

Since we have already installed Ollama with Gemma2, they will appear as default options here. Congratulations, you just get your self-hosted Perplexity alternative.

Step 5: Test your local AI search engine

Let’s try by asking the same question on Perplexica and Perplexity and make an apple-to-apple comparison.

Answer by Perplexica
Answer by Perplexity

As you can see, we asked the same question “why selfhsoting”. While the processing time, info length and details vary due to different models and tech stacks, the answer by Perplexica is acceptable considering the benefits of self-hosting.

Tip: you can access your self-hosted Perplexica from your phone anywhere, thanks to the dedicated domain provided by Terminus.

Conclusion

By leveraging Terminus and open-source tools like Ollama, SearXNG, and Perplexica, you can create a powerful, self-hosted AI search engine similar to commercial offerings like Perplexity. This setup not only saves you money but also gives you control over your data and search experience.

We encourage you to experiment with your setup, try different language models, and customize your AI search engine to fit your unique needs.

In our future sessions, we’ll explore setting up other exciting AI projects like Dify and Open WebUI on Terminus. In the meantime, you can keep an eye on the Terminus project on GitHub for updates and new features if you like what we are doing.

Happy self-hosting!

--

--

Olares
Olares

Written by Olares

Olares is your open-source, self-hosted alternative to public clouds. Official website: olares.xyz GitHub: https://github.com/beclab/Olares