File size: 6,854 Bytes
8d9b537
d83be04
 
 
 
 
 
 
 
 
 
 
 
 
 
8d9b537
 
d83be04
8d9b537
d83be04
8d9b537
 
 
d83be04
 
 
 
 
 
 
 
 
9cc28b8
d83be04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8d9b537
 
 
 
 
d83be04
 
 
 
8d9b537
d83be04
8d9b537
d83be04
8d9b537
d83be04
8d9b537
d83be04
 
 
 
 
 
 
8d9b537
d83be04
8d9b537
d83be04
 
 
 
 
 
 
 
 
 
 
8d9b537
d83be04
8d9b537
d83be04
8d9b537
d83be04
 
 
 
 
8d9b537
d83be04
8d9b537
 
 
d83be04
8d9b537
d83be04
 
 
8d9b537
d83be04
8d9b537
d83be04
8d9b537
d83be04
 
 
 
8d9b537
d83be04
8d9b537
d83be04
 
 
8d9b537
d83be04
8d9b537
d83be04
8d9b537
d83be04
8d9b537
d83be04
8d9b537
d83be04
 
 
 
8d9b537
d83be04
8d9b537
d83be04
 
 
8d9b537
 
 
d83be04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
---
library_name: peft
tags:
- elden-ring
- question-answering
- gaming
- domain-specific
- qlora
- lora
- phi-2
base_model: microsoft/phi-2
license: cc-by-sa-4.0
language:
- en
pipeline_tag: text-generation
---

# πŸ—‘οΈ Elden Ring QA β€” Phi-2 QLoRA Adapter

A QLoRA fine-tuned adapter for [Microsoft Phi-2](https://huggingface.co/microsoft/phi-2) (2.7B) trained on a custom Elden Ring question-answering dataset. The model answers questions about weapons, bosses, spells, NPCs, locations, armor, and creatures β€” including boss vulnerability analysis and per-build weapon recommendations.

## Model Details

- **Base model:** [microsoft/phi-2](https://huggingface.co/microsoft/phi-2) (2.7B parameters)
- **Fine-tuning method:** QLoRA (4-bit NF4 quantization + LoRA adapters)
- **LoRA rank:** 8
- **LoRA alpha:** 16
- **LoRA target modules:** `q_proj`, `k_proj`, `v_proj`, `dense`
- **Trainable parameters:** ~5.2M (0.34% of total)
- **Adapter size:** 21 MB
- **Training data:** [ArenaRune/elden-ring-qa-dataset](https://huggingface.co/datasets/ArenaRune/elden-ring-qa-dataset)
- **Language:** English
- **Developed by:** ArenaRune

## Quick Start

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

# Quantization config (must match training)
bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.float16,
    bnb_4bit_use_double_quant=True,
)

# Load base model + adapter
base = AutoModelForCausalLM.from_pretrained(
    "microsoft/phi-2",
    quantization_config=bnb_config,
    device_map="auto",
    trust_remote_code=True,
)
model = PeftModel.from_pretrained(base, "ArenaRune/elden-ring-phi2-qlora")
tokenizer = AutoTokenizer.from_pretrained("ArenaRune/elden-ring-phi2-qlora")
model.eval()

# Ask a question
prompt = """### Instruction:
What weapons are good against Mohg, Lord of Blood?

### Response:
"""

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
    outputs = model.generate(
        **inputs,
        max_new_tokens=128,
        do_sample=False,
        repetition_penalty=1.5,
        no_repeat_ngram_size=3,
        pad_token_id=tokenizer.eos_token_id,
    )

answer = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(answer)
```

## Prompt Format

The model expects this instruction template:

```
### Instruction:
{your question about Elden Ring}

### Response:
```

## Training Details

### Training Data

Custom dataset built from 3 public sources:
- **Kaggle** β€” Ultimate Elden Ring with Shadow of the Erdtree DLC (12 structured CSVs)
- **GitHub** β€” [Impalers-Archive](https://github.com/ividyon/Impalers-Archive) (DLC text dump)
- **GitHub** β€” [Carian-Archive](https://github.com/AsteriskAmpersand/Carian-Archive) (base game text dump)

Dataset covers 10 entity types (weapons, bosses, armors, spells, NPCs, locations, creatures, skills, ashes of war) with 20+ question categories including cross-entity boss vulnerability analysis and per-build weapon recommendations.

Full dataset: [ArenaRune/elden-ring-qa-dataset](https://huggingface.co/datasets/ArenaRune/elden-ring-qa-dataset)

### Training Procedure

- **Framework:** HuggingFace Transformers + PEFT
- **Method:** QLoRA (4-bit NF4 quantization + LoRA)
- **Precision:** FP16 mixed precision
- **Optimizer:** Paged AdamW 8-bit
- **LR schedule:** Cosine with 10% warmup
- **GPU:** NVIDIA A100 (80GB)
- **Platform:** Google Colab

### Training Hyperparameters

| Parameter | Value |
|-----------|-------|
| Learning rate | 2e-4 |
| LoRA rank (r) | 8 |
| LoRA alpha | 16 |
| LoRA dropout | 0.1 |
| Epochs | 3 |
| Batch size (effective) | 16 (8 Γ— 2 grad accum) |
| Max sequence length | 512 |
| Weight decay | 0.01 |
| Warmup ratio | 0.1 |

### Hyperparameter Search

Three configurations were tested:

| Config | LR | Rank | Alpha | Description |
|--------|-----|------|-------|-------------|
| **A (selected)** | **2e-4** | **8** | **16** | **Conservative β€” fast convergence** |
| B | 1e-4 | 16 | 32 | Balanced |
| C | 5e-5 | 32 | 64 | Aggressive β€” high capacity |

Config A achieved the lowest validation loss. Higher-rank configs underfit due to insufficient training steps at their lower learning rates.

## Evaluation

### Metrics

Evaluated on 100 held-out test examples against unmodified Phi-2 baseline using:
- **ROUGE-1/2/L** β€” n-gram overlap (lexical similarity)
- **BERTScore F1** β€” semantic similarity via RoBERTa-Large embeddings

Key finding: significant ROUGE-2 improvement over baseline, confirming domain vocabulary acquisition. The model learned Elden Ring terminology and response structure. See the training notebook for exact metrics and visualizations.

### What the Model Learned

- Elden Ring domain vocabulary (Hemorrhage, Scarlet Rot, Frostbite, damage negation, FP cost)
- Entity type awareness (distinguishes weapons, bosses, spells, NPCs)
- Structured response formatting ("The {weapon} requires {X} Str, {Y} Dex to wield")
- Build archetype understanding (strength, dexterity, intelligence, faith, arcane)

### Known Limitations

- **Factual hallucination:** The model learned the correct output format but hallucinates specific values (wrong stat numbers, incorrect skill names, approximate weights). This is due to LoRA rank 8 having insufficient capacity to memorize entity-specific facts across hundreds of items.
- **Repetitive generation:** Some outputs may loop despite anti-repetition measures. Use `repetition_penalty=1.5` and `no_repeat_ngram_size=3`.
- **Cross-entity confusion:** May attribute one entity's properties to another similar entity.

### Recommended Improvement: RAG

The model's domain fluency + factual hallucination makes it ideal for **Retrieval-Augmented Generation**: retrieve entity data from the enriched dataset at inference time and inject it as context. The model already knows how to format the data β€” RAG just ensures it has the correct facts.

## Uses

### Intended Uses

- Elden Ring game knowledge QA
- Demonstrating QLoRA fine-tuning on domain-specific data
- Base for RAG-augmented game assistant systems
- Educational reference for parameter-efficient fine-tuning

### Out-of-Scope Uses

- Factual reference without verification (values may be hallucinated)
- Commercial game guide products
- General-purpose question answering outside Elden Ring

## Environmental Impact

- **Hardware:** NVIDIA A100 (40GB)
- **Training time:** ~48 minutes (3 configs Γ— ~16 min each)
- **Cloud provider:** Google Colab

## Citation

```bibtex
@misc{eldenring-phi2-qlora-2026,
  author = {ArenaRune},
  title = {Elden Ring QA β€” Phi-2 QLoRA Adapter},
  year = {2026},
  publisher = {HuggingFace},
  url = {https://huggingface.co/ArenaRune/elden-ring-phi2-qlora}
}
```