Update README.md
Browse files
README.md
CHANGED
@@ -1,21 +1,9 @@
|
|
1 |
-
---
|
2 |
-
language: en
|
3 |
-
tags:
|
4 |
-
- text-generation
|
5 |
-
- YouTube-scripts
|
6 |
-
- fine-tuned
|
7 |
-
- causal-lm
|
8 |
-
datasets:
|
9 |
-
- custom
|
10 |
-
license: mit
|
11 |
-
model_name: Gemma 2 Scripter
|
12 |
-
---
|
13 |
-
|
14 |
# Gemma 2 Scripter
|
15 |
|
16 |
**Gemma 2 Scripter** is a fine-tuned version of the Gemma 2 2B instruct model designed for generating high-quality YouTube scripts based on provided keywords. It is optimized for text generation tasks, delivering coherent and contextually relevant outputs.
|
17 |
|
18 |
## Model Details
|
|
|
19 |
- **Model Name**: `Sidharthan/gemma2_scripter`
|
20 |
- **Architecture**: Causal Language Model
|
21 |
- **Base Model**: Gemma 2 2B
|
@@ -24,15 +12,16 @@ model_name: Gemma 2 Scripter
|
|
24 |
## How to Use
|
25 |
|
26 |
### Installation
|
|
|
27 |
Ensure you have the following dependencies installed:
|
|
|
28 |
```bash
|
29 |
pip install torch transformers peft
|
30 |
```
|
31 |
|
32 |
### Code Sample
|
33 |
|
34 |
-
python
|
35 |
-
|
36 |
from transformers import AutoTokenizer
|
37 |
from peft import AutoPeftModelForCausalLM
|
38 |
import torch
|
@@ -41,6 +30,7 @@ import torch
|
|
41 |
model_name = "Sidharthan/gemma2_scripter"
|
42 |
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
43 |
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
|
|
44 |
model = AutoPeftModelForCausalLM.from_pretrained(
|
45 |
model_name,
|
46 |
device_map=None,
|
@@ -51,9 +41,10 @@ model = AutoPeftModelForCausalLM.from_pretrained(
|
|
51 |
|
52 |
# Generate a script
|
53 |
def generate_script(prompt):
|
54 |
-
formatted_prompt = f"
|
55 |
inputs = tokenizer(formatted_prompt, return_tensors="pt")
|
56 |
inputs = {key: value.to(device) for key, value in inputs.items()}
|
|
|
57 |
outputs = model.generate(
|
58 |
**inputs,
|
59 |
max_length=1024,
|
@@ -65,6 +56,7 @@ def generate_script(prompt):
|
|
65 |
pad_token_id=tokenizer.pad_token_id,
|
66 |
eos_token_id=tokenizer.eos_token_id
|
67 |
)
|
|
|
68 |
return tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
|
69 |
|
70 |
# Example usage
|
@@ -77,23 +69,17 @@ print(f"Generated Script:\n{response}")
|
|
77 |
|
78 |
The model expects prompts in the following format:
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
<
|
83 |
-
|
84 |
-
<start_of_turn>script
|
85 |
-
|
86 |
```
|
87 |
|
88 |
Example:
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
crosshatch waffle texture, dark chocolate, four bar crispy wafers, kat, milk chocolate<end_of_turn>
|
94 |
-
<start_of_turn>script
|
95 |
-
|
96 |
-
|
97 |
```
|
98 |
|
99 |
### Output
|
@@ -105,11 +91,10 @@ The output is a YouTube script generated based on the keywords provided.
|
|
105 |
- CPU: Slower inference due to computational constraints.
|
106 |
- GPU: Optimized for faster inference with FP16 support.
|
107 |
|
108 |
-
|
109 |
### Applications
|
110 |
|
111 |
-
- Generating structured scripts for video content
|
112 |
-
- Keyword-based text generation for creative tasks
|
113 |
|
114 |
### License
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Gemma 2 Scripter
|
2 |
|
3 |
**Gemma 2 Scripter** is a fine-tuned version of the Gemma 2 2B instruct model designed for generating high-quality YouTube scripts based on provided keywords. It is optimized for text generation tasks, delivering coherent and contextually relevant outputs.
|
4 |
|
5 |
## Model Details
|
6 |
+
|
7 |
- **Model Name**: `Sidharthan/gemma2_scripter`
|
8 |
- **Architecture**: Causal Language Model
|
9 |
- **Base Model**: Gemma 2 2B
|
|
|
12 |
## How to Use
|
13 |
|
14 |
### Installation
|
15 |
+
|
16 |
Ensure you have the following dependencies installed:
|
17 |
+
|
18 |
```bash
|
19 |
pip install torch transformers peft
|
20 |
```
|
21 |
|
22 |
### Code Sample
|
23 |
|
24 |
+
```python
|
|
|
25 |
from transformers import AutoTokenizer
|
26 |
from peft import AutoPeftModelForCausalLM
|
27 |
import torch
|
|
|
30 |
model_name = "Sidharthan/gemma2_scripter"
|
31 |
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
32 |
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
33 |
+
|
34 |
model = AutoPeftModelForCausalLM.from_pretrained(
|
35 |
model_name,
|
36 |
device_map=None,
|
|
|
41 |
|
42 |
# Generate a script
|
43 |
def generate_script(prompt):
|
44 |
+
formatted_prompt = f"keywords\n{prompt}\nscript\n"
|
45 |
inputs = tokenizer(formatted_prompt, return_tensors="pt")
|
46 |
inputs = {key: value.to(device) for key, value in inputs.items()}
|
47 |
+
|
48 |
outputs = model.generate(
|
49 |
**inputs,
|
50 |
max_length=1024,
|
|
|
56 |
pad_token_id=tokenizer.pad_token_id,
|
57 |
eos_token_id=tokenizer.eos_token_id
|
58 |
)
|
59 |
+
|
60 |
return tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
|
61 |
|
62 |
# Example usage
|
|
|
69 |
|
70 |
The model expects prompts in the following format:
|
71 |
|
72 |
+
```
|
73 |
+
keywords
|
74 |
+
<your keywords here>
|
75 |
+
script
|
|
|
|
|
76 |
```
|
77 |
|
78 |
Example:
|
79 |
+
```
|
80 |
+
keywords
|
81 |
+
crosshatch waffle texture, dark chocolate, four bar crispy wafers, kat, milk chocolate
|
82 |
+
script
|
|
|
|
|
|
|
|
|
83 |
```
|
84 |
|
85 |
### Output
|
|
|
91 |
- CPU: Slower inference due to computational constraints.
|
92 |
- GPU: Optimized for faster inference with FP16 support.
|
93 |
|
|
|
94 |
### Applications
|
95 |
|
96 |
+
- Generating structured scripts for video content
|
97 |
+
- Keyword-based text generation for creative tasks
|
98 |
|
99 |
### License
|
100 |
|