### Redirect example configuration to a file Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Redirect the output of the --example flag to a file to save the example configuration. This example shows saving a training configuration. ```bash kiwi train --example > train.yaml ``` -------------------------------- ### Run Kiwi CLI command with example configuration Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Use the --example flag to print example configuration files to the terminal. This is useful for creating new configuration files. ```bash kiwi (train|pretrain|predict|evaluate|search) --example ``` -------------------------------- ### Run OpenKiwi Help Command Source: https://github.com/unbabel/openkiwi/blob/master/docs/installation.rst After installation, you can verify the installation and view available commands by running the help command. ```bash python kiwi -h ``` ```bash kiwi -h ``` -------------------------------- ### Install OpenKiwi as a Library Source: https://github.com/unbabel/openkiwi/blob/master/docs/installation.rst Use this command to install OpenKiwi as a Python library for use in your projects. ```bash pip install openkiwi ``` -------------------------------- ### Install OpenKiwi as a Local Package with Poetry Source: https://github.com/unbabel/openkiwi/blob/master/docs/installation.rst Installs all dependencies for OpenKiwi when developing locally using Poetry. Ensure Poetry is installed first. ```bash poetry install ``` -------------------------------- ### Install Poetry using Curl Source: https://github.com/unbabel/openkiwi/blob/master/docs/installation.rst Installs the Poetry dependency manager using a recommended script. This is a prerequisite for installing OpenKiwi as a local package. ```bash curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python ``` -------------------------------- ### Install OpenKiwi with Optuna Search (Poetry) Source: https://github.com/unbabel/openkiwi/blob/master/docs/installation.rst Installs OpenKiwi with optional Optuna integration for hyperparameter search using Poetry. This is useful for optimizing model parameters. ```bash poetry install -E search ``` -------------------------------- ### Configuration Composition Example Source: https://github.com/unbabel/openkiwi/blob/master/docs/configuration/index.rst Use a different dataset configuration by specifying it in the command line, leveraging Hydra/OmegaConf's composition capabilities. ```bash kiwi train config/bert.yaml data=unbabel.qe.en_pt ``` -------------------------------- ### Run OpenKiwi from Command Line Source: https://github.com/unbabel/openkiwi/blob/master/README.md Execute the OpenKiwi command-line interface after installation. ```bash kiwi ``` -------------------------------- ### Install OpenKiwi with MLflow Integration (Poetry) Source: https://github.com/unbabel/openkiwi/blob/master/docs/installation.rst Installs OpenKiwi with optional MLflow integration using Poetry. This enables advanced ML tracking capabilities. ```bash poetry install -E mlflow ``` -------------------------------- ### Example BERT Search Configuration Source: https://github.com/unbabel/openkiwi/blob/master/docs/configuration/search.rst This is an example search configuration file for the BERT model. It should be placed in the `config/` directory. ```yaml search: model: BERT # ... other BERT specific parameters ``` -------------------------------- ### Install OpenKiwi with Optuna Search (Pip) Source: https://github.com/unbabel/openkiwi/blob/master/docs/installation.rst Installs OpenKiwi with optional Optuna integration for hyperparameter search using pip. This is useful for optimizing model parameters. ```bash pip install openkiwi[search] ``` -------------------------------- ### Install OpenKiwi with MLflow Integration (Pip) Source: https://github.com/unbabel/openkiwi/blob/master/docs/installation.rst Installs OpenKiwi with optional MLflow integration using pip. This enables advanced ML tracking capabilities. ```bash pip install openkiwi[mlflow] ``` -------------------------------- ### Install Poetry using Pip Source: https://github.com/unbabel/openkiwi/blob/master/docs/installation.rst An alternative method to install Poetry using pip. Note that this is not recommended as it may conflict with local dependencies. ```bash pip install poetry ``` -------------------------------- ### YAML Configuration with Defaults Source: https://github.com/unbabel/openkiwi/blob/master/docs/configuration/index.rst Example of a YAML configuration file that uses defaults to load another configuration file, demonstrating configuration composition. ```yaml defaults: - data: wmt19.qe.en_de ``` -------------------------------- ### CLI Override Example Source: https://github.com/unbabel/openkiwi/blob/master/docs/configuration/index.rst Override configuration values when running a Kiwi command using dot notation for nested keys. ```bash kiwi train config/bert.yaml trainer.gpus=0 system.batch_size=16 ``` -------------------------------- ### Import OpenKiwi in Python Source: https://github.com/unbabel/openkiwi/blob/master/README.md Import the kiwi module into your Python project after installation. ```python import kiwi ``` -------------------------------- ### Pretrain Predictor model using CLI Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst This command initiates the pretraining process for the Predictor model using a specified configuration file. ```bash kiwi pretrain config/predictor.yaml ``` -------------------------------- ### Python Search from Configuration Dictionary Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Perform a search using a configuration dictionary loaded from a file. This method involves first converting the file to a dictionary, then passing it to the search function. Requires importing both file_to_configuration and search_from_configuration. ```python from kiwi.lib.search import search_from_configuration from kiwi.lib.utils import file_to_configuration configuration_dict = file_to_configuration('config/search.yaml') optuna_study = search_from_configuration(configuration_dict) ``` -------------------------------- ### Train BERT model for QE using Python API (dictionary config) Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Load a configuration from a file into a dictionary and then use train_from_configuration to train a BERT model for QE. This method allows for other file formats like JSON. ```python from kiwi.lib.train import train_from_configuration from kiwi.lib.utils import file_to_configuration configuration_dict = file_to_configuration('config/bert.yaml') run_info = train_from_configuration(configuration_dict) ``` -------------------------------- ### Train BERT model for QE using CLI Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst This command trains a BERT model for Quality Estimation (QE) using a specified configuration file. ```bash kiwi train config/bert.yaml ``` -------------------------------- ### Train BERT model for QE using Python API (file config) Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Use the train_from_file function from kiwi.lib.train to train a BERT model for QE, providing the configuration file path. ```python from kiwi.lib.train import train_from_file run_info = train_from_file('config/bert.yaml') ``` -------------------------------- ### Command-line Search Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Execute a search directly from the command line using a YAML configuration file. ```bash kiwi search config/search.yaml ``` -------------------------------- ### Predict on a dataset using Python API Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Load a configuration file and use predict_from_configuration to generate predictions and metrics for a full dataset. The configuration specifies model and data paths. ```python from kiwi.lib.predict import predict_from_configuration from kiwi.lib.utils import file_to_configuration configuration_dict = file_to_configuration('config/predict.yaml') predictions, metrics = predict_from_configuration(configuration_dict) ``` -------------------------------- ### Predict using a trained QE model via CLI Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Use the predict pipeline via the CLI by providing a YAML configuration file that specifies model path, data locations, and output directories. ```bash kiwi predict config/predict.yaml ``` -------------------------------- ### Python Search from File Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Perform a search by loading the configuration directly from a YAML file using the Python API. Requires importing the search_from_file function. ```python from kiwi.lib.search import search_from_file optuna_study = search_from_file('config/search.yaml') ``` -------------------------------- ### Evaluation Configuration YAML Source: https://github.com/unbabel/openkiwi/blob/master/docs/configuration/evaluate.rst This snippet shows the structure of the evaluation configuration file. Use this to define parameters for evaluation runs. ```yaml model: name: "bert-base-uncased" path: "/path/to/your/model" data: name: "sst2" path: "/path/to/your/data" output: path: "/path/to/your/output" metrics: - "accuracy" - "f1" params: batch_size: 32 epochs: 3 ``` -------------------------------- ### Evaluate model predictions using Python API Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Use evaluate_from_configuration to programmatically evaluate predictions against a gold standard file. The configuration dictionary should specify prediction and reference file details. ```python from kiwi.lib.evaluate import evaluate_from_configuration from kiwi.lib.utils import file_to_configuration configuration_dict = file_to_configuration('config/evaluate.yaml') report = evaluate_from_configuration(configuration_dict) print(report) ``` -------------------------------- ### Evaluate model predictions using CLI Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Evaluate the performance of a trained model's predictions against a reference file using the CLI. A YAML configuration file specifies the formats and locations of predictions and reference data. ```bash kiwi evaluate config/predict.yaml ``` -------------------------------- ### Bert Model Training Configuration Source: https://github.com/unbabel/openkiwi/blob/master/docs/configuration/train.rst YAML configuration file for the Bert model training. This file specifies various parameters for training the Bert model. ```yaml model: name: bert pretrained: bert-base-uncased encoder_layers: 6 decoder_layers: 6 d_model: 512 num_heads: 8 d_ff: 2048 dropout: 0.1 label_smoothing: 0.1 data: train_path: data/wmt14-ende/train.txt val_path: data/wmt14-ende/valid.txt test_path: data/wmt14-ende/test.txt batch_size: 32 max_seq_len: 512 num_workers: 4 training: optimizer: adam learning_rate: 0.0001 warmup_steps: 4000 max_steps: 100000 log_steps: 100 save_steps: 5000 eval_steps: 5000 gradient_accumulation_steps: 1 fp16: true logging: level: info file: logs/bert.log checkpoint: path: checkpoints/bert resume: false ``` -------------------------------- ### Load a trained model for on-demand predictions Source: https://github.com/unbabel/openkiwi/blob/master/docs/usage.rst Use load_system to load a trained model checkpoint and keep it in memory for on-demand predictions on source and target text pairs. ```python from kiwi.lib.predict import load_system runner = load_system('trained_models/model.ckpt') predictions = runner.predict( source=['Aqui vai um exemplo de texto'], target=['Here is an example text'], ) ``` -------------------------------- ### Prediction Configuration File Source: https://github.com/unbabel/openkiwi/blob/master/docs/configuration/predict.rst This snippet shows the structure of the prediction configuration file. It is used to define parameters for prediction tasks. ```yaml model: name: "bert-base-uncased" path: "/opt/ml/model" type: "transformer" device: "cuda" input: max_length: 128 batch_size: 32 output: path: "/opt/ml/output" format: "json" logging: level: "INFO" file: "/opt/ml/logs/predict.log" ``` -------------------------------- ### OpenKiwi Citation Source: https://github.com/unbabel/openkiwi/blob/master/README.md BibTeX entry for citing the OpenKiwi paper. Use this in academic publications. ```bibtex @inproceedings{openkiwi, author = {Fábio Kepler and Jonay Trénous and Marcos Treviso and Miguel Vera and André F. T. Martins}, title = {Open{K}iwi: An Open Source Framework for Quality Estimation}, year = {2019}, booktitle = {Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics--System Demonstrations}, pages = {117--122}, month = {July}, address = {Florence, Italy}, url = {https://www.aclweb.org/anthology/P19-3020}, organization = {Association for Computational Linguistics}, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.