Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# BERT-Base-Uncased Quantized Model for Twitter Tweet Sentiment Classification
|
2 |
+
|
3 |
+
This repository hosts a quantized version of the **T5-Base** model, fine-tuned for **Movie Script Writting**. The model is optimized for efficient deployment while maintaining high accuracy, making it suitable for resource-constrained environments such as mobile and edge devices.
|
4 |
+
|
5 |
+
## Model Details
|
6 |
+
|
7 |
+
- **Model Architecture:** T5-Base
|
8 |
+
- **Task:** Movie Script Writting
|
9 |
+
- **Dataset:** bookcorpus
|
10 |
+
- **Quantization:** Float16 (FP16)
|
11 |
+
- **Fine-tuning Framework:** Hugging Face Transformers
|
12 |
+
- **Inference Framework:** PyTorch
|
13 |
+
|
14 |
+
## Usage
|
15 |
+
|
16 |
+
### Installation
|
17 |
+
|
18 |
+
```sh
|
19 |
+
pip install transformers torch
|
20 |
+
```
|
21 |
+
|
22 |
+
### Loading the Model
|
23 |
+
|
24 |
+
```python
|
25 |
+
from transformers import BertForSequenceClassification, BertTokenizer
|
26 |
+
import torch
|
27 |
+
|
28 |
+
# Load quantized model
|
29 |
+
quantized_model_path = "path/to/bert_finetuned_fp16"
|
30 |
+
|
31 |
+
|
32 |
+
def generate_script(prompt):
|
33 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # Check available device
|
34 |
+
model.to(device) # Move model to the appropriate device
|
35 |
+
|
36 |
+
inputs = tokenizer(f"Generate a movie script: {prompt}", return_tensors="pt", truncation=True, padding="max_length", max_length=256)
|
37 |
+
inputs = {key: value.to(device) for key, value in inputs.items()} # Move inputs to same device as model
|
38 |
+
|
39 |
+
with torch.no_grad():
|
40 |
+
outputs = model.generate(**inputs, max_length=256, num_return_sequences=1)
|
41 |
+
|
42 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
43 |
+
|
44 |
+
# Test the script generator
|
45 |
+
prompt = "SCENE: EXT. DARK ALLEY - NIGHT"
|
46 |
+
print(generate_script(prompt))
|
47 |
+
|
48 |
+
|
49 |
+
## Performance Metrics
|
50 |
+
|
51 |
+
- **Accuracy:** 0.82
|
52 |
+
- **Inference Speed:** Faster due to FP16 quantization
|
53 |
+
|
54 |
+
## Fine-Tuning Details
|
55 |
+
|
56 |
+
### Dataset
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
### Training Configuration
|
61 |
+
|
62 |
+
- **Number of epochs:** 3
|
63 |
+
- **Batch size:** 8
|
64 |
+
- **Evaluation strategy:** Per epoch
|
65 |
+
- **Learning rate:** 2e-5
|
66 |
+
- **Optimizer:** AdamW
|
67 |
+
|
68 |
+
### Quantization
|
69 |
+
|
70 |
+
The model is quantized using **Post-Training Quantization (PTQ)** with **Float16 (FP16)**, which reduces model size and improves inference efficiency while maintaining accuracy.
|
71 |
+
|
72 |
+
## Repository Structure
|
73 |
+
|
74 |
+
```
|
75 |
+
.
|
76 |
+
βββ model/ # Contains the quantized model files
|
77 |
+
βββ tokenizer_config/ # Tokenizer configuration and vocabulary files
|
78 |
+
βββ model.safensors/ # Fine-tuned and quantized model
|
79 |
+
βββ README.md # Model documentation
|
80 |
+
```
|
81 |
+
|
82 |
+
## Limitations
|
83 |
+
|
84 |
+
- The model is optimized for English-language next-word prediction tasks.
|
85 |
+
- While quantization improves speed, minor accuracy degradation may occur.
|
86 |
+
- Performance on out-of-distribution text (e.g., highly technical or domain-specific data) may be limited.
|
87 |
+
|
88 |
+
## Contributing
|
89 |
+
|
90 |
+
Contributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.
|
91 |
+
``
|
92 |
+
|