m-elio commited on
Commit
2f3c9e5
1 Parent(s): a2090ce

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -0
README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - text-generation-inference
6
+ ---
7
+
8
+ # Model Card for Mistral-7B for Story Generation
9
+
10
+ ### Model Description
11
+
12
+ <!-- Provide a longer summary of what this model is. -->
13
+
14
+ This model is a fine-tuned **Mistral-7B** model on stories from the [WritingPrompts dataset](https://huggingface.co/datasets/euclaise/writingprompts).
15
+
16
+ - **Language(s) (NLP):** English
17
+ - **Finetuned from model:** [Mistral-7B](https://huggingface.co/mistralai/Mistral-7B-v0.1)
18
+ - **Dataset used for fine-tuning:** [WritingPrompts](https://huggingface.co/datasets/euclaise/writingprompts)
19
+
20
+
21
+ ### Example of Usage
22
+
23
+ ```python
24
+ import torch
25
+
26
+ from transformers import AutoModelForCausalLM, AutoTokenizer
27
+ from transformers.trainer_utils import set_seed
28
+
29
+ set_seed(42)
30
+
31
+ model_id = "m-elio/Mistral-Writing-Prompts"
32
+
33
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
34
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
35
+
36
+ instruction_text = "Write a story for the writing prompt provided as input"
37
+ input_text = "A story about a dancer who tries to win the National championship."
38
+
39
+ prompt = "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n" \
40
+ f"### Instruction:\nWrite a story for the writing prompt provided as input\n\n" \
41
+ f"### Input:\n{input_text}\n\n" \
42
+ f"### Answer:\n"
43
+
44
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids
45
+ outputs = model.generate(input_ids=input_ids, top_k=0, top_p=0.92, do_sample=True, max_new_tokens=2048)
46
+
47
+ print(tokenizer.batch_decode(outputs.detach().cpu().numpy()[:, input_ids.shape[1]:], skip_special_tokens=True)[0])
48
+ ```
49
+