m-elio commited on
Commit
0caae98
1 Parent(s): 0b4618f

updated model card

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