Update README.md
Browse files
README.md
CHANGED
@@ -7,28 +7,28 @@ This model will generate instructions given some text. It is useful for labelli
|
|
7 |
|
8 |
It was trained across the [reverse-instruct](https://huggingface.co/vikp/reverse_instruct) dataset for 2 epochs. Final validation loss was .72, with rouge-l of .66 .
|
9 |
|
10 |
-
Here is an inference example:
|
11 |
|
12 |
```
|
13 |
-
|
14 |
-
|
15 |
-
model = AutoModelForCausalLM.from_pretrained("vikp/reverse_instruct")
|
16 |
-
tokenizer = AutoTokenizer.from_pretrained("vikp/reverse_instruct")
|
17 |
-
|
18 |
-
prompt = """
|
19 |
Output
|
20 |
|
21 |
-
|
22 |
-
|
23 |
======
|
24 |
Instruction
|
25 |
|
26 |
-
""".
|
|
|
|
|
|
|
27 |
|
28 |
inputs = tokenizer(prompt, return_tensors="pt")
|
29 |
outputs = model.generate(**inputs, max_new_tokens=512)
|
30 |
texts = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
|
|
31 |
print(texts)
|
32 |
```
|
33 |
|
34 |
-
And the output instruction for the above example would be `
|
|
|
|
|
|
7 |
|
8 |
It was trained across the [reverse-instruct](https://huggingface.co/vikp/reverse_instruct) dataset for 2 epochs. Final validation loss was .72, with rouge-l of .66 .
|
9 |
|
10 |
+
Here is an inference example, with some random text from falcon-refinedweb:
|
11 |
|
12 |
```
|
13 |
+
template = """
|
|
|
|
|
|
|
|
|
|
|
14 |
Output
|
15 |
|
16 |
+
{output}
|
|
|
17 |
======
|
18 |
Instruction
|
19 |
|
20 |
+
""".lstrip()
|
21 |
+
|
22 |
+
text = "Many of the programmers, engineers and developers we talk to have a secret that they don't reveal until they know people pretty well. No, I'm not talking about the complete set of Star Wars playing cards they have stashed in the basement or the Rush LPs they haven't gotten around to trading in yet. I'm talking about Legos. You remember Legos, those infinitely malleable blocks that children around the world use to construct everything from tiny towers to life-size towers. Perhaps because these toys leave so much to the imagination, they've captured the imagination of a generation of tech workers. The appearance of Lego in Douglas Copeland's novel Microserfs, set on the Microsoft corporate campus, is one example of how pervasive it is."
|
23 |
+
prompt = template.format(output=text)
|
24 |
|
25 |
inputs = tokenizer(prompt, return_tensors="pt")
|
26 |
outputs = model.generate(**inputs, max_new_tokens=512)
|
27 |
texts = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
28 |
+
texts = [t.replace(template, "") for t in texts]
|
29 |
print(texts)
|
30 |
```
|
31 |
|
32 |
+
And the output instruction for the above example would be `What is a secret that many programmers, engineers and developers don't reveal until they know people pretty well?`
|
33 |
+
|
34 |
+
It works with code, too, although llama-7b is undertrained on code.
|