Why I built it
In a security investigation, an answer needs a source someone else can check. If I ask how an incident should be classified, I want to see the policy passage that supports the answer. I built LocalSecAI on my M2 MacBook to find out what it takes for a local assistant to do that reliably.
Starting with a small set of security notes gave me a collection I could check by hand. I could write questions with known answers, identify the passages I expected the assistant to find, and see where a wrong answer came from. Running it locally also let me see how much work my laptop could handle as the index grew.
What I built
I split the notes into searchable passages. I combined keyword search, which is useful for exact terms such as policy names, with semantic search, which helps when a question uses different wording from the source. A reranker then sorted the candidate passages before the model received them.
I treated search and answer generation as separate stages. For a given question, I wanted to know which passages were found, which were passed to the model, and whether the answer pointed back to the right evidence.
Where it broke
One test asked for the severity levels in a sample incident policy. The search step found the right document and ranked it first. Then the reranker, which was supposed to improve the results, threw it out. Once I got the right document back into the answer, I hit a separate problem: the model could give a correct answer without citing its source.
Those two failures called for different fixes. The first was a ranking decision. The second was a problem with how the answer was produced and checked.
What I changed
I tested search and answer generation separately. For search, I added a fallback for cases where both search methods ranked the same document first, but the reranker rejected it. For answers, I used structured output so the app could check that references pointed to passages it had retrieved. A valid reference alone doesn’t prove the passage supports the answer, so I evaluated answer accuracy separately.
I also tested questions the notes couldn’t answer. For those, saying there wasn’t enough evidence was the expected result. That gave me three things to check in a run: whether the assistant found the right passage, whether it used the passage correctly, and whether it could recognize when the collection didn’t cover the question.
I started with seven questions as a quick regression check. A follow-up run used 17 questions against a more varied collection. I scored answerable questions and questions without supporting evidence separately.
What changed as the index grew
Once I could check the answers and citations, I wanted to see how search behaved with a larger collection. I indexed 1,100 passages in Qdrant and ran 30 hybrid retrieval requests with a cold keyword cache and another 30 with a warm cache. I checked that the rankings matched across both runs before comparing latency.
That benchmark times retrieval. Generating the answer is a separate step.
What I’d test next
I’d build a larger set of questions and keep it separate from the examples I use to tune the system. It would include paraphrased questions, questions that need evidence from several documents, questions with missing evidence, and cases where two versions of a policy conflict. I’d report source retrieval, answer correctness, citation correctness, and appropriate abstention separately so I can see where failures occur.
Back to selected work