File size: 2,587 Bytes
842c904
 
 
d6ac1bc
842c904
 
 
 
 
 
 
 
 
 
481c582
842c904
481c582
842c904
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8d0427c
842c904
8d0427c
842c904
 
 
 
 
 
 
 
8d0427c
 
842c904
 
 
 
 
 
 
 
 
 
 
eb97330
842c904
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6ac1bc
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
base_model: tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.5
library_name: peft
license: other
language:
  - ja
tags:
  - lora
  - medical
  - de-identification
  - ner
  - japanese
---

# PHIタグ推論モデル

[Llama-3.1-Swallow-8B-Instruct-v0.5](https://huggingface.co/tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.5) をベースに、日本語医療テキストのPHIタグ付与タスクにLoRAでファインチューニングしたマージ済みモデルです。

## ベースモデル

- [tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.5](https://huggingface.co/tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.5)

## タスク

入力テキスト中の個人情報(PHI: Protected Health Information)に対してタグを付与します。

| タグ | 対象 |
|------|------|
| `<phi_age>` | 年齢 |
| `<phi_id>` | 識別番号 |
| `<phi_tel>` | 電話番号 |
| `<phi_job>` | 職業 |
| `<phi_location>` | 住所・地名 |
| `<phi_person>` | 人名 |
| `<phi_hospital>` | 医療機関名 |

## 使用方法

```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig

model_id = "sociocom/MedPHINER-Llama-3.1-Swallow-8B-Instruct-v0.5"

tokenizer = AutoTokenizer.from_pretrained(model_id)

quant_cfg = 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(
    model_id,
    device_map="auto",
    dtype=torch.bfloat16,
    quantization_config=quant_cfg,
)
model.eval()
```

## 学習データ

- データセット: NTCIR
- 学習サンプル数: 11,127文
- 個人情報の挿入およびアノテーションに OpenAI API(gpt-5.2-2025-12-11)を使用

## 学習設定

| パラメータ | 値 |
|------------|----|
| LoRA rank | 16 |
| LoRA alpha | 64 |
| LoRA dropout | 0.05 |
| 学習エポック数 | 5 |
| バッチサイズ | 8 |
| 学習率 | 2e-4 |
| オプティマイザ | AdamW |

## ライセンス

本モデルのベースである Llama-3.1-Swallow-8B-Instruct-v0.5 は以下の2つのライセンスに従います。

| 使用モデル | ライセンス |
|------------|------------|
| [Llama-3.1-Swallow-8B-Instruct-v0.5](https://huggingface.co/tokyotech-llm/Llama-3.1-Swallow-8B-Instruct-v0.5) | [Llama 3.1](https://llama.meta.com/llama3_1/license/) および [Gemma](https://ai.google.dev/gemma/terms) |
| [Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct) | [Llama 3.1](https://llama.meta.com/llama3_1/license/) |