Update README.md
Browse files
README.md
CHANGED
|
@@ -1,124 +1,122 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
license: mit
|
| 3 |
-
language:
|
| 4 |
-
- en
|
| 5 |
-
base_model:
|
| 6 |
-
- distilbert/distilgpt2
|
| 7 |
-
library_name: transformers
|
| 8 |
tags:
|
| 9 |
-
- text-generation
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
---
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
"bos_token": "<|endoftext|>",
|
| 36 |
-
"clean_up_tokenization_spaces": false,
|
| 37 |
-
"eos_token": "<|endoftext|>",
|
| 38 |
-
"errors": "replace",
|
| 39 |
-
"extra_special_tokens": {},
|
| 40 |
-
"model_max_length": 1024,
|
| 41 |
-
"pad_token": "<|endoftext|>",
|
| 42 |
-
"tokenizer_class": "GPT2Tokenizer",
|
| 43 |
-
"unk_token": "<|endoftext|>"
|
| 44 |
-
}
|
| 45 |
-
```
|
| 46 |
-
- config.json
|
| 47 |
-
```json
|
| 48 |
-
{
|
| 49 |
-
"_num_labels": 1,
|
| 50 |
-
"activation_function": "gelu_new",
|
| 51 |
-
"architectures": [
|
| 52 |
-
"GPT2LMHeadModel"
|
| 53 |
-
],
|
| 54 |
-
"attn_pdrop": 0.1,
|
| 55 |
-
"bos_token_id": 50256,
|
| 56 |
-
"embd_pdrop": 0.1,
|
| 57 |
-
"eos_token_id": 50256,
|
| 58 |
-
"id2label": {
|
| 59 |
-
"0": "LABEL_0"
|
| 60 |
-
},
|
| 61 |
-
"initializer_range": 0.02,
|
| 62 |
-
"label2id": {
|
| 63 |
-
"LABEL_0": 0
|
| 64 |
-
},
|
| 65 |
-
"layer_norm_epsilon": 1e-05,
|
| 66 |
-
"model_type": "gpt2",
|
| 67 |
-
"n_ctx": 1024,
|
| 68 |
-
"n_embd": 768,
|
| 69 |
-
"n_head": 12,
|
| 70 |
-
"n_inner": null,
|
| 71 |
-
"n_layer": 6,
|
| 72 |
-
"n_positions": 1024,
|
| 73 |
-
"reorder_and_upcast_attn": false,
|
| 74 |
-
"resid_pdrop": 0.1,
|
| 75 |
-
"scale_attn_by_inverse_layer_idx": false,
|
| 76 |
-
"scale_attn_weights": true,
|
| 77 |
-
"summary_activation": null,
|
| 78 |
-
"summary_first_dropout": 0.1,
|
| 79 |
-
"summary_proj_to_labels": true,
|
| 80 |
-
"summary_type": "cls_index",
|
| 81 |
-
"summary_use_proj": true,
|
| 82 |
-
"task_specific_params": {
|
| 83 |
-
"text-generation": {
|
| 84 |
-
"do_sample": true,
|
| 85 |
-
"max_length": 50
|
| 86 |
-
}
|
| 87 |
-
},
|
| 88 |
-
"torch_dtype": "float32",
|
| 89 |
-
"transformers_version": "4.50.3",
|
| 90 |
-
"use_cache": true,
|
| 91 |
-
"vocab_size": 50257
|
| 92 |
-
}
|
| 93 |
```
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
```python
|
| 98 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
```
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
```python
|
| 105 |
from transformers import pipeline
|
| 106 |
|
| 107 |
pipe = pipeline("text-generation", model="kulia-moon/Text2GPT")
|
|
|
|
| 108 |
```
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
-p 8000:8000 \
|
| 117 |
-
--ipc=host \
|
| 118 |
-
vllm/vllm-openai:latest \
|
| 119 |
-
# --model kulia-moon/Text2GPT
|
| 120 |
```
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
| 123 |
docker exec -it my_vllm_container bash -c "vllm serve kulia-moon/Text2GPT"
|
| 124 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language: en
|
| 3 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
+
- text-generation
|
| 6 |
+
- transformers
|
| 7 |
+
- safetensors
|
| 8 |
+
base_model: distilbert/distilgpt2
|
| 9 |
+
parameters: 81912576
|
| 10 |
---
|
| 11 |
+
|
| 12 |
+
# Text2GPT ๐ค
|
| 13 |
+
|
| 14 |
+
Text2GPT is a lightweight text generation model fine-tuned from [DistilGPT2](https://huggingface.co/distilbert/distilgpt2), with 81.9M parameters, designed for efficient and coherent text generation. It leverages the power of transformers and supports Safetensors for secure model loading. Ideal for creative writing, text completion, and more! ๐
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## Features โจ
|
| 19 |
+
|
| 20 |
+
- Generates human-like text with minimal input ๐
|
| 21 |
+
- Supports Safetensors for safe and efficient loading ๐
|
| 22 |
+
- Fine-tuned for low-resource environments โก
|
| 23 |
+
- Compatible with Hugging Face `transformers` and vLLM ๐
|
| 24 |
+
|
| 25 |
+
## Installation ๐ ๏ธ
|
| 26 |
+
|
| 27 |
+
Install the required dependencies:
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
pip install transformers torch safetensors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
```
|
| 32 |
+
|
| 33 |
+
## Usage ๐ฎ
|
| 34 |
+
|
| 35 |
+
### Loading the Model with Transformers
|
| 36 |
+
|
| 37 |
+
Use the Hugging Face `transformers` library to load and generate text:
|
| 38 |
+
|
| 39 |
```python
|
| 40 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 41 |
|
| 42 |
+
# Load model and tokenizer
|
| 43 |
+
model_name = "kulia-moon/Text2GPT"
|
| 44 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 45 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 46 |
+
|
| 47 |
+
# Generate text
|
| 48 |
+
input_text = "Once upon a time"
|
| 49 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
| 50 |
+
outputs = model.generate(**inputs, max_length=50, do_sample=True)
|
| 51 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 52 |
```
|
| 53 |
+
|
| 54 |
+
### Using Pipeline for Simplicity
|
| 55 |
+
|
| 56 |
+
For quick text generation:
|
| 57 |
+
|
| 58 |
```python
|
| 59 |
from transformers import pipeline
|
| 60 |
|
| 61 |
pipe = pipeline("text-generation", model="kulia-moon/Text2GPT")
|
| 62 |
+
print(pipe("My name is Julien and I like to", max_length=30, do_sample=True)[0]["generated_text"])
|
| 63 |
```
|
| 64 |
+
|
| 65 |
+
### vLLM Deployment for Scalability
|
| 66 |
+
|
| 67 |
+
Deploy with vLLM for high-throughput inference:
|
| 68 |
+
|
| 69 |
+
```bash
|
| 70 |
+
docker run --runtime nvidia --gpus all -v ~/.cache/huggingface:/root/.cache/huggingface -p 8000:8000 --ipc=host vllm/vllm-openai:latest --model kulia-moon/Text2GPT
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
```
|
| 72 |
+
|
| 73 |
+
Then, serve the model:
|
| 74 |
+
|
| 75 |
+
```bash
|
| 76 |
docker exec -it my_vllm_container bash -c "vllm serve kulia-moon/Text2GPT"
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## Widget Examples ๐ฑ๏ธ
|
| 80 |
+
|
| 81 |
+
Try these prompts on the [model page](https://huggingface.co/kulia-moon/Text2GPT):
|
| 82 |
+
|
| 83 |
+
- "Once upon a time" โณ
|
| 84 |
+
- "My name is Julien and I like to" ๐
|
| 85 |
+
- "Paris is an amazing place to visit," ๐ผ
|
| 86 |
+
- "I like traveling by train because" ๐
|
| 87 |
+
|
| 88 |
+
**Example Output**:
|
| 89 |
+
|
| 90 |
+
**Input**: "Once upon a time"
|
| 91 |
+
**Output**: "Once upon a time, a curious AI roamed the digital realm, crafting tales of wonder."
|
| 92 |
+
|
| 93 |
+
## Model Details ๐
|
| 94 |
+
|
| 95 |
+
- **Architecture**: DistilGPT2-based, 6 layers, 81.9M parameters
|
| 96 |
+
- **Base Model**: [distilbert/distilgpt2](https://huggingface.co/distilbert/distilgpt2)
|
| 97 |
+
- **Safetensors**: Supported, 81,912,576 parameters (non-sharded, non-quantized)
|
| 98 |
+
- **Intended Use**: Text generation, creative writing, dialogue completion
|
| 99 |
+
- **Limitations**: May produce biased or repetitive outputs; not optimized for sensitive tasks
|
| 100 |
+
|
| 101 |
+
## Evaluation Report ๐
|
| 102 |
+
|
| 103 |
+
Evaluation metrics are under development. Preliminary tests suggest performance comparable to DistilGPT2 (perplexity ~21.1 on WikiText-103). Contributions for detailed metrics are welcome via [discussions](https://huggingface.co/kulia-moon/Text2GPT/discussions)! ๐
|
| 104 |
+
|
| 105 |
+
## Requirements โ๏ธ
|
| 106 |
+
|
| 107 |
+
- Python 3.8+
|
| 108 |
+
- `transformers>=4.30.0`
|
| 109 |
+
- `torch>=2.0.0`
|
| 110 |
+
- `safetensors>=0.4.0`
|
| 111 |
+
|
| 112 |
+
## License ๐
|
| 113 |
+
|
| 114 |
+
This model is licensed under the [MIT License](https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/mit.md).
|
| 115 |
+
|
| 116 |
+
## Community & Support ๐ฌ
|
| 117 |
+
|
| 118 |
+
Join the conversation or seek help at:
|
| 119 |
+
- [Hugging Face Discussions](https://huggingface.co/kulia-moon/Text2GPT/discussions)
|
| 120 |
+
- [Model Page](https://huggingface.co/kulia-moon/Text2GPT)
|
| 121 |
+
|
| 122 |
+
Contributions and feedback are welcome! ๐
|