메뉴
HN
Hacker News 37일 전

Qwen 3 0.6B 모델 파인튜닝으로 질문 분류하기

IMP
6/10
핵심 요약

저자는 가사 관련 챗봇의 검색 정확도(RAG)를 높이기 위해 6억 개(0.6B)의 매개변수를 가진 초소형 로컬 LLM인 Qwen 3:0.6B를 파인튜닝하여 질문을 카테고리별로 분류하는 실험을 진행했습니다. 미세조정 전 원본 모델의 정답률은 10%에 불과했으나, Unsloth 프레임워크와 약 850개의 데이터를 활용해 학습을 진행하여 신뢰할 수 있는 분류기를 구축할 수 있었음을 보여줍니다.

번역된 본문

출처: 해커뉴스(hackernews) 제목: 흥미로운 지식 습득하기 - 로컬 LLM을 파인튜닝하여 질문 분류하기 게시일: 2026년 6월 16일 작가: Torgeir Helgevold

재미있는 개인 프로젝트로, 집안의 유지 보수 질문부터 병원 예약에 이르기까지 우리 집에 대한 일반적인 질문에 답하는 챗봇을 개발해왔습니다. 이 챗봇의 기본 아이디어는 벡터 데이터베이스를 쿼리하여 RAG(Retrieval-Augmented Generation)를 통해 가사 지식을 습득하는 것이지만, 더 나은 결과를 위해 벡터 검색에 메타데이터를 인식하도록 만들었습니다. 기본적으로 질문을 사전 처리 단계를 거쳐 알려진 메타데이터 카테고리(예: 수영장, 자동차, 냉난방, 요리)로 분류합니다. 이 방식의 주요 목적은 벡터 랭킹의 검색 공간을 좁혀, 질문 카테고리와 일치하는 인덱스된 항목만 검색하는 것입니다. 예를 들어, "수영장 펌프를 언제 교체했나요?"라는 질문은 인덱스 데이터베이스를 쿼리하기 전에 "수영장"이라는 카테고리로 매핑됩니다. 이 실험에서 테스트하고자 하는 가설은 가사 관련 질문 데이터셋으로 학습시켰을 때, 매우 작은 로컬 LLM을 파인튜닝하여 신뢰할 수 있는 질문 분류를 수행할 수 있는지 여부입니다.

LLM (대형 언어 모델) 이 프로젝트에서는 Qwen 3:4B와 Qwen 3:0.6B라는 두 가지 다른 로컬 LLM을 사용하고 있습니다. 4B 매개변수 버전은 일반적인 질의응답에 사용되며, 초소형인 0.6B 버전은 질문을 분류하는 데 사용됩니다. 이 실험의 전제는 오직 6억 개의 매개변수를 가진 초소형 LLM을 가사 질문의 신뢰할 수 있는 분류기로 파인튜닝할 수 있는지 확인하는 것입니다.

파인튜닝 (Finetuning) 파인튜닝에는 Qwen 및 Llama와 같은 로컬 모델을 튜닝하는 데 적합해 보이는 Unsloth라는 인기 있는 오픈소스 프레임워크를 사용하고 있습니다. 학습 목적으로 초기 데이터셋은 약 850개의 데이터 항목으로 구성되며, 이를 각각 학습 데이터, 평가 데이터, 테스트 데이터로 70/15/15 비율로 분할했습니다. 학습 데이터와 평가 데이터는 훈련 중에 사용되며, 테스트 데이터셋은 보류되었다가 학습이 끝난 후 테스트를 실행하는 데 사용됩니다. 아래 섹션에서 샘플 데이터를 확인하세요:

[ { "question": "Who cleans our gutters at the house?", "category": "gutters" }, { "question": "Who serviced the hot water heater for the home?", "category": "water heater" }, { "question": "Who fixed the sprinkler system in the yard?", "category": "irrigation" }, { "question": "Which store do we usually buy pinnekjott from?", "category": "cooking" }, { "question": "What dimensions are the air filters for the home AC?", "category": "hvac" }, { "question": "What year did we replace the downstairs AC unit?", "category": "hvac" } ]

기본적인 아이디어는 충분한 양의 가사 질문 세트로 LLM을 학습시켜 신뢰할 수 있는 질문 분류기가 되도록 가르치는 것입니다.

베이스라인 (Baseline) 파인튜닝을 진행하기 전에 측정 기준이 될 베이스라인을 설정하는 것이 중요합니다. 이 실험에서 베이스라인은 프롬프트만 사용하여 원본 Qwen 0.6B 모델을 '있는 그대로' 사용해 보는 것입니다. 아래에서 베이스라인에 사용된 샘플 프롬프트를 확인할 수 있습니다:

아래 목록에서 정확히 하나의 카테고리로 주택 소유자의 질문을 분류하세요. 목록에서 카테고리 이름만 반환하세요. 코드, 숫자, 동의어, 설명 또는 기타 텍스트는 반환하지 마세요. 답변은 반드시 목록에 있는 정확히 하나의 카테고리 이름이어야 합니다. 질문의 의미를 기반으로 가장 적합한 카테고리를 선택하세요.

유효한 카테고리:

  • 어플라이언스
  • 벽돌 공사
  • 자동차
  • 요리
  • 초인종
  • 전기
  • 울타리
  • 분수
  • 정원 조명
  • 홈통
  • 냉난방
  • 관개
  • 모기
  • 페인트
  • 수영장
  • 나무 관리
  • 온수기
  • 창문 서비스

질문: 집의 온수 탱크리스 시스템을 누가 설치했나요? 카테고리:

베이스라인 모델의 정확도: 오프라인 평가 방법 중 하나로, 두 번째 데이터셋의 시나리오로 모델을 테스트하기 위해 약 130개의 통합 테스트 묶음을 만들었습니다. 베이스라인 모델의 경우 결과가 좋지 않습니다. 131개의 테스트 중 모델은 13개의 질문만 올바르게 분류했습니다(정확도 약 10%). 아래 요약을 참조하세요:

{ "scenario": "baseline-category", "model_kind": "baseline", "model_name": "qwen3:0.6b", "label_mode": "category", "total": 131,

원문 보기
원문 보기 (영어)
Teach Me Cool Stuff Fine Tuning a Local LLM to Categorize Questions Published: 16 Jun, 2026 Author Torgeir Helgevold As a fun personal project, I have been working on a chatbot for answering general questions about my household on anything from maintenance questions to doctor’s appointments. The general idea is that the chatbot will get its household knowledge through RAG from querying a vector database, but for better results I have made the vector searches metadata aware. Basically, I am running questions through a pre-processing step to categorize questions into known metadata categories (e.g. pool, car, hvac, cooking). The main goal of this is to narrow down the search space for vector ranking to only indexed entries that match the category of the question. As an example, the question “When did we replace our pool pump?” will be mapped to a category called “pool” before querying the Index database. The hypothesis I want to test in this experiment is whether a very small local LLM can be fine-tuned to perform reliable question categorization when trained on a dataset of household-related questions LLMs In this project I am using two different local llms – Qwen 3:4B and Qwen 3:0.6B. The 4B parameter version is used for general question answering, while the super tiny 0.6B version is used to categorize questions. The whole premise of this experiment is to see if a tiny llm with only 600M parameters can be finetuned into a reliable classifier of household questions. Finetuning For finetuning I am using a popular open-source framework called Unsloth, which seems well suited for tuning local models like Qwen and Llama. For training purposes my initial dataset consists of about ~850 data entries where I do a 70/15/15 percentage-based split into training data, eval data and test data respectively. Training data and eval data are used during training, while the test dataset is withheld and used to run a test post training. See section below for sample data: [ { "question": "Who cleans our gutters at the house?", "category": "gutters" }, { "question": "Who serviced the hot water heater for the home?", "category": "water heater" }, { "question": "Who fixed the sprinkler system in the yard?", "category": "irrigation" }, { "question": "Which store do we usually buy pinnekjott from?", "category": "cooking" }, { "question": "What dimensions are the air filters for the home AC?", "category": "hvac" }, { "question": "What year did we replace the downstairs AC unit?", "category": "hvac" } ] The basic idea is to train the llm on a sufficient set of household questions to teach it to become a reliable question classifier. Baseline Before doing any finetuning, it’s important to establish a baseline to measure against. In this experiment the baseline is to try to use the original Qwen 0.6B model “as is” through prompting alone. A sample prompt used for the baseline can be found below: Classify the homeowner question into exactly one category from the list below. Return only the category name from the list. Never return a code, a number, a synonym, an explanation, or any other text. The answer must be exactly one category name from the list. Choose the best category based on the meaning of the question. Valid categories: - appliances - brick work - car - cooking - doorbell - electric - fence - fountain - garden lights - gutters - hvac - irrigation - mosquito - painting - pool - tree service - water heater - window service Question: Who installed the tankless hot water setup for the house? Category: Accuracy of Baseline model: As one of my offline eval methods I have created a battery of ~130 integration tests to test the model with scenarios from a second dataset. For the baseline model, the results are poor. Out of 131 tests the model only categorized 13 questions correctly (~10% correct responses). See summary below: { "scenario": "baseline-category", "model_kind": "baseline", "model_name": "qwen3:0.6b", "label_mode": "category", "total": 131, "correct": 13, "incorrect": 118, "accuracy": 0.0992 } When digging into the actual failures a few common patterns emerge: The model is mostly overusing broad labels like electric/appliances and missing most of the other categories (e.g pool, cooking, hvac). The model invents new categories (e.g. apartments) and doesn’t stick to the provided list of allowed categories I have provided an excerpt from the test report below: [{ "case_id": 1, "question": "When was the lower air conditioning system swapped out?", "expected_category": "hvac", "scenario": "baseline-category", "model_kind": "baseline", "model_name": "qwen3:0.6b", "label_mode": "category", "predicted_category": "electric", "correct": false }, { "case_id": 64, "question": "Which painter worked on Joe's room?", "expected_category": "painting", "scenario": "baseline-category", "model_kind": "baseline", "model_name": "qwen3:0.6b", "label_mode": "category", "predicted_category": null, "predicted_code": null, "correct": false, "status_code": 422, "error": "Ollama returned an unknown category name 'apartments' from response 'apartments'" } ] Finetuning – 1st attempt The results from the baseline made it clear that a tiny model like Qwen 3 0.6B cannot provide reliable performance through just prompting alone. As for the next experiment, I am using the same prompt as before, but I am doing model finetuning to teach the model how to categorize with greater accuracy. I have included the finetuning script here in case you are interested in checking it out. At a high level I am leveraging Unsloth with QLora as the finetuning strategy. One note: The default fine tuning parameters provided by Unsloth provide a very good starting point. It’s been my experience that it’s more important to come up with a good dataset than worrying about tweaking the Unsloth values too much, at least to start. One common pitfall to avoid though is overfitting on the training data, which is why it’s important to test the model on data not found in the training data. In addition to the static training/test data I have also incorporated a way to provide user feedback to amend the training data as a second channel during future retraining. Result: After running the battery of integration tests, I observed a clear improvement in prediction accuracy as seen in the report below: { "scenario": "finetuned-category", "model_kind": "finetuned", "model_name": "our-house-qwen3-0.6b-category-names", "label_mode": "category", "total": 131, "correct": 104, "incorrect": 27, "accuracy": 0.7939 } The prediction accuracy is up from 10% to 79%, but I still see some clear patterns of incorrect results: The model now shows clear signs of heading in the right direction, but I see a pattern of only emitting fragments of the correct categories from the allowed list. Some examples are ac/air instead of hvac The model gets confused by semantically overlapping categories like water-based confusion from fountain, water heater and pool. Finetuning – 2nd attempt An easy improvement on the first fine tuning experiment would be to add a post processing step. This would allow me to normalize results where the prediction is semantically correct, but syntactically incorrect (e.g. ac, air). Another tweak would be to build more reinforcement into the prompt itself by providing more examples, telling the model what to do and not to do. I would say both ideas a reasonable, but it leads to more maintenance as more categories are added. Instead, I wanted to see if I could tweak the finetuning approach slightly by making some changes to how I teach the model to map categories. It turns out we can make a minor change to the prompt to improve accuracy even more compared to the 1st experiment. The tweak is actually just a simple change to the prompt where I map the categories to a two-character opaque IDs with no semantic overlap as seen in the sample below: Classify the homeowner question into exactly one label from the list below. Return only the s