irene93/deidentification-chat-ko
Viewer • Updated • 9.4k • 19
How to use hgjun/llama-3_deidentification_01 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="hgjun/llama-3_deidentification_01")
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("hgjun/llama-3_deidentification_01")
model = AutoModelForCausalLM.from_pretrained("hgjun/llama-3_deidentification_01", 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]:]))How to use hgjun/llama-3_deidentification_01 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "hgjun/llama-3_deidentification_01"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "hgjun/llama-3_deidentification_01",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/hgjun/llama-3_deidentification_01
How to use hgjun/llama-3_deidentification_01 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "hgjun/llama-3_deidentification_01" \
--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": "hgjun/llama-3_deidentification_01",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "hgjun/llama-3_deidentification_01" \
--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": "hgjun/llama-3_deidentification_01",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use hgjun/llama-3_deidentification_01 with Docker Model Runner:
docker model run hf.co/hgjun/llama-3_deidentification_01
A Korean de-identification model: it finds personal information (names, phone numbers, etc.) in Korean text and returns the text with that information masked.
| Item | Value |
|---|---|
| Base model | allganize/Llama-3-Alpha-Ko-8B-Instruct |
| Data | 100 examples from irene93/deidentification-chat-ko |
| Method | LoRA SFT (r=8, alpha=16, all linear layers), merged into the base model, saved in fp16 |
| Hyperparameters | 10 epochs · learning rate 1e-4 · cosine schedule · bf16 |
| Tools | LLaMA-Factory · DeepSpeed ZeRO-3 · single GPU |
The model was trained with the following Korean instruction.
<instruction>
다음 입력을 받아 <deidentified_text>익명화 텍스트</deidentified_text>를 작성한다:
<text>: 주어진 문장 텍스트
</instruction>
<task>
<text>에서 개인정보를 마스킹한 <deidentified_text>를 작성하라.
</task>
<text>원문</text>
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "hgjun/llama-3_deidentification_01"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
An experimental model trained on a small dataset (100 examples). Validate it separately before using it on real personal data. Quantitative evaluation results are not published yet.
Base model
allganize/Llama-3-Alpha-Ko-8B-Instruct