--- license: apache-2.0 language: - ko - en library_name: transformers pipeline_tag: text-generation tags: - qwen2 - causal-lm - summarization - korean - finetuned - safetensors - fp32 base_model: Qwen/Qwen2-1.5B-Instruct model-index: - name: qwen2-1_5b-sum_lk_gemini results: [] --- # seoseo99/qwen2-1_5b-sum_lk_gemini Qwen2-1.5B-Instruct를 한국어 여행/행사 **후기 요약** 용도로 미세조정한 1.5B 파라미터 모델입니다. 1–3문장 간결 요약, 핵심 포인트 추출, 여러 후기 합본 요약에 적합합니다. ## 파일 구성 - `config.json` — 모델 아키텍처 설정(hidden size, layer 수 등). 구조 정보라 보통 수정하지 않습니다. - `generation_config.json` — `generate()`의 기본값(max_new_tokens, temperature, top_p, 등) - `tokenizer.json` — Fast 토크나이저 전체 정의(vocab/merges/전처리 파이프라인 포함) - `tokenizer_config.json` — 토크나이저 메타(model_max_length, 특수토큰 정책 등) - `special_tokens_map.json` — `eos/pad` 등 특수 토큰 매핑 - `model-00001-of-00002.safetensors`, `model-00002-of-00002.safetensors` — 모델 가중치 샤드(shard) 파일 - `model.safetensors.index.json` — 각 파라미터 텐서가 어느 shard에 있는지 인덱스 맵 --- ## Introduction (EN) Qwen2-1.5B-Instruct fine-tuned for **Korean travel/event review summarization** (1.5B parameters). Well-suited for **1–3 sentence** concise summaries, key-point extraction, and aggregating multiple reviews. ## Files (EN) - `config.json` — Model architecture settings (hidden size, number of layers, etc.). Structural info; usually not modified. - `generation_config.json` — Default parameters for `generate()` (e.g., `max_new_tokens`, `temperature`, `top_p`). - `tokenizer.json` — Full definition of the Fast tokenizer (vocab/merges/preprocessing pipeline). - `tokenizer_config.json` — Tokenizer metadata (`model_max_length`, special-token policies, etc.). - `special_tokens_map.json` — Mapping for special tokens (e.g., `eos`, `pad`). - `model-00001-of-00002.safetensors`, `model-00002-of-00002.safetensors` — Sharded model weights. - `model.safetensors.index.json` — Index mapping that shows which tensors live in which shard. --- ## Quickstart (Transformers) ```python from transformers import AutoTokenizer, AutoModelForCausalLM import torch, unicodedata, re RID = "seoseo99/qwen2-1_5b-sum_lk_gemini" tok = AutoTokenizer.from_pretrained(RID, use_fast=True, trust_remote_code=True) if tok.pad_token is None: tok.pad_token = tok.eos_token model = AutoModelForCausalLM.from_pretrained( RID, torch_dtype=torch.float32, # GPU면 bfloat16/auto 가능 low_cpu_mem_usage=True, trust_remote_code=True, ).eval() review = "여기에 리뷰 본문을 넣으세요" sys = ("다음 한국어 리뷰 본문을 1~3문장으로 간결하게 요약하세요. " "과장/광고 톤 금지, 제목/지역/날짜는 출력하지 마세요.") body = unicodedata.normalize("NFKC", review).replace("\n", " ") msgs = [ {"role": "system", "content": sys}, {"role": "user", "content": "【리뷰 본문】\n" + body}, ] ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt") out = model.generate( ids, max_new_tokens=180, num_beams=4, do_sample=False, no_repeat_ngram_size=4, repetition_penalty=1.05, eos_token_id=tok.eos_token_id, ) text = tok.decode(out[0, ids.shape[-1]:], skip_special_tokens=True) text = unicodedata.normalize("NFKC", text).replace("\n", " ") text = re.sub(r"\s+([\.!?])", r"\1", text).strip() print(text if text.endswith(('.', '!', '?')) else text + '.')