지난달이 며칠인지는 코드가 정했다
맥북(M5, 24GB) 안에서 도는 로컬 모델로 개인 메일을 찾아 요약하게 했습니다. 모델은 Ollama 로 띄우고, 메일은 맥 밖으로 내보내지 않습니다. 메일함 1년치 4,246통을 IMAP 으로 받는 데 2분, 의미 검색에 쓸 임베딩을 만드는 데 5분이 걸렸습니다.
질문 하나는 네 단계를 거칩니다. 모델이 질문을 검색어 JSON 으로 바꾸면, 키워드 검색과 임베딩 검색을 섞어 후보 12통을 고릅니다. 모델이 메일마다 한두 문장으로 메모하면서 관련 없는 메일은 버리고, 남은 메모를 근거 번호가 달린 답으로 합칩니다. 모델에게는 도구를 하나도 주지 않았고, 메일 본문 안의 지시는 따르지 말라고 지시문에 적었습니다. 전체 구성은 프로젝트 카드에 있습니다.
이 일에서 가장 많이 고친 것은 모델이 아니었습니다. 무엇을 모델에 맡기고 무엇을 코드가 정할지, 그 경계를 여러 번 옮겼습니다.
지난달이 며칠인지 모델은 몰랐다
처음에는 기간도 모델이 정했습니다. 검색어 JSON 에 며칠 전까지 볼지를 넣게 했더니, 모델들은 "지난달"을 30일이나 31일로 옮겼습니다. 10월 14일에 물으면 9월 중순부터 오늘까지가 되어 이번 달 메일이 지난달 결제 내역에 섞였습니다. 4b 모델 하나는 "지난달"을 8월로 알아듣고 "8월 결제 없음"으로 답을 시작했습니다.
"최근"도 비슷했습니다. 쇼핑몰에서 최근 주문한 것을 물었더니 후보 가운데 가장 새 메일이 8월 10일이었고, 모델은 그것을 최근 주문으로 답했습니다. "내가 보낸 메일"은 모델이 보낸 사람을 나로 옮기지 못해서 받은 메일만 골랐습니다.
셋 모두 정답이 하나뿐인 일이었습니다. 기간 계산을 코드로 옮겨 "지난달"은 지난달 1일부터 말일까지로 정했습니다. "최근"이나 "요즘"이 있으면 60일 안에서 새것부터 고르고, "내가 보낸"이면 보낸편지함만 봅니다. 고친 뒤 기간이나 보낸편지함이 걸린 다섯 질문을 다시 돌리니 모두 맞는 기간의 메일을 후보로 골랐고, 12b 모델로 돌려도 같았습니다. 질문당 시간은 17~35초로 고치기 전과 비슷했습니다.
모델에게는 말을 다루는 일만 남겼습니다. 질문에서 검색어를 뽑고, 메일 한 통을 읽어 메모하고, 메모를 묶어 답을 쓰는 일입니다. 날짜와 메일함을 고르는 것처럼 답이 하나로 정해지는 일은 코드가 합니다.
두 글자 검색어는 색인에 걸리지 않았다
키워드 검색에는 SQLite 의 전문 검색을 쓸 생각이었습니다. 세 글자 단위(trigram)로 색인하는 방식인데, 한국어 검색어는 "결제", "배송", "주문"처럼 두 글자가 많습니다. 짧은 문장 하나를 넣고 재 보니 "결제"가 전문 검색으로는 0건, LIKE 로는 1건 나왔습니다.
개인 메일함 규모라면 색인 없이 전부 훑어도 됩니다. LIKE 로 제목과 보낸 사람, 본문을 훑어 제목이나 보낸 사람에서 맞으면 3점, 본문에서 맞으면 1점을 주고, 이 순위를 임베딩 순위와 섞습니다. 비교 실행 72번에서 검색 단계는 가장 길어도 1.1초였습니다. 질문 하나에 드는 시간은 대부분 메일마다 메모를 쓰는 단계에서 나왔고, 모델 6종 모두 전체의 64~76%였습니다.
같은 12문항으로 모델 6종을 쟀다
질문 12개는 메일함의 보낸 사람 분포를 보고 정했습니다. 결제, 쇼핑 배송, 항공 마일리지, 구독 요금, 전자책 구매, 계정 보안, 뉴스레터, 행사 일정, 내가 보낸 메일을 묻고, "요즘 챙길 것" 같은 애매한 질문도 섞었습니다. 모든 모델에 같은 지시문과 온도 0, 문맥 8,192 토큰을 주고 생각 모드를 껐습니다. Ollama 는 문맥을 따로 주지 않으면 4,096 토큰으로 잡습니다.
gemma4 e4b 는 틀림 0건에 질문당 24초, gemma4 12b 는 틀림 0건에 62초였습니다. qwen3.5 9b 와 4b 는 1건씩 틀렸고 47초와 48초가 걸렸습니다. qwen2.5 7b 는 3건에 51초였고, 한국어 전용 모델인 exaone3.5 7.8b 가 4건에 60초로 가장 많이 틀렸습니다. 해외 쇼핑몰 주문 여섯 건의 배송 단계를 하나도 섞지 않고 정리한 모델은 e4b 하나였습니다. e4b 는 보낸 메일을 찾지 못했을 때도 지어내지 않고, 정리할 수 없다고 밝혔습니다.
틀림을 세는 쪽도 먼저 확인했습니다. 기계 채점은 메모의 숫자가 그 메일 본문에 있는지, 답의 숫자가 그 줄에 단 근거 메모에 있는지를 셉니다. e4b 는 답에 쓴 숫자 321개가 모두 근거에 있었습니다. 이 비율은 숫자를 지어냈는지만 잡고, 빠뜨린 것이나 근거를 엇갈려 단 것은 잡지 못합니다. exaone 은 메모 숫자 133개가 모두 맞았지만, 구독 결제 안내를 빠뜨린 채 구체적인 안내가 없다고 답했습니다.
기계 채점만으로는 모자라서 답 144개를 근거 메일과 맞춰 읽고, 사실이 틀렸거나 질문을 잘못 알아들은 것을 셌습니다. 이 판정은 Claude 가 혼자 했고 사람이 다시 보지 않았습니다. 모델마다 한 번씩만 돌렸으니 0건과 1건의 차이는 우연일 수 있습니다. 3~4건인 두 모델이 아래라는 것까지가 비교적 믿을 만한 결론입니다.
다시 재야 할 일이 두 번 생겼다
한 번은 실수였습니다. 검색을 고친 뒤 재시험을 기본 결과 폴더로 돌려 gemma4 두 모델의 1차 결과를 덮어썼습니다. 고치기 전 검색으로 되돌리는 스위치를 넣고 두 모델을 다시 돌렸고, 12b 평균이 62.8초에서 62.0초로 바뀐 것 말고는 둘 다 틀림 0건 그대로였습니다. 지금은 실행할 때마다 결과 폴더를 따로 정합니다.
다른 한 번은 모델이 바뀌어서였습니다. 10월 15일에 e4b 를 기본으로 정하고 e4b, 12b, 임베딩 모델만 남겨 모델 저장 공간을 45GB 에서 17GB 로 줄였습니다. 이튿날 다른 이유로 e4b 를 지우면서 메일 기본은 12b 로 옮겼습니다. 틀림은 똑같이 0건이고, 느린 것을 받아들였습니다.
e4b 자리에 들어온 같은 크기의 파생 모델도 같은 12문항으로 재 봤습니다. 주문 하나를 '준비 중'과 '운송 중' 양쪽에 넣어 1건 틀렸고, 질문당 50초로 원래 e4b 의 두 배였습니다. 메일에는 쓰지 않기로 했습니다. 문항과 채점 방법이 남아 있어서 새 모델 하나를 다시 돌리는 데는 10분이면 됐습니다.
메일은 링크 너머에 둔다
휴대폰에서는 텔레그램 봇으로 묻습니다. 텔레그램 대화는 텔레그램 서버에 남고 계정이 털리면 누구든 봇에게 메일을 물을 수 있어서, 봇은 메일 일을 웹 화면에 맡기고 "요약 준비됨"과 링크만 보냅니다. 링크는 사설망 안에서만 열리고, 작업 상태를 알려 주는 API 도 메일 내용은 주지 않습니다. 웹 화면은 질문이 든 요청 줄을 기록에 남기지 않습니다.
코드 리뷰에서 두 가지를 더했습니다. 요청의 Host 가 허용한 주소가 아니면 거절해 DNS 리바인딩을 막고, POST 는 Origin 이 이 화면 주소가 아니거나 다른 사이트에서 온 요청이면 거절합니다. 휴대폰에서 사설망으로 링크를 여는 것은 아직 직접 확인하지 못했습니다.
정리하면
정답이 하나인 일은 모델에 맡기지 않습니다. "지난달"과 "내가 보낸"을 코드가 정하자 후보를 잘못 고르던 질문 다섯 개가 모두 맞는 메일을 찾았습니다.
검색어의 생김새부터 봅니다. 두 글자 낱말이 많은 한국어에는 세 글자 단위 색인이 맞지 않았고, 개인 메일함은 전부 훑어도 1초 남짓이었습니다.
채점기가 무엇을 못 보는지 알고 씁니다. 숫자 근거율은 지어낸 숫자만 잡아서, 빠뜨린 답은 근거 메일과 맞춰 읽어서 셌습니다.
문항을 남겨 두면 다시 재는 일이 싸집니다. 기본 모델이 이틀 만에 바뀌었을 때 같은 12문항으로 10분 만에 다시 쟀습니다.
답이 없을 때 지어내는 대신 비워 두기로 한 다른 결정은 지어낸 답보다 빈칸이 낫다에 있습니다.
I had local models running on a MacBook (M5, 24GB) search and summarise my personal email. The models are served with Ollama, and the mail never leaves the Mac. Fetching a year of the mailbox, 4,246 messages, over IMAP took 2 minutes, and building the embeddings for semantic search took 5.
Each question goes through four steps. The model turns the question into a search JSON, and a blend of keyword and embedding search picks 12 candidate messages. The model writes a one- or two-sentence note on each message, discarding the irrelevant ones, then merges the remaining notes into an answer with numbered citations. The model was given no tools at all, and its instructions say not to follow any instructions found inside a message body. The whole setup is on the project card.
What I changed most in this work was not the model. I moved the line between what the model handles and what the code decides, again and again.
The model did not know how long last month was
At first the model set the time range too. When I had it write how many days back to look into the search JSON, the models turned "last month" into 30 or 31 days. Asked on October 14, that meant mid-September through today, so this month's mail got mixed into last month's payment history. One 4b model took "last month" to mean August and opened its answer with "no payments in August".
"Recently" went much the same way. Asked what I had recently ordered from a shopping site, the newest candidate was from August 10, and the model gave that as the recent order. For "mail I sent", the model failed to turn the sender into me, so only received mail was picked.
All three were jobs with exactly one right answer. I moved the date arithmetic into code and fixed "last month" as the 1st through the last day of the previous month. If "recently" or "these days" appears, it picks newest first within 60 days, and for "I sent" it looks only at the Sent folder. After the fix I reran the five questions involving a time range or the Sent folder: all of them picked candidates from the right period, and the same held with the 12b model. Time per question was 17–35 seconds, about the same as before the fix.
The model was left only with the work of handling language: pulling search terms out of the question, reading one message and noting it, and bundling the notes into an answer. Work with a single fixed answer, like choosing dates and mailboxes, is done by code.
Two-character search terms did not hit the index
For keyword search I planned to use SQLite's full-text search. It indexes in three-character units (trigram), but Korean search terms are often two characters long, like 결제 (payment), 배송 (delivery) and 주문 (order). Testing with a single short sentence, 결제 returned 0 hits with full-text search and 1 with LIKE.
At the scale of a personal mailbox, scanning everything without an index is fine. LIKE scans the subject, sender and body, giving 3 points for a match in the subject or sender and 1 point for a match in the body, and this ranking is blended with the embedding ranking. Across 72 comparison runs, the search step took 1.1 seconds at most. Most of the time per question went into the step that writes a note for each message: 64–76% of the total, for all six models.
Six models on the same 12 questions
I chose the 12 questions by looking at how senders were distributed in the mailbox. They ask about payments, shopping deliveries, airline miles, subscription fees, e-book purchases, account security, newsletters, event schedules and mail I sent, with vague ones like "what should I keep an eye on these days" mixed in. Every model got the same instructions, temperature 0 and an 8,192-token context, with thinking mode off. Unless told otherwise, Ollama sets the context to 4,096 tokens.
gemma4 e4b made 0 errors at 24 seconds per question, and gemma4 12b made 0 errors at 62 seconds. qwen3.5 9b and 4b made 1 error each and took 47 and 48 seconds. qwen2.5 7b made 3 at 51 seconds, and exaone3.5 7.8b, a Korean-specialised model, made the most: 4 errors at 60 seconds. e4b was the only model that laid out the delivery stages of six orders from an overseas shopping site without mixing up a single one. When it could not find sent mail, e4b did not invent any either, and said it could not summarise it.
I checked the side counting the errors first, too. The automatic grader counts whether the numbers in a note appear in that message's body, and whether the numbers in an answer appear in the notes cited on that line. All 321 numbers in e4b's answers were in the cited evidence. This ratio only catches invented numbers; it misses omissions and mismatched citations. All 133 of exaone's note numbers were correct, yet it left out a subscription payment notice and answered that there was no specific notice.
Automatic grading was not enough, so the 144 answers were read against their source messages, counting those with wrong facts or a misread question. Claude made this judgement alone, and no person reviewed it again. Each model ran only once, so the difference between 0 and 1 error may be chance. The fairly reliable conclusion goes only as far as the two models with 3–4 errors being at the bottom.
Twice I had to measure again
Once was a mistake. After fixing the search, I ran the retest into the default results folder and overwrote the first-round results of the two gemma4 models. I added a switch that reverts to the pre-fix search and reran both models; apart from the 12b average moving from 62.8 to 62.0 seconds, both still had 0 errors. Now each run gets its own results folder.
The other time was because the model changed. On October 15 I made e4b the default and kept only e4b, 12b and the embedding model, cutting model storage from 45GB to 17GB. The next day e4b was removed for a different reason, and the mail default moved to 12b. Errors are the same at 0; I accepted the slowness.
A derivative model of the same size that took e4b's place was measured on the same 12 questions too. It put one order under both "preparing" and "in transit", for 1 error, and took 50 seconds per question, twice the original e4b. I decided not to use it for mail. Because the questions and grading method had been kept, rerunning one new model took just 10 minutes.
The mail stays behind a link
On the phone I ask through a Telegram bot. Telegram conversations stay on Telegram's servers, and if the account were compromised anyone could ask the bot about my mail, so the bot hands mail work to the web page and sends only "summary ready" and a link. The link opens only inside the private network, and the API that reports job status does not return mail content either. The web page does not log the request line that carries the question.
Code review added two more things. A request whose Host is not an allowed address is refused, blocking DNS rebinding, and a POST is refused if its Origin is not this page's address or if it comes from another site. Opening the link over the private network from the phone is something I have not checked directly yet.
In short
Work with one right answer is not left to the model. Once code decided "last month" and "I sent", all five questions that had been picking the wrong candidates found the right mail.
Look at the shape of the search terms first. A three-character index did not suit Korean, with its many two-character words, and scanning a whole personal mailbox took about a second.
Know what the grader cannot see. The number-evidence ratio only catches invented numbers, so omitted answers were counted by reading against the source messages.
Keeping the questions makes measuring again cheap. When the default model changed within two days, the same 12 questions measured it again in 10 minutes.
Other decisions to leave a blank rather than invent an answer are in Empty-Handed Beats Invented.