初始化项目,由ModelHub XC社区提供模型
Model: philippelaban/keep_it_simple Source: Original Platform
This commit is contained in:
18
.gitattributes
vendored
Normal file
18
.gitattributes
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
74
README.md
Normal file
74
README.md
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
language:
|
||||
- en
|
||||
tags:
|
||||
- simplification
|
||||
license: apache-2.0
|
||||
datasets:
|
||||
- cnn_dailymail
|
||||
widget:
|
||||
- text: "A capsule containing asteroid soil samples landed in the Australian Outback. The precision required to carry out the mission thrilled many.<|endoftext|>"
|
||||
example_title: "Example 1"
|
||||
---
|
||||
|
||||
# Try out in the Hosted inference API
|
||||
In the right panel, you can try the model (although it only handles a short sequence length).
|
||||
Feel free to try Example 1, and modify it to inspect model ability.
|
||||
|
||||
|
||||
# Model Loading
|
||||
|
||||
The model can be loaded in the following way:
|
||||
```
|
||||
from transformers import AutoTokenizer, AutoModelForCausalLM
|
||||
import torch
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained("philippelaban/keep_it_simple")
|
||||
kis_model = AutoModelForCausalLM.from_pretrained("philippelaban/keep_it_simple")
|
||||
```
|
||||
|
||||
# Example use
|
||||
|
||||
And then used by first inputting a paragraph for simplification, followed by a `bos_token` to indicate to the model to start simplifying.
|
||||
Imagine we want to simplify the following 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.
|
||||
```
|
||||
|
||||
The following code can be run:
|
||||
```
|
||||
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."""
|
||||
|
||||
start_id = tokenizer.bos_token_id
|
||||
tokenized_paragraph = [(tokenizer.encode(text=paragraph) + [start_id])]
|
||||
input_ids = torch.LongTensor(tokenized_paragraph)
|
||||
|
||||
output_ids = kis_model.generate(input_ids, max_length=150, num_beams=4, do_sample=True, num_return_sequences=8)
|
||||
output_ids = output_ids[:, input_ids.shape[1]:]
|
||||
output = tokenizer.batch_decode(output_ids)
|
||||
output = [o.replace(tokenizer.eos_token, "") for o in output]
|
||||
|
||||
for o in output:
|
||||
print("----")
|
||||
print(o)
|
||||
```
|
||||
|
||||
# Example output
|
||||
|
||||
When run, an output similar to the following should be obtained:
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
# Github repo
|
||||
|
||||
You can access more information, access to the scoring function, the training script, or an example training log on the Github repo:
|
||||
https://github.com/tingofurro/keep_it_simple
|
||||
39
config.json
Normal file
39
config.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"_name_or_path": "gpt2-medium",
|
||||
"activation_function": "gelu_new",
|
||||
"architectures": [
|
||||
"GPT2LMHeadModel"
|
||||
],
|
||||
"attn_pdrop": 0.1,
|
||||
"bos_token_id": 50256,
|
||||
"embd_pdrop": 0.1,
|
||||
"eos_token_id": 50256,
|
||||
"gradient_checkpointing": false,
|
||||
"initializer_range": 0.02,
|
||||
"layer_norm_epsilon": 1e-05,
|
||||
"model_type": "gpt2",
|
||||
"n_ctx": 1024,
|
||||
"n_embd": 1024,
|
||||
"n_head": 16,
|
||||
"n_inner": null,
|
||||
"n_layer": 24,
|
||||
"n_positions": 1024,
|
||||
"n_special": 0,
|
||||
"predict_special_tokens": true,
|
||||
"resid_pdrop": 0.1,
|
||||
"scale_attn_weights": true,
|
||||
"summary_activation": null,
|
||||
"summary_first_dropout": 0.1,
|
||||
"summary_proj_to_labels": true,
|
||||
"summary_type": "cls_index",
|
||||
"summary_use_proj": true,
|
||||
"task_specific_params": {
|
||||
"text-generation": {
|
||||
"do_sample": true,
|
||||
"max_length": 50
|
||||
}
|
||||
},
|
||||
"transformers_version": "4.8.2",
|
||||
"use_cache": true,
|
||||
"vocab_size": 50257
|
||||
}
|
||||
50001
merges.txt
Normal file
50001
merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b83c0d72444e69094b51b8ad5a048ae1d0203f3b43396776873402511be1dcdd
|
||||
size 1444493752
|
||||
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7eb9c93de94a4ffc988db3dba9e9d614465e66761c880e0d72bf10c028b4131e
|
||||
size 1444589475
|
||||
1
special_tokens_map.json
Normal file
1
special_tokens_map.json
Normal file
@@ -0,0 +1 @@
|
||||
{"bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "unk_token": "<|endoftext|>", "pad_token": "!"}
|
||||
1
tokenizer.json
Normal file
1
tokenizer.json
Normal file
File diff suppressed because one or more lines are too long
1
tokenizer_config.json
Normal file
1
tokenizer_config.json
Normal file
@@ -0,0 +1 @@
|
||||
{"unk_token": "<|endoftext|>", "bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "add_prefix_space": false, "model_max_length": 1024, "special_tokens_map_file": null, "name_or_path": "gpt2-medium", "tokenizer_class": "GPT2Tokenizer"}
|
||||
1
vocab.json
Normal file
1
vocab.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user