Instructions to use chyungwon/police-report-analysis-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chyungwon/police-report-analysis-model with Transformers:
# 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use chyungwon/police-report-analysis-model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "chyungwon/police-report-analysis-model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chyungwon/police-report-analysis-model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/chyungwon/police-report-analysis-model
- SGLang
How to use chyungwon/police-report-analysis-model with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "chyungwon/police-report-analysis-model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chyungwon/police-report-analysis-model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "chyungwon/police-report-analysis-model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chyungwon/police-report-analysis-model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use chyungwon/police-report-analysis-model with Docker Model Runner:
docker model run hf.co/chyungwon/police-report-analysis-model
# 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
# 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)