File size: 4,077 Bytes
10bf19f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "dc3852ca",
   "metadata": {},
   "source": [
    "# Evaluate Classification"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3a2d9fbf",
   "metadata": {},
   "source": [
    "## Setup"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "45140c6e",
   "metadata": {},
   "source": [
    "#### Load the API key and libaries."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e7bf1b8e",
   "metadata": {
    "height": 115,
    "tags": []
   },
   "outputs": [],
   "source": [
    "from src.Language_Evaluation_LC import llm_language_evaluation\n",
    "from src.data_analysis import run_analysis\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10e95383",
   "metadata": {
    "height": 30
   },
   "source": [
    "#### Load the Constants"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "464a2aaa",
   "metadata": {
    "height": 47,
    "tags": []
   },
   "outputs": [],
   "source": [
    "\n",
    "MODEL = \"meta-llama/Llama-3-70b-chat-hf\"\n",
    "TEMPERATURE = 0.0\n",
    "N_REPETITIONS = 0\n",
    "REASONING = False\n",
    "LANGUAGES = ['spanish', 'tagalog', 'portuguese', 'english']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "92663014",
   "metadata": {},
   "source": [
    "#### Run The Experiments:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7c7ccfa1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# Run evaluation:\n",
    "llm_language_evaluation(path=PATH, model=MODEL, temperature=TEMPERATURE, n_repetitions=N_REPETITIONS, reasoning=REASONING, languages=LANGUAGES)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "079dcbc4",
   "metadata": {},
   "source": [
    "#### See the results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a58184aa",
   "metadata": {
    "height": 30,
    "tags": []
   },
   "outputs": [],
   "source": [
    "import os\n",
    "MODEL = os.path.basename(MODEL)\n",
    "\n",
    "if N_REPETITIONS > 1:\n",
    "    df = pd.read_csv(f\"responses/{MODEL}_Temperature{str(TEMPERATURE).replace('.', '_')}_{N_REPETITIONS}Repetitions.csv\")\n",
    "else:\n",
    "    df = pd.read_csv(f\"responses/{MODEL}_Temperature{str(TEMPERATURE).replace('.', '_')}.csv\")\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "041dc525",
   "metadata": {},
   "source": [
    "### Data Analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "85f6bb97",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "TEMPERATURE = str(TEMPERATURE).replace('.', '_')\n",
    "\n",
    "run_analysis(model=MODEL, temperature=TEMPERATURE, n_repetitions=N_REPETITIONS, languages=LANGUAGES)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "dffeddc1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "N_REPETITIONS = 1 if N_REPETITIONS < 1 else N_REPETITIONS\n",
    "pd.read_csv(f'results/results_{MODEL}_Temperature{TEMPERATURE}_Repetitions{N_REPETITIONS}/matches_results_{MODEL}.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c23866b3-c0c6-42de-968c-6994b2b8b7fa",
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.read_csv(f'results/results_{MODEL}_Temperature{TEMPERATURE}_Repetitions{N_REPETITIONS}/matches_results_{MODEL}.csv').sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1dcad7d6-7647-49c5-9804-17db4dfbc5a3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}