SabaKore

Home / Articles / AI guides

Building Self-Hosted AI Search on a VPS

This article covers the overall setup when you run your own system that lets AI search your documents and site content, and when to choose that over leaving search to an external service.

Ren, a junior infrastructure engineer

Ren

I want to build a feature where the AI searches the contents of my own site and generates answers. Can I host all of it myself?
Procura, a cloud AI robot who explains

Procura

You can. If you combine RAG (a mechanism where the AI searches documents first and then answers) with vector search (search that finds text by closeness in meaning), you can keep a feature that searches your site and documents entirely inside your VPS.

Overall setup

  • Split the content of your site and documents into pieces for searching, and store them
  • Receive the user's question and find the relevant pieces
  • Have the AI generate an answer based on the pieces it found
Ren, a junior infrastructure engineer

Ren

What's the difference between using an external search service and hosting it myself?
Procura, a cloud AI robot who explains

Procura

An external service is easy to start with, but you hand over the data to be searched to the other party. If you host it yourself, you don't have to send that data outside your VPS. But you'll do the tuning to improve accuracy yourself.

Keeping up with updates

A site's content keeps being updated, so you need a mechanism to update the search data to match. Reflecting each update by hand isn't realistic, so build in from the start a mechanism that regularly rebuilds the search data automatically.

  • Update the search data automatically whenever the content is updated
  • Record the run results so you notice when an update fails
  • Delete the previous data when you rebuild, so old pieces don't stay behind

Mind what is publicly searchable

Wilson, the security guard

Wilson

If something is searchable, it can also be probed from outside. Have you accidentally included documents you never meant to make public in the search target? That's the first thing I'd try.
Procura, a cloud AI robot who explains

Procura

That's harsh, but true. Limit the data you include in the search target to what is fine to make public. If you handle internal information, put authentication in front so that only a limited set of people can use it.
Ren, a junior infrastructure engineer

Ren

If I feel the search accuracy is low, what should I review first?
Procura, a cloud AI robot who explains

Procura

When RAG gives poor answers, the cause is often in the search part rather than in the AI itself. Start by reviewing how you split the content and how many candidates you pass to the AI.

How to respond when nothing is found

If no piece relevant to the user's question is found and you force the AI to produce an answer, it may output groundless content that sounds plausible. When search results are thin, it damages users' trust less to honestly answer "No relevant information was found" than to present wrong information. Keep in mind that in some situations, saying you can't answer is safer than giving an answer.

  • If relevant pieces are scarce, don't force the AI to generate an answer
  • Prepare in advance a response that says "nothing was found"
  • If some category has many questions with no results, suspect that the documents themselves are lacking
Procura, a cloud AI robot who explains

Procura

The peace of mind of hosting it yourself comes together with the effort of managing what is public. If you're ready to take on both, I think it's a rewarding setup that lets you build a search experience that suits your own site.
Ren, a junior infrastructure engineer

Ren

So hosting it myself isn't automatically safe. Managing what's public is a separate job.

This article is translated from the Japanese original. If the two differ, the Japanese version is the one we keep up to date.