Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f94cc3c

Browse filesBrowse files
committed
Expanded text generation section
1 parent a1ef779 commit f94cc3c
Copy full SHA for f94cc3c

File tree

1 file changed

+68
-0
lines changed
Filter options

1 file changed

+68
-0
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+68Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,74 @@ SELECT pgml.transform(
566566
]
567567
]
568568
```
569+
570+
To use a specific model from :hugs: model hub, pass the model name along with task name in task.
571+
572+
```sql
573+
SELECT pgml.transform(
574+
task => '{
575+
"task" : "text-generation",
576+
"model" : "gpt2-medium"
577+
}'::JSONB,
578+
inputs => ARRAY[
579+
'Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone'
580+
]
581+
) AS answer;
582+
```
583+
*Result*
584+
```json
585+
[
586+
[{"generated_text": "Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone.\n\nThis place has a deep connection to the lore of ancient Elven civilization. It is home to the most ancient of artifacts,"}]
587+
]
588+
```
589+
To make the generated text longer, you can include the argument `max_length` and specify the desired maximum length of the text.
590+
591+
```sql
592+
SELECT pgml.transform(
593+
task => '{
594+
"task" : "text-generation",
595+
"model" : "gpt2-medium"
596+
}'::JSONB,
597+
inputs => ARRAY[
598+
'Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone'
599+
],
600+
args => '{
601+
"max_length" : 200
602+
}'::JSONB
603+
) AS answer;
604+
```
605+
*Result*
606+
```json
607+
[
608+
[{"generated_text": "Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone, Three for the Dwarfs and the Elves, One for the Gnomes of the Mines, and Two for the Elves of Dross.\"\n\nHobbits: The Fellowship is the first book of J.R.R. Tolkien's story-cycle, and began with his second novel - The Two Towers - and ends in The Lord of the Rings.\n\n\nIt is a non-fiction novel, so there is no copyright claim on some parts of the story but the actual text of the book is copyrighted by author J.R.R. Tolkien.\n\n\nThe book has been classified into two types: fantasy novels and children's books\n\nHobbits: The Fellowship is the first book of J.R.R. Tolkien's story-cycle, and began with his second novel - The Two Towers - and ends in The Lord of the Rings.It"}]
609+
]
610+
```
611+
If you want the model to generate more than one output, you can specify the number of desired output sequences by including the argument `num_return_sequences` in the arguments.
612+
613+
```sql
614+
SELECT pgml.transform(
615+
task => '{
616+
"task" : "text-generation",
617+
"model" : "gpt2-medium"
618+
}'::JSONB,
619+
inputs => ARRAY[
620+
'Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone'
621+
],
622+
args => '{
623+
"num_return_sequences" : 3
624+
}'::JSONB
625+
) AS answer;
626+
```
627+
*Result*
628+
```json
629+
[
630+
[
631+
{"generated_text": "Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone, and Thirteen for the human-men in their hall of fire.\n\nAll of us, our families, and our people"},
632+
{"generated_text": "Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone, and the tenth for a King! As each of these has its own special story, so I have written them into the game."},
633+
{"generated_text": "Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone… What's left in the end is your heart's desire after all!\n\nHans: (Trying to be brave)"}
634+
]
635+
]
636+
```
569637
### Text2Text Generation
570638
## Fill-Mask
571639
![fill mask](pgml-docs/docs/images/fill-mask.png)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.