forked from BeastByteAI/scikit-llm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8d3155
commit 3d008d7
Showing
7 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from skllm.datasets.multi_class import get_classification_dataset | ||
from skllm.datasets.multi_label import get_multilabel_classification_dataset | ||
from skllm.datasets.summarization import get_summarization_dataset | ||
from skllm.datasets.summarization import get_summarization_dataset | ||
from skllm.datasets.translation import get_translation_dataset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
def get_translation_dataset(): | ||
X = [ | ||
r"Me encanta bailar salsa y bachata. Es una forma divertida de expresarme.", | ||
r"J'ai passé mes dernières vacances en Grèce. Les plages étaient magnifiques.", | ||
( | ||
r"Ich habe gestern ein tolles Buch gelesen. Die Geschichte war fesselnd bis" | ||
r" zum Ende." | ||
), | ||
( | ||
r"Gosto de cozinhar pratos tradicionais italianos. O espaguete à carbonara" | ||
r" é um dos meus favoritos." | ||
), | ||
( | ||
r"Mám v plánu letos v létě vyrazit na výlet do Itálie. Doufám, že navštívím" | ||
r" Řím a Benátky." | ||
), | ||
( | ||
r"Mijn favoriete hobby is fotograferen. Ik hou ervan om mooie momenten vast" | ||
r" te leggen." | ||
), | ||
] | ||
|
||
return X |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from skllm.preprocessing.gpt_summarizer import GPTSummarizer | ||
from skllm.preprocessing.gpt_translator import GPTTranslator | ||
from skllm.preprocessing.gpt_vectorizer import GPTVectorizer | ||
from skllm.preprocessing.gpt_summarizer import GPTSummarizer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from typing import Optional | ||
|
||
from skllm.openai.base_gpt import BaseZeroShotGPTTransformer as _BaseGPT | ||
from skllm.prompts.builders import build_translation_prompt | ||
|
||
|
||
class GPTTranslator(_BaseGPT): | ||
"""A text translator.""" | ||
|
||
system_msg = "You are a text translator." | ||
default_output = "Translation is unavailable." | ||
|
||
def __init__( | ||
self, | ||
openai_key: Optional[str] = None, | ||
openai_org: Optional[str] = None, | ||
openai_model: str = "gpt-3.5-turbo", | ||
output_language: str = "English", | ||
): | ||
self._set_keys(openai_key, openai_org) | ||
self.openai_model = openai_model | ||
self.output_language = output_language | ||
|
||
def _get_prompt(self, X: str) -> str: | ||
"""Generates the prompt for the given input. | ||
Parameters | ||
---------- | ||
X : str | ||
sample to translate | ||
Returns | ||
------- | ||
str | ||
translated sample | ||
""" | ||
return build_translation_prompt(X, self.output_language) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters