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 c347f9b

Browse filesBrowse files
committed
Documentation for more tasks
1 parent fca5ef2 commit c347f9b
Copy full SHA for c347f9b

File tree

1 file changed

+106
-2
lines changed
Filter options

1 file changed

+106
-2
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+106-2Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,19 +450,123 @@ select pgml.transform(
450450
]]
451451
```
452452
## Translation
453+
Translation is the task of converting text written in one language into another language.
454+
453455
![translation](pgml-docs/docs/images/translation.png)
454456

457+
You have the option to select from over 2000 models available on the Hugging Face <a href="https://huggingface.co/models?pipeline_tag=translation" target="_blank">hub</a> for translation.
458+
459+
```sql
460+
select pgml.transform(
461+
inputs => array[
462+
'How are you?'
463+
],
464+
task => '{"task": "translation",
465+
"model": "Helsinki-NLP/opus-mt-en-fr"
466+
}'::JSONB
467+
);
468+
```
469+
*Result*
470+
```json
471+
[
472+
{"translation_text": "Comment allez-vous ?"}
473+
]
474+
```
455475
## Summarization
476+
Summarization involves creating a condensed version of a document that includes the important information while reducing its length. Different models can be used for this task, with some models extracting the most relevant text from the original document, while other models generate completely new text that captures the essence of the original content.
477+
456478
![summarization](pgml-docs/docs/images/summarization.png)
457479

480+
```sql
481+
select pgml.transform(
482+
task => '{"task": "summarization",
483+
"model": "sshleifer/distilbart-cnn-12-6"
484+
}'::JSONB,
485+
inputs => array[
486+
'Paris is the capital and most populous city of France, with an estimated population of 2,175,601 residents as of 2018, in an area of more than 105 square kilometres (41 square miles). The City of Paris is the centre and seat of government of the region and province of Île-de-France, or Paris Region, which has an estimated population of 12,174,880, or about 18 percent of the population of France as of 2017.'
487+
]
488+
);
489+
```
490+
*Result*
491+
```json
492+
[
493+
{"summary_text": " Paris is the capital and most populous city of France, with an estimated population of 2,175,601 residents as of 2018 . The city is the centre and seat of government of the region and province of Île-de-France, or Paris Region . Paris Region has an estimated 18 percent of the population of France as of 2017 ."}
494+
]
495+
```
496+
You can control the length of summary_text by passing `min_length` and `max_length` as arguments to the SQL query.
497+
498+
```sql
499+
select pgml.transform(
500+
task => '{"task": "summarization",
501+
"model": "sshleifer/distilbart-cnn-12-6"
502+
}'::JSONB,
503+
inputs => array[
504+
'Paris is the capital and most populous city of France, with an estimated population of 2,175,601 residents as of 2018, in an area of more than 105 square kilometres (41 square miles). The City of Paris is the centre and seat of government of the region and province of Île-de-France, or Paris Region, which has an estimated population of 12,174,880, or about 18 percent of the population of France as of 2017.'
505+
],
506+
args => '{
507+
"min_length" : 20,
508+
"max_length" : 70
509+
}'::JSONB
510+
);
511+
```
512+
513+
```json
514+
[
515+
{"summary_text": " Paris is the capital and most populous city of France, with an estimated population of 2,175,601 residents as of 2018 . City of Paris is centre and seat of government of the region and province of Île-de-France, or Paris Region, which has an estimated 12,174,880, or about 18 percent"
516+
}
517+
]
518+
```
458519
## Question Answering
520+
Question Answering models are designed to retrieve the answer to a question from a given text, which can be particularly useful for searching for information within a document. It's worth noting that some question answering models are capable of generating answers even without any contextual information.
521+
459522
![question answering](pgml-docs/docs/images/question-answering.png)
460523

461-
## Table Question Answering
462-
![table question answering](pgml-docs/docs/images/table-question-answering.png)
524+
```sql
525+
SELECT pgml.transform(
526+
'question-answering',
527+
inputs => ARRAY[
528+
'{
529+
"question": "Where do I live?",
530+
"context": "My name is Merve and I live in İstanbul."
531+
}'
532+
]
533+
) AS answer;
534+
```
535+
*Result*
536+
537+
```json
538+
{
539+
"end" : 39,
540+
"score" : 0.9538117051124572,
541+
"start" : 31,
542+
"answer": "İstanbul"
543+
}
544+
```
545+
<!-- ## Table Question Answering
546+
![table question answering](pgml-docs/docs/images/table-question-answering.png) -->
547+
463548
## Text Generation
549+
Text generation is the task of producing new text, such as filling in incomplete sentences or paraphrasing existing text. It has various use cases, including code generation and story generation. Completion generation models can predict the next word in a text sequence, while text-to-text generation models are trained to learn the mapping between pairs of texts, such as translating between languages. Popular models for text generation include GPT-based models, T5, T0, and BART. These models can be trained to accomplish a wide range of tasks, including text classification, summarization, and translation.
550+
464551
![text generation](pgml-docs/docs/images/text-generation.png)
465552

553+
```sql
554+
SELECT pgml.transform(
555+
task => 'text-generation',
556+
inputs => ARRAY[
557+
'Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone'
558+
]
559+
) AS answer;
560+
```
561+
*Result*
562+
563+
```json
564+
[
565+
[
566+
{"generated_text": "Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone, and eight for the Dragon-lords in their halls of blood.\n\nEach of the guild-building systems is one-man"}
567+
]
568+
]
569+
```
466570
### Text2Text Generation
467571
## Fill-Mask
468572
![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.