-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Language Validation Test #257
Merged
heffernankevin
merged 46 commits into
facebookresearch:MLH-dev
from
NIXBLACK11:Language_model_validation
Nov 14, 2023
Merged
Changes from 8 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
8fc4b9a
test to validate languages
NIXBLACK11 9a3228b
test to validate languages
NIXBLACK11 ad9a588
Delete flores directory
NIXBLACK11 7f32d7a
Update validate_models.py
NIXBLACK11 ff3254b
Update validate_models.py
NIXBLACK11 cb2d91a
Update validate_models.py
NIXBLACK11 f4e84d2
Update validate_models.py
NIXBLACK11 109eac2
Update .gitignore
NIXBLACK11 2236fe0
added pytest to validate_models.py
NIXBLACK11 472657b
Update validate_models.py
NIXBLACK11 c744030
Update validate_models.py
NIXBLACK11 c71aec7
Update validate_models.py using mock downloader
NIXBLACK11 c816d79
Update validate_models.py
NIXBLACK11 31aa252
Update validate_models.py
NIXBLACK11 c34279d
Update validate_models.py
NIXBLACK11 8b25a3d
Update validate_models.py
NIXBLACK11 302d068
Update validate_models.py
NIXBLACK11 73f873f
Update download_models.py according to 1.
NIXBLACK11 5e04a2a
Update download_models.py
NIXBLACK11 e3552a7
Update download_models.py
NIXBLACK11 1d74246
Update download_models.py
NIXBLACK11 1bddd81
Update validate_models.py
NIXBLACK11 e4f3fd0
Update models.py
NIXBLACK11 03284a2
Update laser_tokenizer.py
NIXBLACK11 43f4d1a
Update download_models.py
NIXBLACK11 6ef54c2
Update validate_models.py
NIXBLACK11 89c9dde
Update validate_models.py
NIXBLACK11 d883ee0
Added slow and fast tests to validate_models.py
NIXBLACK11 e1e22a3
Update validate_models.py
NIXBLACK11 a8f4135
Update validate_models.py
NIXBLACK11 4cd83e8
Create test_validate_models.py
NIXBLACK11 e0be04f
Rename test_validate_models.py to test_models_initialization.py
NIXBLACK11 9ec012f
Update test_models_initialization.py
NIXBLACK11 fbbc6fc
Update test_models_initialization.py
NIXBLACK11 99ebbfd
Update download_models.py
NIXBLACK11 6356c4d
Update test_models_initialization.py
NIXBLACK11 eac3674
Update test_models_initialization.py
NIXBLACK11 d3935f9
Update download_models.py
NIXBLACK11 18c1657
Update validate_models.py
NIXBLACK11 c26e775
Update validate_models.py
NIXBLACK11 023eab2
Update validate_models.py
NIXBLACK11 3944556
Update validate_models.py
NIXBLACK11 0a4d983
Update validate_models.py
NIXBLACK11 e5823d6
Update validate_models.py
NIXBLACK11 92345be
Update validate_models.py
NIXBLACK11 87a08e9
Update validate_models.py
NIXBLACK11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import tempfile | ||
|
||
from laser_encoders.download_models import LaserModelDownloader | ||
from laser_encoders.language_list import LASER2_LANGUAGE, LASER3_LANGUAGE | ||
from laser_encoders.laser_tokenizer import initialize_tokenizer | ||
from laser_encoders.models import initialize_encoder | ||
|
||
|
||
def validate_language_models_and_tokenize(): | ||
with tempfile.TemporaryDirectory() as tmp_dir: | ||
print("Created temporary directory", tmp_dir) | ||
|
||
downloader = LaserModelDownloader(model_dir=tmp_dir) | ||
|
||
for lang in LASER3_LANGUAGE: | ||
# Use the downloader to download the model | ||
downloader.download_laser3(lang) | ||
encoder = initialize_encoder(lang, model_dir=tmp_dir) | ||
tokenizer = initialize_tokenizer(lang, model_dir=tmp_dir) | ||
# Test tokenization with a sample sentence | ||
tokenized = tokenizer.tokenize("This is a sample sentence.") | ||
|
||
for lang in LASER2_LANGUAGE: | ||
# Use the downloader to download the model | ||
downloader.download_laser2() | ||
encoder = initialize_encoder(lang, model_dir=tmp_dir, laser="laser2") | ||
tokenizer = initialize_tokenizer(lang, model_dir=tmp_dir) | ||
# Test tokenization with a sample sentence | ||
tokenized = tokenizer.tokenize("This is a sample sentence.") | ||
|
||
print("All language models validated and deleted successfully.") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we maybe do the pytest.mark.parametrize thing with this test, instead of looping over the language inside it?
This way, it would be easier to rerun it for a particular language, if e.g. we decide to fix a single language code