Views
No views yet
Baragi-AI/Munche-768 을 llama.cpp
에서 쓸 수 있도록 GGUF 로 변환한 것입니다. 한국어 소설의 문체 유사도를 나타내는
768차원 임베딩 모델입니다.google/embeddinggemma-300m
에 대한 LoRA 어댑터이므로, 베이스에 병합한 뒤 변환했습니다. SentenceTransformer
파이프라인의 Dense 프로젝션(768→3072→768)과 mean pooling 도 GGUF 에 포함되어
있어, 별도 후처리 없이 원본과 같은 임베딩이 나옵니다.| 파일 | 크기 | 최저 코사인 일치도 | 유사도 최대 오차 |
|---|---|---|---|
munche-768-f32.gguf | 1.18 GB | 1.000000 | 0.000054 |
munche-768-f16.gguf | 593 MB | 0.999999 | 0.000121 |
munche-768-q8_0.gguf | 318 MB | 0.999437 | 0.002015 |
munche-768-q4_k_m.gguf | 228 MB | 0.990537 | 0.010029 |
llama-server -m munche-768-f16.gguf --embeddings --pooling mean -c 2048 -ub 2048 -b 2048-ub 와 -b 를 2048 로 지정해야 합니다. 생략하면 llama.cpp 가 배치 크기를 512 로
낮춰서 긴 입력이 잘립니다.1import numpy as np
2import requests
3
4texts = [
5 "그는 창밖을 오래 바라보았다. 빗소리가 방 안을 가득 채웠다.",
6 "야, 그거 진짜야? 말도 안 돼. 나 어제 걔 봤는데 아무 말도 없었거든.",
7]
8
9response = requests.post(
10 "http://127.0.0.1:8080/v1/embeddings",
11 json={"input": texts, "model": "munche-768"},
12)
13rows = sorted(response.json()["data"], key=lambda r: r["index"])
14embeddings = np.array([r["embedding"] for r in rows])
15
16print(embeddings.shape) # (2, 768)
17print(embeddings @ embeddings.T) # 코사인 유사도--pooling mean 으로 띄우면 llama.cpp 가 L2 정규화까지 마친 벡터를 반환하므로,
코사인 유사도는 내적만으로 계산할 수 있습니다. 다른 pooling 옵션을 쓰거나 값을
직접 다룰 때는 norm 을 확인하세요.task: search result | query: 같은 프리픽스를 붙여 쓰도록 설계되어 있는데, 이
규칙은 GGUF 에 들어가지 않습니다. 원본 SentenceTransformer 의 encode_query() /
encode_document() 와 동일한 결과가 필요하다면 호출하는 쪽에서 프리픽스를 직접
붙여야 합니다. 위 표의 일치도는 양쪽 모두 프리픽스 없이 측정한 값입니다.google/embeddinggemma-300m 에 LoRA 어댑터를 병합한 뒤 llama.cpp 로 변환했습니다.1python convert_hf_to_gguf.py munche-768-merged \
2 --outfile munche-768-f32.gguf \
3 --outtype f32 \
4 --sentence-transformers-dense-modules
5
6llama-quantize munche-768-f32.gguf munche-768-q8_0.gguf Q8_0--sentence-transformers-dense-modules 가 없으면 Dense 레이어가 빠져서, 차원은
768 로 같지만 원본과 다른 임베딩이 나옵니다.SentenceTransformer.save() 는 tokenizer.model 을 저장하지 않습니다. 이
파일이 없으면 변환기가 sentencepiece 대신 BPE 경로를 타고, embeddinggemma 의
pre-tokenizer 해시가 등록되어 있지 않아 실패합니다. 베이스 리포에서 함께
복사해야 합니다.base_model.model. 접두사와 .default 가 빠져 있어,
PeftModel.from_pretrained() 로 로드하면 LoRA 가 적용되지 않은 채 경고만
출력됩니다. 키를 교정해 병합했습니다.1@software{munche768,
2 title = {Munche-768: Korean Fiction Style Embedding Model},
3 author = {Baragi AI},
4 year = {2026},
5 url = {https://huggingface.co/Baragi-AI/Munche-768}
6}