Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

8 November 2026 · Practical AI builds

How do I add a search box that understands meaning to my own documents?

By the end of this you will have a small search box that finds passages in your own documents by what they mean, not just by the exact words you type. Search for "customer wants money back" and it will find the note that says "refund request". It suits anyone with a pile of notes, policies or help pages who is tired of keyword search missing things.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

What you need

Step by step

  1. Put all the documents you want to search into one folder as .txt or .md files, so there is one place to read from.
  2. Split each document into chunks of a paragraph or two. Models like this only read a limited amount of text at once and quietly ignore the rest, and short chunks also give more precise results.
  3. Keep the file name (and a heading if you have one) with every chunk, so a result can tell you where it came from.
  4. Create a Python virtual environment and install the library with pip install sentence-transformers. The model downloads itself the first time you use it.
  5. Turn every chunk into an embedding. An embedding is a list of numbers that describes what the text is about, so texts with similar meaning end up with similar numbers.
  6. Save those embeddings to disk along with the chunks. You only need to do this once per document, not every time someone searches.
  7. When someone searches, turn their words into an embedding in the same way and compare it with the saved ones. Show the five closest chunks, with their file names and a similarity score.
  8. Once it works in the terminal, put a simple web form in front of it with a small framework such as Flask, and keep it private if the documents are.
  9. Re-run the embedding step whenever documents are added or changed. A nightly scheduled job does this without you having to remember.

Here is the core of it in a few lines, to show how little is involved:

from sentence_transformers import SentenceTransformer, util

model = SentenceTransformer("all-MiniLM-L6-v2")
chunks = ["Refund requests must be made within 30 days.",
          "Our van parks behind the hall on Saturdays.",
          "Invoices are sent by email at the end of each month."]

chunk_vecs = model.encode(chunks, convert_to_tensor=True)
query_vec = model.encode("customer wants money back", convert_to_tensor=True)

for hit in util.semantic_search(query_vec, chunk_vecs, top_k=2)[0]:
    print(round(hit["score"], 2), chunks[hit["corpus_id"]])

For a real folder you would read the chunks from your files and save chunk_vecs to disk, but the idea stays the same. Once you have this, it is a short step to a chatbot that answers from the same passages, which is covered in how to build a chatbot that answers from your own files. If the search page sits on a server, putting a simple password in front of a private web tool keeps it to the people it is meant for.

What good looks like

Test it with questions worded differently from your documents. If you search "staff holiday rules" and the top result is the paragraph headed "annual leave policy", it is working. Results should come back in well under a second for a few thousand chunks, and the scores for good matches should be clearly higher than for unrelated ones. Keep a short list of test searches with the answers you expect, and run them again after any change.

Watch out for

Questions people ask

Do I need a special vector database?

Not for a small collection. A few thousand chunks fit comfortably in a single file in memory, and a dedicated vector database only starts to pay off when you have far more text or many users.

Does it work in languages other than English?

The small model used here is trained mainly on English. There are multilingual embedding models that work the same way, so choose one of those if your documents are in several languages.

In short, you turn your documents and each search into embeddings, compare them, and show the closest passages with their sources. It takes a free model, a few lines of Python and a regular refresh to find notes by what they are about.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Related AI builds: How do I build a chatbot that answers from my own files? · How do I build a simple AI assistant for my team's shared documents? · How do I choose between a hosted AI model and one I run myself? · All daily notes