Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

intel-extension-for-transformers.ipynb #1696

Open
ayttop opened this issue Aug 30, 2024 · 3 comments
Open

intel-extension-for-transformers.ipynb #1696

ayttop opened this issue Aug 30, 2024 · 3 comments

Comments

@ayttop
Copy link

ayttop commented Aug 30, 2024

!git clone https://github.com/intel/intel-extension-for-transformers.git

!pip install intel-extension-for-transformers

!pip install --upgrade neural_compressor==2.6

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path Helsinki-NLP/opus-mt-en-ro
--do_train
--do_eval
--source_lang en
--target_lang ro
--dataset_name wmt/wmt16
--dataset_config_name ro-en
--output_dir /tmp/tst-translation
--per_device_train_batch_size 4
--per_device_eval_batch

from datasets import load_dataset

اسم مجموعة البيانات التي تريد تحميلها (مثلاً: 'wmt16' للترجمة)

dataset_name = 'wmt16'
dataset_config_name = 'ro-en' # تكوين مجموعة البيانات، إذا كان موجوداً

تحميل مجموعة البيانات

dataset = load_dataset(dataset_name, dataset_config_name)

عرض بعض الأمثلة من مجموعة البيانات

print("Train Examples:")
for example in dataset['train'][:2]:
print(example)

print("\nValidation Examples:")
for example in dataset['validation'][:2]:
print(example)

print("\nTest Examples:")
for example in dataset['test'][:2]:
print(example)

!pip install sacrebleu==2.2.1

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path Helsinki-NLP/opus-mt-en-ro
--do_train
--do_eval
--source_lang en
--target_lang ro
--dataset_name wmt16
--dataset_config_name ro-en
--output_dir /tmp/tst-translation
--per_device_train_batch_size 4
--per_device_eval_batch_size 4
--overwrite_output_dir
--tune
--predict_with_generate

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_train
--do_eval
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:For system requirements and other installation tips please refer to Installation Guide "
--dataset_name wmt16
--dataset_config_name ro-en
--output_dir /tmp/tst-translation
--per_device_train_batch_size 4
--per_device_eval_batch_size 4
--overwrite_output_dir
--tune
--predict_with_generate

!pip uninstall tensorflow
!pip install tensorflow # Make sure to install the version compatible with your CUDA version

@ayttop
Copy link
Author

ayttop commented Aug 30, 2024

It doesn't work and doesn't translate a sentence or a text file.

@ayttop
Copy link
Author

ayttop commented Aug 30, 2024

!git clone https://github.com/intel/intel-extension-for-transformers.git

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path Helsinki-NLP/opus-mt-en-ro
--do_train
--do_eval
--source_lang en
--target_lang ro
--dataset_name wmt/wmt16
--dataset_config_name ro-en
--output_dir /tmp/tst-translation
--per_device_train_batch_size 4
--per_device_eval_batch_size 4
--overwrite_output_dir
--tune
--predict_with_generate

!pip install intel-extension-for-transformers

!pip install --upgrade neural_compressor==2.6

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path Helsinki-NLP/opus-mt-en-ro
--do_train
--do_eval
--source_lang en
--target_lang ro
--dataset_name wmt/wmt16
--dataset_config_name ro-en
--output_dir /tmp/tst-translation
--per_device_train_batch_size 4
--per_device_eval_batch

!pip install intel-extension-for-transformers

!pip install datasets

from datasets import load_dataset

اسم مجموعة البيانات التي تريد تحميلها (مثلاً: 'wmt16' للترجمة)

dataset_name = 'wmt16'
dataset_config_name = 'ro-en' # تكوين مجموعة البيانات، إذا كان موجوداً

تحميل مجموعة البيانات

dataset = load_dataset(dataset_name, dataset_config_name)

عرض بعض الأمثلة من مجموعة البيانات

print("Train Examples:")
for example in dataset['train'][:2]:
print(example)

print("\nValidation Examples:")
for example in dataset['validation'][:2]:
print(example)

print("\nTest Examples:")
for example in dataset['test'][:2]:
print(example)

!pip install sacrebleu==2.2.1

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path Helsinki-NLP/opus-mt-en-ro
--do_train
--do_eval
--source_lang en
--target_lang ro
--dataset_name wmt16
--dataset_config_name ro-en
--output_dir /tmp/tst-translation
--per_device_train_batch_size 4
--per_device_eval_batch_size 4
--overwrite_output_dir
--tune
--predict_with_generate

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_train
--do_eval
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian: "
--dataset_name wmt16
--dataset_config_name ro-en
--output_dir /tmp/tst-translation
--per_device_train_batch_size 4
--per_device_eval_batch_size 4
--overwrite_output_dir
--tune
--predict_with_generate

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_train
--do_eval
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:For system requirements and other installation tips please refer to Installation Guide "
--dataset_name wmt16
--dataset_config_name ro-en
--output_dir /tmp/tst-translation
--per_device_train_batch_size 4
--per_device_eval_batch_size 4
--overwrite_output_dir
--tune
--predict_with_generate

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_train
--do_eval
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:Pentru cerințe de sistem și alte sfaturi de instalare, vă rugăm să consultați ghidul de instalare "
--dataset_name wmt16
--dataset_config_name ro-en
--output_dir /tmp/tst-translation
--per_device_train_batch_size 4
--per_device_eval_batch_size 4
--overwrite_output_dir
--tune
--predict_with_generate

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_predict
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:"
--input_file /content/input.txt
--output_file /content/output.txt
--per_device_eval_batch_size 4
--predict_with_generate
--overwrite_output_dir

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:Pentru cerințe de sistem și alte sfaturi de instalare, vă rugăm să "
--output_dir /content/a
--overwrite_output_dir
--tune
--predict_with_generate

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:For system requirements and other installation tips please refer to Installation Guide "
--output_dir /content/a
--overwrite_output_dir
--tune
--predict_with_generate

!pip uninstall tensorflow
!pip install tensorflow # Make sure to install the version compatible with your CUDA version

!pip uninstall tensorflow
!pip install tensorflow # Make sure to install the version compatible with your CUDA version

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_predict
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:Pentru cerințe de sistem și alte sfaturi de instalare, vă rugăm să cons"
--input_file /path/to/your/input.txt
--output_file /path/to/your/output.txt
--per_device_eval_batch_size 4
--predict_with_generate
--overwrite_output_dir

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_predict
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:Pentru cerințe de sistem și alte sfaturi de instalare, vă rugăm să cons"
--input_file /content/input.txt
--output_file /content/output.txt
--per_device_eval_batch_size 4
--predict_with_generate
--overwrite_output_dir

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_predict
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:Pentru cerințe de sistem și alte sfaturi de instalare, vă rugăm să cons"
--input_file /content/input.txt
--output_file /content/a/output.txt
--output_dir /content/a/
--per_device_eval_batch_size 4
--predict_with_generate
--overwrite_output_dir

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_predict
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:Pentru cerințe de sistem și alte sfaturi de instalare, vă rugăm să cons"
--input_file /content/input.txt
--output_file /content/output.txt
--output_dir /content/output_directory
--per_device_eval_batch_size 4
--predict_with_generate
--overwrite_output_dir

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_predict
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:Pentru cerințe de sistem și alte sfaturi de instalare, vă rugăm să cons"
--input_file /path/to/your/input.txt
--output_file /path/to/your/output.txt
--per_device_eval_batch_size 4
--predict_with_generate
--overwrite_output_dir

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_predict
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:Pentru cerințe de sistem și alte sfaturi de instalare, vă rugăm să cons"
--input_file /path/to/your/input.txt
--output_file /path/to/your/output.txt
--per_device_eval_batch_size 4
--predict_with_generate
--overwrite_output_dir

!python /content/intel-extension-for-transformers/examples/huggingface/pytorch/translation/quantization/run_translation.py
--model_name_or_path t5-small
--do_predict
--source_lang en
--target_lang ro
--source_prefix "translate English to Romanian:Pentru cerințe de sistem și alte sfaturi de instalare, vă rugăm să cons"
--input_file /path/to/your/input.txt
--output_file /path/to/your/output.txt
--per_device_eval_batch_size 4
--predict_with_generate
--overwrite_output_dir

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant