philippelaban commited on
Commit
219e90d
1 Parent(s): f383261

Create first draft of the Model Card to help with usage of the model

Browse files
Files changed (1) hide show
  1. README.md +36 -0
README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The model can be loaded in the following way:
2
+ ```
3
+ from transformers import AutoTokenizer, AutoModelForCausalLM
4
+ import torch
5
+
6
+ tokenizer = AutoTokenizer.from_pretrained("philippelaban/keep_it_simple")
7
+ kis_model = AutoModelForCausalLM.from_pretrained("philippelaban/keep_it_simple")
8
+ ```
9
+
10
+ And then used by first inputting a paragraph for simplification, followed by a `bos_token` to indicate to the model to start simplifying:
11
+ ```
12
+ paragraph = """A small capsule containing asteroid soil samples that was dropped from 136,700 miles in space by Japan's Hayabusa2 spacecraft landed as planned in the Australian Outback on December 6. The extremely high precision required to carry out the mission thrilled many in Japan, who said they took pride in its success."""
13
+
14
+ start_id = tokenizer.bos_token_id
15
+ tokenized_paragraph = [(tokenizer.encode(text=paragraph) + [start_id])]
16
+ input_ids = torch.LongTensor(tokenized_paragraph)
17
+
18
+ output_ids = kis_model.generate(input_ids, max_length=150, num_beams=4, do_sample=True, num_return_sequences=8)
19
+ output_ids = output_ids[:, input_ids.shape[1]:]
20
+ output = tokenizer.batch_decode(output_ids)
21
+ output = [o.replace(tokenizer.eos_token, "") for o in output]
22
+
23
+ for o in output:
24
+ print("----")
25
+ print(o)
26
+ ```
27
+
28
+ When run, an output similar to the following should be obtained:
29
+
30
+ A small capsule containing samples of asteroid soil that was dropped from 136,700 miles, Japan's Hayabusa2 space probe, landed as planned on December 6. The mission was extremely precise, said many in Japan, and they took pride in its success.
31
+
32
+ A small capsule containing samples of asteroid soil that was dropped from 136,700 miles, Japan's Hayabusa2 space probe, landed as planned on December 6. The mission was extremely precise and well thought-out, said many in Japan, who took pride in the mission.
33
+
34
+ A small capsule containing soil samples that was dropped from 136,700 miles, Japan's Hayabusa2 space probe, landed as planned on December 6. The mission was designed to test the performance of the country's space fleet, which many said took pride in its success.
35
+
36
+ A small capsule containing soil samples that was dropped from 136,700 miles in space by Japan's Hayabusa2 probe was followed by a landing on the Outback. The precise timing of the mission thrilled many in Japan, who said they took pride in its success.