You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You have the option to select from over 2000 models available on the Hugging Face <ahref="https://huggingface.co/models?pipeline_tag=translation"target="_blank">hub</a> for translation.
458
+
459
+
```sql
460
+
selectpgml.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
+
```
455
475
## 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.
'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
+
selectpgml.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
+
```
458
519
## 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.
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.
'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"}
0 commit comments