Text Generation
Transformers
PyTorch
Safetensors
English
gpt2
simplification
text-generation-inference
Instructions to use philippelaban/keep_it_simple with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use philippelaban/keep_it_simple with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="philippelaban/keep_it_simple")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("philippelaban/keep_it_simple") model = AutoModelForCausalLM.from_pretrained("philippelaban/keep_it_simple") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use philippelaban/keep_it_simple with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "philippelaban/keep_it_simple" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "philippelaban/keep_it_simple", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/philippelaban/keep_it_simple
- SGLang
How to use philippelaban/keep_it_simple with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "philippelaban/keep_it_simple" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "philippelaban/keep_it_simple", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "philippelaban/keep_it_simple" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "philippelaban/keep_it_simple", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use philippelaban/keep_it_simple with Docker Model Runner:
docker model run hf.co/philippelaban/keep_it_simple
Commit ·
219e90d
1
Parent(s): f383261
Create first draft of the Model Card to help with usage of the model
Browse files
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.
|