Presets
skai.presets gives common tasks a name. Every preset is a function that returns an ordinary component with its
instructions, operation or by set, and passes extra keyword arguments, such as backend, max_length or
k_shot, to the component. The result clones, tunes with GridSearchCV and fits in a pipeline exactly like the
component it is.
from sklearn.base import clone
from skai import presets
summarizer = presets.summarizer(max_length=50, backend='dummy')
print(type(summarizer).__name__, summarizer.max_length, summarizer.instructions)
print(clone(presets.translator('Greek', backend='dummy')).fit().predict(['Good morning']))
TextToTextGenerator 50 Summarize the text, keeping its main points.
['Good morning']
Available presets
The table lists every preset, the component it returns, and the parameters it sets besides the arguments shown, which are required.
| Preset | Returns | Configuration |
|---|---|---|
presets.animator() |
ImageToVideoGenerator |
operation='animate' |
presets.background_remover() |
ImageToImageGenerator |
operation='remove_background' |
presets.describer() |
ImageToTextGenerator |
instructions='Describe the image in a few sentences.'operation='instruct' |
presets.diarizer() |
AudioSegmenter |
by='speaker' |
presets.document_parser() |
ImageToTextGenerator |
format='markdown'operation='transcribe' |
presets.lip_syncer() |
MultimodalToVideoGenerator |
operation='lip_sync' |
presets.moderator() |
MultimodalClassifier |
instructions='Decide whether the sample is appropriate for a general audience.'labels=['safe', 'unsafe'] |
presets.music_generator() |
TextToAudioGenerator |
operation='music' |
presets.object_detector(labels=['person']) |
ImageSegmenter |
by='object' |
presets.ocr() |
ImageToTextGenerator |
operation='transcribe' |
presets.prompt_writer() |
TextToTextGenerator |
instructions='Write one detailed prompt for an image generation model that shows the text.'operation='instruct' |
presets.question_answerer(question='What is shown?') |
TextToTextGenerator |
instructions='Answer this question about the text: What is shown?'operation='instruct' |
presets.quiz_writer() |
TextToTextGenerator |
instructions='Write 5 multiple-choice questions, with their answers, that test the text.'operation='instruct' |
presets.rewriter() |
TextToTextGenerator |
instructions='Rewrite the text in a clear and concise style, keeping its meaning.'operation='instruct' |
presets.script_writer() |
TextToTextGenerator |
instructions='Write a one-minute video narration script from the text, as the words to be spoken only.'operation='instruct' |
presets.separator() |
AudioToAudioGenerator |
operation='separate' |
presets.shot_detector() |
VideoSegmenter |
by='shot' |
presets.storyboarder() |
TextExtractor |
fields={'scenes': [{'narration': 'the words spoken in the scene', 'visual': 'what the viewer sees'}]}instructions='Split the text into a few scenes, each with the narration and what the viewer sees.' |
presets.summarizer() |
TextToTextGenerator |
instructions='Summarize the text, keeping its main points.'max_length='auto'operation='instruct' |
presets.talking_head(avatar='portrait.png') |
AudioToVideoGenerator |
operation='talking_head' |
presets.translator(target_language='Greek') |
TextToTextGenerator |
instructions='Translate the text into Greek, keeping its meaning, tone and formatting.'learn_terms=Trueoperation='instruct' |
presets.upscaler() |
ImageToImageGenerator |
operation='upscale' |
presets.voice_converter(voice='voice.wav') |
AudioToAudioGenerator |
operation='convert_voice' |
Instructions
skai.presets.INSTRUCTIONS holds the instructions of the presets that are text generators, extractors or
classifiers. The names in braces are filled from the arguments of the preset, and {kind} is the input kind, such
as image or video. The strings can be reused or adapted in a component of your own.
| Preset | Instructions |
|---|---|
summarizer |
Summarize the text, keeping its main points. |
translator |
Translate the text into {target_language}, keeping its meaning, tone and formatting. |
rewriter |
Rewrite the text in a {style} style, keeping its meaning. |
describer |
Describe the {kind} in a few sentences. |
question_answerer |
Answer this question about the {kind}: {question} |
script_writer |
Write a {length} {format} script from the text, as the words to be spoken only. |
prompt_writer |
Write one detailed prompt for an {target} generation model that shows the text. |
quiz_writer |
Write {n_questions} multiple-choice questions, with their answers, that test the text. |
storyboarder |
Split the text into {n_scenes} scenes, each with the narration and what the viewer sees. |
moderator |
Decide whether the {kind} is appropriate for a general audience. |
from skai.generation import VideoToTextGenerator
from skai.presets import INSTRUCTIONS
instructions = INSTRUCTIONS['question_answerer'].format(kind='video', question='Who scores?')
print(VideoToTextGenerator(instructions=instructions, backend='dummy').instructions)
Answer this question about the video: Who scores?
The API reference is in skai.presets.