updated model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
tags:
|
| 5 |
+
- text-generation-inference
|
| 6 |
+
license: llama2
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
# Model Card for LLaMA 2 Spell Generation
|
| 10 |
+
|
| 11 |
+
### Model Description
|
| 12 |
+
|
| 13 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 14 |
+
|
| 15 |
+
This model is a fine-tuned **llama-2-13b** model for the generation of *D&D 5th edition spells*
|
| 16 |
+
|
| 17 |
+
- **Language(s) (NLP):** English
|
| 18 |
+
- **Finetuned from model:** [llama-2-13b](https://huggingface.co/meta-llama/Llama-2-13b-hf)
|
| 19 |
+
- **Dataset used for fine-tuning:** [m-elio/spell_generation](https://huggingface.co/datasets/m-elio/spell_generation)
|
| 20 |
+
|
| 21 |
+
## Prompt Format
|
| 22 |
+
|
| 23 |
+
This prompt format based on the Alpaca model was used for fine-tuning:
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
"Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n" \
|
| 27 |
+
f"### Instruction:\n{instruction}\n\n### Response:\n{response}"
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
It is recommended to use the same prompt in inference to obtain the best results!
|
| 31 |
+
|
| 32 |
+
## Output Format
|
| 33 |
+
|
| 34 |
+
The output format for a generated spell should be the following:
|
| 35 |
+
|
| 36 |
+
```
|
| 37 |
+
Name:
|
| 38 |
+
Level:
|
| 39 |
+
School:
|
| 40 |
+
Classes:
|
| 41 |
+
Casting time:
|
| 42 |
+
Range:
|
| 43 |
+
Duration:
|
| 44 |
+
Components: [If no components are required, then this field has a None value]
|
| 45 |
+
Material cost: [If there is no "M" character in the Components field, then this field is skipped]
|
| 46 |
+
Description:
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
Example:
|
| 50 |
+
|
| 51 |
+
```
|
| 52 |
+
Name: The Shadow
|
| 53 |
+
Level: 1
|
| 54 |
+
School: Evocation
|
| 55 |
+
Classes: Bard, Cleric, Druid, Ranger, Sorcerer, Warlock, Wizard
|
| 56 |
+
Casting time: 1 Action
|
| 57 |
+
Range: Self
|
| 58 |
+
Duration: Concentration, Up To 1 Minute
|
| 59 |
+
Components: V, S, M
|
| 60 |
+
Material cost: a small piece of cloth
|
| 61 |
+
Description: You touch a creature within range. The target must make a Dexterity saving throw. On a failed save, the target takes 2d6 psychic damage and is charmed by you. On a successful save, the target takes half as much damage.
|
| 62 |
+
At Higher Levels. When you cast this spell using a spell slot of 4th level or higher, the damage increases by 1d6 for each slot level above 1st.
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
## Example use
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 70 |
+
|
| 71 |
+
model_id = "m-elio/spell_generation_llama-2-13b"
|
| 72 |
+
|
| 73 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 74 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 75 |
+
|
| 76 |
+
instruction = "Write a spell for the 5th edition of the Dungeons & Dragons game."
|
| 77 |
+
|
| 78 |
+
prompt = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n" \
|
| 79 |
+
f"### Instruction:\n{instruction}\n\n### Response:\n"
|
| 80 |
+
|
| 81 |
+
tokenized_input = tokenizer(prompt, return_tensors="pt")
|
| 82 |
+
outputs = model.generate(**tokenized_input, max_length=512)
|
| 83 |
+
|
| 84 |
+
print(tokenizer.batch_decode(outputs.detach().cpu().numpy()[:, tokenized_input.input_ids.shape[1]:], skip_special_tokens=True)[0])
|
| 85 |
+
```
|