{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "source": [ "!pip install sacrebleu" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "collapsed": true, "id": "qfgKIeKIfP_K", "outputId": "148ccad4-2aa7-4ce2-fc0c-0b758da2d900" }, "execution_count": 2, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Requirement already satisfied: sacrebleu in /usr/local/lib/python3.10/dist-packages (2.4.3)\n", "Requirement already satisfied: portalocker in /usr/local/lib/python3.10/dist-packages (from sacrebleu) (2.10.1)\n", "Requirement already satisfied: regex in /usr/local/lib/python3.10/dist-packages (from sacrebleu) (2024.9.11)\n", "Requirement already satisfied: tabulate>=0.8.9 in /usr/local/lib/python3.10/dist-packages (from sacrebleu) (0.9.0)\n", "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from sacrebleu) (1.26.4)\n", "Requirement already satisfied: colorama in /usr/local/lib/python3.10/dist-packages (from sacrebleu) (0.4.6)\n", "Requirement already satisfied: lxml in /usr/local/lib/python3.10/dist-packages (from sacrebleu) (4.9.4)\n" ] } ] }, { "cell_type": "code", "source": [ "import torch\n", "import torch.nn as nn\n", "import torch.optim as optim\n", "from torch.utils.data import DataLoader, Dataset\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import sacrebleu\n", "import json\n", "import csv\n", "from collections import Counter\n", "import pandas as pd" ], "metadata": { "id": "ldLKZyt0e3Fc" }, "execution_count": 3, "outputs": [] }, { "cell_type": "code", "source": [ "# Load the dataset using pandas\n", "data_df = pd.read_json('/content/Finnish.json', encoding='utf-8')\n", "\n" ], "metadata": { "id": "MNK5E90He3C9" }, "execution_count": 4, "outputs": [] }, { "cell_type": "code", "source": [ "# View the first few rows of the dataset\n", "print(\"First few rows of the dataset:\")\n", "data_df.head()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 310 }, "id": "6Og66QxJfLF6", "outputId": "a83ec768-894f-4b93-c4b5-72cd890084ce" }, "execution_count": 5, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "First few rows of the dataset:\n" ] }, { "output_type": "execute_result", "data": { "text/plain": [ " instruction \\\n", "0 Translate the following sentence into Finnish. \n", "1 Translate the following sentence into Finnish. \n", "2 Translate the following sentence into Finnish. \n", "3 Translate the following sentence into Finnish. \n", "4 Translate the following sentence into Finnish. \n", "\n", " input \\\n", "0 give three tips for staying healthy \n", "1 1 eat a balanced and nutritious diet make sure... \n", "2 what are the three primary colors \n", "3 the three primary colors are red blue and yell... \n", "4 describe the structure of an atom \n", "\n", " output \n", "0 anna kolme vinkkiä pysyäksesi terveenä \n", "1 1 syö tasapainoista ja ravitsevaa ruokavaliota... \n", "2 mitkä ovat kolme pääväriä \n", "3 kolme pääväriä ovat punainen sininen ja keltai... \n", "4 kuvaile atomin rakennetta " ], "text/html": [ "\n", "
| \n", " | instruction | \n", "input | \n", "output | \n", "
|---|---|---|---|
| 0 | \n", "Translate the following sentence into Finnish. | \n", "give three tips for staying healthy | \n", "anna kolme vinkkiä pysyäksesi terveenä | \n", "
| 1 | \n", "Translate the following sentence into Finnish. | \n", "1 eat a balanced and nutritious diet make sure... | \n", "1 syö tasapainoista ja ravitsevaa ruokavaliota... | \n", "
| 2 | \n", "Translate the following sentence into Finnish. | \n", "what are the three primary colors | \n", "mitkä ovat kolme pääväriä | \n", "
| 3 | \n", "Translate the following sentence into Finnish. | \n", "the three primary colors are red blue and yell... | \n", "kolme pääväriä ovat punainen sininen ja keltai... | \n", "
| 4 | \n", "Translate the following sentence into Finnish. | \n", "describe the structure of an atom | \n", "kuvaile atomin rakennetta | \n", "