forked from WDAqua/Qanary-question-answering-components
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow for multiple source and target langugages
- Loading branch information
Showing
10 changed files
with
108 additions
and
55 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
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
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
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,9 +1,10 @@ | ||
transformers | ||
torch | ||
SentencePiece | ||
qanary-helpers | ||
SPARQLWrapper | ||
Flask | ||
langid | ||
pytest | ||
pytest-env | ||
Flask==3.0.3 | ||
langid==1.1.6 | ||
pytest==8.3.2 | ||
pytest-env==1.1.3 | ||
qanary_helpers==0.2.2 | ||
SentencePiece==0.2.0 | ||
SPARQLWrapper==2.0.0 | ||
torch==2.4.0 | ||
transformers==4.44.0 | ||
qanary-helpers==0.2.2 |
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
Empty file.
13 changes: 13 additions & 0 deletions
13
qanary-component-MT-Python-HelsinkiNLP/utils/model_utils.py
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,13 @@ | ||
from transformers.models.marian.modeling_marian import MarianMTModel | ||
from transformers.models.marian.tokenization_marian import MarianTokenizer | ||
|
||
|
||
def load_models_and_tokenizers(supported_langs: dict): | ||
models = {} | ||
tokenizers = {} | ||
for s_lang in supported_langs.keys(): | ||
lang_models = {t_lang: MarianMTModel.from_pretrained(f'Helsinki-NLP/opus-mt-{s_lang}-{t_lang}') for t_lang in supported_langs[s_lang]} | ||
lang_tokenizers = {t_lang: MarianTokenizer.from_pretrained(f'Helsinki-NLP/opus-mt-{s_lang}-{t_lang}') for t_lang in supported_langs[s_lang]} | ||
models[s_lang] = lang_models | ||
tokenizers[s_lang] = lang_tokenizers | ||
return models, tokenizers |