How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="chyungwon/police-report-analysis-model")
messages = [
    {"role": "user", "content": "Who are you?"},
]
pipe(messages)
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("chyungwon/police-report-analysis-model")
model = AutoModelForCausalLM.from_pretrained("chyungwon/police-report-analysis-model", device_map="auto")
messages = [
    {"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
	messages,
	add_generation_prompt=True,
	tokenize=True,
	return_dict=True,
	return_tensors="pt",
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
Quick Links

Model Card for Model ID

Model Details

Model Description

이 λͺ¨λΈμ€ Google의 κ°•λ ₯ν•œ μ†Œν˜• μ–Έμ–΄ λͺ¨λΈμΈ Gemma-3-1B-it을 기반으둜, ν•œκ΅­μ–΄ 범죄 사건 λ³΄κ³ μ„œ 뢄석 νƒœμŠ€ν¬μ— 맞게 λ―Έμ„Έ μ‘°μ •(Fine-tuning)λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

# μ£Όμš” κΈ°λŠ₯
사건 μž¬κ΅¬μ„± (Context Generation): 사건 λ³΄κ³ μ„œμ˜ λ‚΄μš©κ³Ό 사싀 관계λ₯Ό λΆ„μ„ν•˜μ—¬ λ‹Ήμ‹œ 상황을 λ…Όλ¦¬μ μœΌλ‘œ μž¬κ΅¬μ„±ν•©λ‹ˆλ‹€.
사건 μœ ν˜• λΆ„λ₯˜ (Kind Classification): μž¬κ΅¬μ„±λœ λ‚΄μš©μ„ λ°”νƒ•μœΌλ‘œ μ‚¬κ±΄μ˜ μ’…λ₯˜λ₯Ό μ •ν™•νžˆ λΆ„λ₯˜ν•˜μ—¬ μ œμ‹œν•©λ‹ˆλ‹€.

# ν•™μŠ΅ μ „λž΅
(QLoRA)λͺ¨λΈ ν•™μŠ΅μ—λŠ” QLoRA (Quantized Low-Rank Adaptation) 기법이 μ μš©λ˜μ–΄, 높은 λ©”λͺ¨λ¦¬ νš¨μœ¨μ„±κ³Ό λΉ λ₯Έ ν•™μŠ΅ 속도λ₯Ό λ‹¬μ„±ν–ˆμŠ΅λ‹ˆλ‹€.

μ–‘μžν™”: 4-bit NF4 μ–‘μžν™” (BitsAndBytes)
PEFT: LoRA 적용 (Rank $r=16$, $\alpha=32$)
μ΅œμ ν™”: adamw_torch, Learning Rate $2e-4$, Cosine Scheduler

ν•„μˆ˜ 라이브러리 및 버전이 λͺ¨λΈμ˜ ν•™μŠ΅ 및 μ‚¬μš©μ„ μœ„ν•΄μ„œλŠ” λ‹€μŒ 라이브러리 버전이 ꢌμž₯λ©λ‹ˆλ‹€.
라이브러리 버전
transformers : 4.57.3
accelerate : 1.12.0
bitsandbytes : 0.48.2
peft : 0.15.2
torch : 2.9.0

Uses

from transformers import AutoModelForCausalLM, AutoTokenizer


base_model = "chyungwon/police-report-analysis-model"

tokenizer = AutoTokenizer.from_pretrained(base_model)

model = AutoModelForCausalLM.from_pretrained(
    base_model,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)


question = """λ‹€μŒ 사건 λ³΄κ³ μ„œλ₯Ό ν†΅ν•΄μ„œ λ‹Ήμ‹œ 범죄 사건을 μž¬κ΅¬μ„±ν•΄μ£Όκ³ , 사건 μœ ν˜•μ„ λΆ„λ₯˜ν•΄μ€˜.

[사건 λ³΄κ³ μ„œ]
2024λ…„ 4μ›” 25일, μ„œμšΈ μˆ­μ‹€λŒ€μž…κ΅¬μ—­ μΈκ·Όμ—μ„œ 이삿짐 ν™”λ¬Όμ°¨κ°€ μΈλ„λ‘œ λŒμ§„ν•΄ 60λŒ€ 남성을 λΆ€μƒμ‹œν‚¨ 사건이 λ°œμƒν•˜μ˜€λ‹€. 
ν˜„μž₯ 쑰사 κ²°κ³Ό, ν™”λ¬Όμ°¨ μš΄μ „μž κΉ€λ―Όμˆ˜(35)λŠ” 사전에 브레이크 νŒ¨λ“œλ₯Ό 마λͺ¨μ‹œν‚€κ³  λΈŒλ ˆμ΄ν¬μ•‘μ— 물을 μ„žμ–΄ κ³ μž₯을 μœ λ°œν•œ κ²ƒμœΌλ‘œ ν™•μΈλ˜μ—ˆλ‹€. 
사고 직후 김은 μ°¨ 내뢀에 μˆ¨κ²¨μ§„ κΈˆκ³ μ—μ„œ ν˜„κΈˆ 200만 원과 κ°€μ£½ κ°€λ°©, μŠ€λ§ˆνŠΈν°μ„ κΊΌλ‚΄ 상가 μ•ˆκ²½μ› μ§μ›μ—κ²Œ μ „λ‹¬ν•˜κ³ , 은행 κ³„μ’Œλ‘œ μ†‘κΈˆν•˜μ˜€λ‹€. 
경찰은 μ°¨λŸ‰ GPS 기둝, 브레이크 νŒ¨λ“œ 마λͺ¨ μƒνƒœ, CCTV μ˜μƒ μ‘°μž‘ μ—¬λΆ€λ₯Ό 쑰사 쀑이며, 김은 κ΅ν†΅μ‚¬κ³ μ²˜λ¦¬νŠΉλ‘€λ²•μ— 따라 μΉ˜μƒ 혐의둜 μž…κ±΄λ˜μ—ˆλ‹€. 
ν˜„μž¬ μˆ˜μ‚¬λŠ” κΉ€μ˜ 은행 μ†‘κΈˆ 기둝과 금고 λ‚΄μš©λ¬Ό 확보λ₯Ό 톡해 범죄 동기와 λ²”ν–‰ 방법을 νŒŒμ•… 쀑이닀. 
사건은 아직 결말이 λ‚΄λ €μ§€μ§€ μ•Šμ•˜μœΌλ©°, μΆ”κ°€ 증거 확보가 ν•„μš”ν•˜λ‹€."""


messages = [
    {"role": "system", "content": """당신은 범행뢄석 AI λͺ¨λΈμž…λ‹ˆλ‹€. μ§ˆλ¬Έμ— μ •ν™•ν•˜κ²Œ λ‹΅λ³€ν•˜μ„Έμš”."""},
    {"role": "user", "content": question}
]

inputs = tokenizer.apply_chat_template(
    messages,
    add_generation_prompt=True,
    return_tensors="pt",
    return_dict=True,
).to(model.device)

model.eval()
outputs = model.generate(
    **inputs,
    max_new_tokens=1024 * 2,
    temperature=0.1,
    do_sample=True,
)

generated = outputs[0][inputs["input_ids"].shape[-1] :]
answer = tokenizer.decode(generated, skip_special_tokens=True)
print('사건 μž¬κ΅¬μ„± : ', answer)


사건 μž¬κ΅¬μ„± : 2024λ…„ 4μ›” 25일 μ˜€ν›„ 1μ‹œ 30λΆ„, μ„œμšΈ μˆ­μ‹€λŒ€μž…κ΅¬μ—­ μΈκ·Όμ—μ„œ λ°œμƒν•œ 이삿짐 ν™”λ¬Όμ°¨ μ‚¬κ³ λŠ” λ‹¨μˆœν•œ ꡐ톡사고가 μ•„λ‹ˆλΌ μ •κ΅ν•˜κ²Œ κ³„νšλœ μ ˆλ„ μ‚¬κ±΄μ˜ μΌν™˜μ΄μ—ˆλ‹€. ν™”λ¬Όμ°¨ μš΄μ „μžμΈ κΉ€λ―Όμˆ˜(35)λŠ” 3κ°œμ›” μ „λΆ€ν„° μ§€μ—­ μƒκ°€μ—μ„œ μΌν•˜λŠ” 60λŒ€ 남성(ν”Όν•΄μž)과의 κΈˆμ „μ  κ°ˆλ“±μ„ ν’ˆκ³  μžˆμ—ˆλ‹€. 김은 ν”Όν•΄μžκ°€ μžμ‹ μ΄ μš΄μ˜ν•˜λ˜ μž‘μ€ κ°€κ²Œμ—μ„œ 물건을 훔쳐 κ°€λŠ” 것을 λͺ©κ²©ν•˜κ³ , κ·Έ 사싀을 ν­λ‘œν•˜λ©΄ μžμ‹ μ˜ 사업이 λ§κ°€μ§ˆ μœ„ν—˜μ΄ μžˆλ‹€κ³  νŒλ‹¨ν–ˆλ‹€. 이에 김은 ν”Όν•΄μžλ₯Ό μ œκ±°ν•˜κ³  λ™μ‹œμ— κ°€κ²Œμ—μ„œ ν›”μΉœ 물건을 νšŒμˆ˜ν•˜λ €λŠ” κ³„νšμ„ μ„Έμ› λ‹€.  

κ³„νš λ‹¨κ³„μ—μ„œ 김은 ν™”λ¬Όμ°¨μ˜ 브레이크 νŒ¨λ“œλ₯Ό 미리 마λͺ¨μ‹œν‚€κ³ , λΈŒλ ˆμ΄ν¬μ•‘μ— 물을 μ„žμ–΄ λΈŒλ ˆμ΄ν¬κ°€ κ°‘μžκΈ° μž‘λ™ν•˜μ§€ μ•Šλ„λ‘ μ‘°μž‘ν–ˆλ‹€. λ˜ν•œ, μ°¨ 내뢀에 μˆ¨κ²¨μ§„ μž‘μ€ κΈˆκ³ μ— ν›”μΉœ 물건(ν˜„κΈˆ 200만 원, κ°€μ£½ κ°€λ°©, 슀마트폰)을 λ³΄κ΄€ν–ˆλ‹€. 사고 λ°œμƒ μ‹œ ν”Όν•΄μžκ°€ 차에 λΆ€λ”ͺν˜€ 뢀상을 μž…μœΌλ©΄, 김은 μ¦‰μ‹œ μ°¨λ₯Ό λ©ˆμΆ”κ³  금고λ₯Ό μ—΄μ–΄ 물건을 κΊΌλ‚΄μ–΄ 상가 μ•ˆκ²½μ› μ§μ›μ—κ²Œ μ „λ‹¬ν–ˆλ‹€. 이 직원은 김이 사전에 ν˜‘μƒν•œ 인물둜, 물건을 μˆ˜κ±°ν•΄ κΉ€μ˜ 은행 κ³„μ’Œλ‘œ μ†‘κΈˆν•˜λ„λ‘ ν–ˆλ‹€.  

μ‹€ν–‰ λ‹¨κ³„μ—μ„œ 김은 ν™”λ¬Όμ°¨λ₯Ό μˆ­μ‹€λŒ€μž…κ΅¬μ—­ 인근 인도에 μ£Όμ°¨ν•œ λ’€, ν”Όν•΄μžκ°€ μ°¨λ₯Ό μ§€λ‚˜κ°€λ˜ μˆœκ°„ 브레이크λ₯Ό 고의둜 μž‘λ™μ‹œν‚€μ§€ μ•Šλ„λ‘ μ‘°μž‘ν–ˆλ‹€. μ°¨κ°€ 인도λ₯Ό λŒμ§„ν•˜λ©΄μ„œ ν”Όν•΄μžλŠ” 차체에 λΆ€λ”ͺν˜€ 닀리λ₯Ό 크게 λ‹€μ³€κ³ , μ¦‰μ‹œ λ³‘μ›μœΌλ‘œ μ΄μ†‘λ˜μ—ˆλ‹€. 김은 사고 직후 μ°¨λ₯Ό λ©ˆμΆ”κ³ , ν”Όν•΄μžκ°€ λΆ€μƒμœΌλ‘œ 움직일 수 μ—†λ‹€λŠ” 상황을 μ΄μš©ν•΄ 금고λ₯Ό μ—΄μ–΄ 물건을 κΊΌλƒˆλ‹€. κ·ΈλŠ” 물건을 상가 μ•ˆκ²½μ› μ§μ›μ—κ²Œ μ „λ‹¬ν•˜κ³ , 직원은 μ¦‰μ‹œ ν˜„κΈˆκ³Ό 물건을 κΉ€μ˜ 은행 κ³„μ’Œλ‘œ μ†‘κΈˆν–ˆλ‹€.  

은폐 λ‹¨κ³„μ—μ„œλŠ” 김은 사고 ν˜„μž₯을 λΉ λ₯΄κ²Œ μ •λ¦¬ν•˜κ³ , μ°¨ 내뢀에 남은 흔적을 μ΅œμ†Œν™”ν–ˆλ‹€. κ·ΈλŠ” μ°¨λ₯Ό λ‹€λ₯Έ μ§€μ—­μœΌλ‘œ μ΄λ™μ‹œμΌœ CCTVκ°€ κ°μ‹œλ˜μ§€ μ•ŠλŠ” 곳에 μ£Όμ°¨ν–ˆλ‹€. λ˜ν•œ, 사고 λ‹Ήμ‹œ μ°¨κ°€ μ •μ§€ν•œ μœ„μΉ˜μ™€ ν”Όν•΄μžμ˜ 뢀상 정도λ₯Ό μ΄μš©ν•΄ 경찰이 사고λ₯Ό λ‹¨μˆœν•œ κ΅ν†΅μ‚¬κ³ λ‘œ νŒλ‹¨ν•˜λ„λ‘ μœ λ„ν–ˆλ‹€. 김은 이후 은행 κ³„μ’Œμ—μ„œ 물건을 ν˜„κΈˆμœΌλ‘œ μΈμΆœν•΄ ν˜„μ§€ νŽΈμ˜μ μ—μ„œ ν˜„κΈˆν™”ν•˜κ³ , 남은 κΈˆμ•‘μ€ κ°€μ§œ μ‹ λΆ„μ¦μœΌλ‘œ λ§Œλ“  가상 κ³„μ’Œμ— μ†‘κΈˆν–ˆλ‹€.  

μˆ˜μ‚¬ κ³Όμ •μ—μ„œ 경찰은 CCTV μ˜μƒμ„ 뢄석해 ν™”λ¬Όμ°¨κ°€ 인도λ₯Ό λŒμ§„ν•œ μˆœκ°„μ„ ν™•μΈν–ˆκ³ , 브레이크 νŒ¨λ“œ 마λͺ¨μ™€ λΈŒλ ˆμ΄ν¬μ•‘μ— 물이 μ„žμΈ 흔적을 λ°œκ²¬ν–ˆλ‹€. λ˜ν•œ, 김이 사전에 상가 μ•ˆκ²½μ› 직원과 연락을 μ£Όκ³ λ°›μ•˜λ‹€λŠ” 증거가 ν™•λ³΄λ˜μ—ˆλ‹€. κ·ΈλŸ¬λ‚˜ 김은 κ΅ν†΅μ‚¬κ³ μ²˜λ¦¬νŠΉλ‘€λ²•μ— 따라 μΉ˜μƒ 혐의둜 μž…κ±΄λ˜μ—ˆμœΌλ©°, ν˜„μž¬λŠ” κ΅¬μ†μ˜μž₯이 μ‹ μ²­ 쀑이닀. 사건은 아직 μˆ˜μ‚¬ 단계이며, 김이 μ‹€μ œλ‘œ 물건을 ν›”μ³€λŠ”μ§€, 그리고 ν”Όν•΄μžμ™€μ˜ κ°ˆλ“±μ΄ λ²”ν–‰ 동기에 μ–Όλ§ˆλ‚˜ 영ν–₯을 λ―Έμ³€λŠ”μ§€μ— λŒ€ν•œ μΆ”κ°€ 쑰사가 ν•„μš”ν•˜λ‹€. 사건은 아직 결말이 λ‚΄λ €μ§€μ§€ μ•Šμ•˜μœΌλ©°, 경찰은 κΉ€μ˜ 은행 κ³„μ’Œμ™€ 상가 μ•ˆκ²½μ› μ§μ›μ˜ 증언을 톡해 λ²”ν–‰μ˜ μ „λͺ¨λ₯Ό νŒŒμ•…ν•˜λ € ν•˜κ³  μžˆλ‹€. 
사건 μœ ν˜• : μ ˆλ„

Training Details

base_model = "./gemma-3-1b-it"
tokenizer = AutoTokenizer.from_pretrained(base_model)

bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_compute_dtype=torch.bfloat16,
    bnb_4bit_use_double_quant=True,
    bnb_4bit_quant_type="nf4"
)

model = AutoModelForCausalLM.from_pretrained(
    base_model,
    quantization_config=bnb_config,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)

lora_config = LoraConfig(
    r=16,
    lora_alpha=32,
    target_modules=[
        "q_proj", "k_proj", "v_proj", "o_proj",
        "gate_proj", "up_proj", "down_proj"
    ],
    lora_dropout=0.05,
    bias="none",
    task_type=TaskType.CAUSAL_LM,
)

model2 = get_peft_model(model, lora_config)

Preprocessing [optional]

def format_prompt(ex, max_length=1775):
    global max_length_cal, row


    title = 'λ‹€μŒ 사건 λ³΄κ³ μ„œλ₯Ό ν†΅ν•΄μ„œ λ‹Ήμ‹œ 사건을 μž¬κ΅¬μ„±ν•΄μ£Όκ³ , 사건 μœ ν˜•μ„ λΆ„λ₯˜ν•΄μ€˜\n'
    question = ex["report"]
    answer = ex["context"]
    kind = f'\n사건 μœ ν˜• : {ex["kind"]}'

    prompt = f"""<start_of_turn>system
당신은 범행뢄석 AI λͺ¨λΈμž…λ‹ˆλ‹€.
μ§ˆλ¬Έμ— μ •ν™•ν•˜κ²Œ λ‹΅λ³€ν•˜μ„Έμš”.
<end_of_turn>
<start_of_turn>user
{title}

[사건 λ³΄κ³ μ„œ]
{question}\n<end_of_turn>\n<start_of_turn>model\n"""

    prompt_ids = tokenizer(prompt, add_special_tokens=False)["input_ids"]

    model_part = f"""{answer} {kind}<end_of_turn>"""
    answer_ids = tokenizer(model_part, add_special_tokens=False)["input_ids"]

    input_ids = prompt_ids + answer_ids
    labels = [-100] * len(prompt_ids) + answer_ids
    attention_mask = [1] * len(input_ids)

    pad_len = max_length - len(input_ids)
    input_ids += [tokenizer.pad_token_id] * pad_len
    attention_mask += [0] * pad_len
    labels += [-100] * pad_len

    return {
        "input_ids": input_ids,
        "attention_mask": attention_mask,
        "labels": labels,
    }

Training Hyperparameters

training_args = TrainingArguments(
  output_dir=model_path,
  per_device_train_batch_size=16,
  gradient_accumulation_steps=2,
  num_train_epochs=4, 
  learning_rate=2e-4, 
  bf16=True,
  fp16=False,
  gradient_checkpointing = False,
  logging_steps=5,
  eval_steps=300,                  
  save_strategy="steps",
  save_steps=300,                              
  save_total_limit=2,
  report_to="none",
  lr_scheduler_type="cosine",
  warmup_ratio=0.05, 
  optim="adamw_torch"
)

Speeds, Sizes, Times [optional]

[4844/4844 5:28:09, Epoch 4/4]
Step	Training Loss
10	2.668900
20	2.386700
30	2.226000
40	2.026500
50	1.896800
60	1.778100
70	1.733700
80	1.678000
90	1.622100
100	1.583400
200	1.399400
300	1.343400
400	1.290700
500	1.286000
600	1.229200
700	1.226100
800	1.216800
900	1.204500
1000	1.158700
1100	1.153700
1200	1.157400
1300	1.106100
1400	1.114300
1500	1.091600
1600	1.087400
1700	1.087200
1800	1.093100
1900	1.082200
2000	1.084200
2100	1.090000
2200	1.084300
2300	1.058100
2400	1.062100
2500	1.021800
2600	1.028800
2700	1.034700
2800	1.040300
2900	1.033000
3000	1.016200
3100	1.015800
3200	0.983400
3300	1.010900
3400	1.015900
3500	1.028600
3600	1.019400
3700	0.971100
3800	0.947100
3900	0.984500
4000	0.965500
4100	0.973800
4200	0.968100
4300	0.969000
4400	0.953500
4500	0.988400
4505	0.942400
4510	0.931300
4515	0.973200
4520	0.989900
4525	0.979900
4530	0.963000
4535	0.981700
4540	0.953700
4545	0.963700
4550	0.961500
4555	0.972000
4560	0.958600
4565	0.970500
4570	0.987800
4575	0.974500
4580	0.968700
4585	0.982000
4590	0.961300
4595	0.968400
4600	0.966000
4700	0.998300
4800	0.966200
4805	0.973900
4810	0.975200
4815	0.974400
4820	0.973400
4825	0.972000
4830	0.960200
4835	0.961700
4840	0.974000


Evaluation Result : 
{'eval_loss': 1.062408447265625, 'eval_runtime': 15.7428, 'eval_samples_per_second': 24.9, 'eval_steps_per_second': 3.113, 'epoch': 4.0}


Best checkpoint :
4510	0.931300

Model Card Authors [optional]

(μ£Ό)인정보
ν™ˆνŽ˜μ΄μ§€ : http://www.ijbinfo.com

정보톡신산업진ν₯μ›μ˜ 지원을 λ°›μ•„μ„œ μ§„ν–‰ν–ˆμŠ΅λ‹ˆλ‹€.

Model Card Contact

(μ£Ό)인정보
μ£Όμ†Œ : μ„œμšΈμ‹œ 금천ꡬ 가산동 60-5 κ°‘μ˜¬κ·Έλ ˆμ΄νŠΈλ°Έλ¦¬A동 805호
μ—°λ½μ²˜ : TEL : 02-3397-7765 FAX : 02-3397-7769 E-mail : sales@injungbo.co.kr
λ‹΄λ‹Ήμž : μž₯ν˜•μ›(chyungwon@ijbinfo.com)
Downloads last month
8
Safetensors
Model size
1.0B params
Tensor type
BF16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for chyungwon/police-report-analysis-model

Quantizations
1 model