Views
No views yet
1"Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n" \
2f"### Instruction:\n{instruction}\n\n### Response:\n{response}"Name:
Level:
School:
Classes:
Casting time:
Range:
Duration:
Components: [If no components are required, then this field has a None value]
Material cost: [If there is no "M" character in the Components field, then this field is skipped]
Description:Name: The Shadow
Level: 1
School: Evocation
Classes: Bard, Cleric, Druid, Ranger, Sorcerer, Warlock, Wizard
Casting time: 1 Action
Range: Self
Duration: Concentration, Up To 1 Minute
Components: V, S, M
Material cost: a small piece of cloth
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.
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.1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "m-elio/spell_generation_opt-2.7b"
4
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id)
7
8instruction = "Write a spell for the 5th edition of the Dungeons & Dragons game."
9
10prompt = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n" \
11f"### Instruction:\n{instruction}\n\n### Response:\n"
12
13tokenized_input = tokenizer(prompt, return_tensors="pt")
14outputs = model.generate(**tokenized_input, max_length=512)
15
16print(tokenizer.batch_decode(outputs.detach().cpu().numpy()[:, tokenized_input.input_ids.shape[1]:], skip_special_tokens=True)[0])