smji commited on
Commit
efb732c
1 Parent(s): 777fdb6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -0
README.md CHANGED
@@ -1,3 +1,65 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - hakurei/open-instruct-v1
5
+ language:
6
+ - en
7
+ tags:
8
+ - code
9
+ - instruction-following
10
+ widget:
11
+ - text: Tell me how to bake a cake
12
+ example_title: Baking cakes
13
+ - text: How can I print a fibonacci series upto N in C++
14
+ example_title: Coding
15
  ---
16
+
17
+ # DialoGPT2 Instruction Following
18
+
19
+ This is the fine-tuned version of the [microsoft/dialogpt-small](https://huggingface.co/microsoft/DialoGPT-small) on the instruction following task. The dataset used was the [hakurei/open-instruct-v1](https://huggingface.co/datasets/hakurei/open-instruct-v1) dataset.
20
+
21
+ ## Using the model
22
+
23
+
24
+ ### Using `model.generate()`
25
+
26
+ To use the model, first call the checkpoints and initialize the model
27
+
28
+ ```python
29
+ # Load model directly
30
+ from transformers import AutoTokenizer, AutoModelForCausalLM
31
+
32
+ tokenizer = AutoTokenizer.from_pretrained("smji/dialogpt2-instruct-following")
33
+ model = AutoModelForCausalLM.from_pretrained("smji/dialogpt2-instruct-following")
34
+ ```
35
+
36
+ And then move onto generating the text
37
+
38
+ ```python
39
+ def generate_text(prompt):
40
+ inputs = tokenizer.encode(prompt, return_tensors='pt').to(device)
41
+ outputs = model.generate(inputs, max_length=512, pad_token_id=tokenizer.eos_token_id)
42
+ generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
43
+
44
+ return generated_text[:generated_text.rfind('.')+1]
45
+
46
+ generate_text("How can I bake a cake?")
47
+ ```
48
+
49
+ ### Using the pipeline
50
+
51
+ Or, you can also use the pipeline
52
+
53
+ ```python
54
+ # Use a pipeline as a high-level helper
55
+ from transformers import pipeline
56
+
57
+ pipe = pipeline("text-generation", model="smji/dialogpt2-instruct-following")
58
+
59
+ pipe("How can I bake a cake?", max_length=512)
60
+ ```
61
+
62
+ ---
63
+
64
+ Done by [S M Jishanul Islam](https://github.com/S-M-J-I)
65
+