m97j commited on
Commit
c6bd207
Β·
verified Β·
1 Parent(s): 5d2c9e3

Delete lora-output-jason-mom-head/README.md

Browse files
Files changed (1) hide show
  1. lora-output-jason-mom-head/README.md +0 -136
lora-output-jason-mom-head/README.md DELETED
@@ -1,136 +0,0 @@
1
- ---
2
- base_model: Qwen/Qwen2.5-3B-Instruct
3
- library_name: peft
4
- pipeline_tag: text-generation
5
- tags:
6
- - lora
7
- - transformers
8
- - korean
9
- - npc
10
- - game-ai
11
- ---
12
-
13
- # npc_LoRA
14
-
15
- **npc_LoRA** is a LoRA adapter built on top of [Qwen/Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct), designed to generate emotionally rich, context-aware dialogue for non-player characters (NPCs) in Korean-language game environments.
16
-
17
- This project is part of a portfolio for industrial service roles in AI and game development, showcasing practical model design, multi-head training, and real-world integration strategies.
18
-
19
- ## 🧠 Model Architecture
20
-
21
- - **Base model**: Qwen2.5-3B-Instruct
22
- - **Adapter type**: LoRA (via PEFT)
23
- - **Language**: Korean
24
- - **Task**: Text generation with auxiliary heads
25
- - **Heads added**:
26
- - `delta_head`: Predicts 2D continuous values for narrative state change
27
- - `flag_head`: Predicts 3 or more binary flags for game logic triggers
28
-
29
- ## πŸ—οΈ Training Setup
30
-
31
- - **Environment**: Google Colab with A100 GPU
32
- - **Quantization**: 4-bit (nf4) via BitsAndBytes
33
- - **Batch size**: 2 (gradient accumulation: 8)
34
- - **Epochs**: 6
35
- - **Losses**:
36
- - Language modeling (CrossEntropy)
37
- - Delta prediction (MSE)
38
- - Flag prediction (BCE)
39
-
40
- ## πŸ“œ Prompt Format
41
-
42
- ```text
43
- <SYS>
44
- NPC_ID=...
45
- TAGS:
46
- location=...
47
- quest_stage=...
48
- relationship=...
49
- trust=...
50
- npc_mood=...
51
- player_reputation=...
52
- style=...
53
- REQUIRE:
54
- ...
55
- FORMAT:
56
- <RESPONSE>...</RESPONSE>
57
- <DELTA ...>
58
- <FLAG ...>
59
- </SYS>
60
- <CTX>
61
- player: ...
62
- npc: ...
63
- </CTX>
64
- <PLAYER>...
65
- <NPC>
66
- ```
67
-
68
- ## πŸ” Inference Example
69
-
70
- ```python
71
- from transformers import AutoTokenizer, AutoModelForCausalLM
72
- from peft import PeftModel
73
- import torch.nn as nn
74
-
75
- BASE_MODEL = "Qwen/Qwen2.5-3B-Instruct"
76
- ADAPTER_PATH = "minjae/npc_LoRA"
77
-
78
- tokenizer = AutoTokenizer.from_pretrained(ADAPTER_PATH, use_fast=True)
79
- model = AutoModelForCausalLM.from_pretrained(BASE_MODEL, device_map="auto", trust_remote_code=True)
80
- model = PeftModel.from_pretrained(model, ADAPTER_PATH)
81
-
82
- # Add heads
83
- hidden_size = model.config.hidden_size
84
- model.delta_head = nn.Linear(hidden_size, 2).to(model.device)
85
- model.flag_head = nn.Linear(hidden_size, 3).to(model.device)
86
-
87
- prompt = "<SYS>...<CTX>...<PLAYER>...<NPC>"
88
- inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
89
-
90
- with torch.no_grad():
91
- outputs = model(**inputs, output_hidden_states=True)
92
- gen_ids = model.generate(**inputs, max_new_tokens=100)
93
- generated_text = tokenizer.decode(gen_ids[0], skip_special_tokens=True)
94
-
95
- last_hidden = outputs.hidden_states[-1][:, -1, :]
96
- delta = model.delta_head(last_hidden)
97
- flag = model.flag_head(last_hidden)
98
-
99
- print("Response:", generated_text)
100
- print("Delta:", delta)
101
- print("Flags:", torch.sigmoid(flag))
102
- ```
103
-
104
- ## 🧩 Use Cases
105
-
106
- - NPC dialogue generation in Korean RPGs
107
- - Emotionally adaptive storytelling
108
- - Game logic trigger prediction (e.g., quest progression, item handoff)
109
-
110
- ## πŸ“ Repository Structure
111
-
112
- ```
113
- npc_LoRA/
114
- β”œβ”€β”€ adapter/ # LoRA adapter files
115
- β”œβ”€β”€ basemodel/ # Optional: base model files if Qwen is unavailable
116
- β”œβ”€β”€ README.md
117
- ```
118
-
119
- ## πŸ“Œ Notes
120
-
121
- - Adapter is optimized for Korean-language prompts and multi-turn dialogue.
122
- - Designed to integrate with game engines or AI-driven simulation platforms.
123
- - Compatible with Hugging Face Spaces (CPU/GPU) and local inference.
124
-
125
- ## πŸ“œ License
126
-
127
- MIT
128
-
129
- ## πŸ‘€ Author
130
-
131
- Created by **Minjae**
132
- Portfolio: [GitHub Profile](https://github.com/m97j)
133
- Contact: [[email protected]]
134
- ```
135
-
136
-