Houjun Lab
Houjun Lab / Private document search
Research project · document search · question answering (RAG)

Ask your own documents,
and see where each answer came from.

Most of what an organisation knows sits in reports, manuals and records that cannot be sent to a cloud service. This study built a document assistant that runs entirely on one Mac: it finds passages by meaning, even when the question is in another language, and a local model answers only from those passages, names the source of every statement and says so when the documents do not contain the answer.

Results Code on GitHub CompletedFinal results below · September 2026.

The answer, in three numbers

8 / 8questions in Chinese, Japanese and English that found the right project first, among 487 passages
6.4 sfrom question to a cited answer, on average, with both models loaded fresh each time
0network calls: documents, questions and answers never leave the machine

What this means for real work

Two models work together: one finds the material, the other writes the answer. Neither is retrained on your data, so documents can be added or removed at any time.

Search by meaning, not by matching words

The question and the document do not need to share a single word. Every test question was deliberately worded differently from the text it should find, and Japanese and English questions found Chinese reports.

Every answer can be checked

Each statement points to a file, a section and line numbers, and the exact passages the model saw are saved with the answer, so a person can verify it in seconds.

It says when it does not know

If the retrieved passages do not contain the answer, the system replies with a fixed sentence instead of guessing. One test cannot prove it always will, so this is tested on purpose.

It fits on hardware you can own

Search and answers ran on one Mac Studio with 32 GB of memory, peaking at about 5.2 GiB. Nothing was sent to an outside service at any step.

How it works

Retrieval-augmented generation (RAG): first retrieve the relevant passages, then generate an answer from them alone.

  1. Cut documents into passages

    Each passage keeps its project, file path, section title and line numbers, so every result can be traced back.

  2. Turn each passage into a vector

    A small embedding model (Qwen3-Embedding-0.6B, 8-bit, 1,024 dimensions) maps each passage, with its title, to a list of numbers that captures its meaning. The index is saved, so this is done once.

  3. Find the closest passages

    The question is mapped the same way and compared with every passage. At most five are kept, no more than two from one file.

  4. Answer from those passages only

    A local answer model writes the reply with a source mark on every factual line, in the language of the question, or declines.

Results

In one paragraph

On 68 real research documents in Chinese, Japanese and English, the search step found the right project first for every one of eight questions, including Japanese and English questions about Chinese text. The full system then answered four test questions correctly with sources, in the language they were asked in, in about six seconds each, and declined to answer a question its documents could not answer. It took three failed rounds to get there, and all three are kept.

How to read the numbers

Recall@1 counts how often the right material was the first result; Recall@3, how often it was in the first three. Similarity scores only rank results within one question: a score of 0.65 does not mean "65% likely to be right".

1. Titles matter more than expected

A first, small test used 12 short passages and nine questions worded differently from the text (five Chinese, three Japanese, two English). Indexing the body text alone put the right passage in the top three every time, but first only six times out of nine. Indexing each passage together with its title put it first in all nine, at the same speed. Real document systems should index titles and section paths with the text, not the text alone.

Right passage ranked first, out of 9 questions

Right passage ranked first, out of 9 questionsBars. Body text only: 6 of 9 ranked first. Title plus body: 9 of 9. Both had all 9 in the top three. 0 3 6 9 Body text only 6 / 9 Title + body 9 / 9 questions with the right passage first · both 9 / 9 in the top three

2. Real documents: the right topic every time, not always the right report

The index then took every README, design note and result report in the lab: 68 files cut into 487 passages, each stored with its project, file path, section and line numbers. Building it took 59 seconds, peaked at 5.4 GiB of memory and produced a 5.3 MB index file. Eight new questions in three languages found the right project first, eight out of eight, in under a second each.

The one designated source report was in the top three only five times out of eight. In each miss, the same fact also appears in later reports and summaries, so the search returned a correct passage from a different document. A meaning-based search knows what a passage is about; it does not know which document your organisation treats as authoritative. That needs a second ranking step (keywords, dates, document type or a reranker), which we did not hard-code to pass this test.

The numbers
MeasureResult
Files indexed68 (README, design notes and result reports)
Passages487, up to about 1,400 characters each
Build time59.4 s, peak memory 5.42 GiB, no swap
Index size5.3 MB (1,024 numbers per passage)
Right project first (Recall@1)8 / 8
Designated report in top three5 / 8
Search time per questionunder 1 s

3. Answers with sources, and a refusal

For answers, the search results go to a separate local model (Qwen3-4B-Instruct, 8-bit). It sees at most five passages, no more than two from one file and 7,000 characters in total, and must mark every factual line with its source, such as [S1]. Text inside the documents is treated as data, never as instructions. If the passages do not contain the answer, it must reply with a fixed sentence saying so.

Seconds per answer

Seconds per answerStacked view as separate bars: search 0.88 seconds, answer 5.52 seconds, total 6.41 seconds on average. 0 2 4 6 Search (meaning-based) 0.88 s Write the answer 5.52 s Total, question to cited answer 6.41 s average of four test questions · both models loaded fresh each time
The four test questions
QuestionLanguageWhat it testsResultTime
Why did the cat-blink video only partly succeed?ChineseExplain a finding from the video studyPass7.3 s
Is "TP" on the receipt part of the item name or its own column?JapaneseRead a detail from the receipt studyPass7.3 s
How did throughput and delay change with four parallel requests?EnglishQuote numbers correctly (+8.2%, 4.55 s → 16.79 s)Pass6.9 s
Where was the item bought, and for how much?ChineseRefuse when the documents do not sayPass (refused)4.1 s

The search model and the answer model never run at the same time, so peak memory stayed at 5.2 GiB with no swapping. A human read all four final answers: each core statement is supported by the cited passage; the Japanese answer is correct but wordy.

4. The three rounds that failed

  • Round 1, 3 of 4. The Japanese answer had the right fact but slipped into Chinese, and its citation format wandered.
  • Round 2, 2 of 4. Japanese improved; the English answer then drifted into Chinese, and our own checker rejected a correct Chinese answer worded differently from what it expected.
  • Round 3, 3 of 4. All three languages were right; one answer failed only because the model wrote [ S1 ] with spaces.

The fixes were an explicit answer-language instruction per question, a checker that accepts real synonyms, and tidying of spaces inside citation brackets only, each covered by unit tests. Two of the three failures were in our test, not in the model: the check has to be tested too.

5. Where this started

An earlier version, built in the local language model study, used keyword search (BM25) with a 14-billion-parameter model. Keywords are exact for numbers and names but miss a question phrased in other words or another language. That gap is why this study added meaning-based search; the practical next step for larger collections is to use both together.

Limits

What these results do not show.

  • The citation check confirms that every statement points to a real source; it cannot prove that each sentence is fully supported by it. A real system still needs people to sample and review answers.
  • The collection was small: about 70 documents. Larger collections need keyword and meaning-based search combined, and usually a reranking step.
  • The answer model is small (4 billion parameters). It sometimes drifted into another language or wrote wordy answers; larger models and explicit language control reduce this.
  • Both models were loaded for every question, which suits occasional use. A service for many users would keep them running, and would be faster.
  • One refusal test passed. That shows the behaviour exists, not that every unanswerable question will be refused.
  • Nothing was trained here. Teaching a model new material is a different method, measured in MedAdapt Lab.

Code and licence

The study's scripts, test material, raw measurements and phase reports are open source under the Apache License 2.0, as part of the AI-Lab repository. Model weights are not included; each keeps its publisher's licence and is downloaded separately at a pinned revision with a checked SHA-256. See the licence page.