Spaces:
Build error
Build error
ready for llama-3.1-8b
Browse files- llm_toolkit/eval_rpp.py +9 -2
- llm_toolkit/translation_utils.py +42 -13
- notebooks/00_Data Analysis.ipynb +2 -2
- notebooks/00a_Data Analysis_greedy_decoding.ipynb +2 -2
- notebooks/00b4080_Data Analysis_Few_Shots.ipynb +0 -0
- notebooks/00b_Data Analysis_Few_Shots.ipynb +0 -0
- notebooks/00c_Data Analysis_Fine_Tuned.ipynb +0 -0
- notebooks/00d_Data Analysis_Fine_Tuned_RPP.ipynb +0 -0
- notebooks/00e_Data Analysis_Fine_Tuned_RPP_MNT_2048.ipynb +0 -0
- notebooks/00f_Data Analysis_Fine_Tuned_RPP_Generic_Prompt.ipynb +0 -0
- notebooks/01_Few-shot_Prompting.ipynb +2 -2
- notebooks/01a_Few-shot_Prompting.ipynb +2 -2
- notebooks/01b_Few-shot_Prompting_RTX4080.ipynb +0 -0
- notebooks/01c_Few-shot_Prompting_OpenAI.ipynb +868 -1
- notebooks/02_Fine_Tune_OpenAI.ipynb +0 -0
- notebooks/02a_Fine_Tune_GPT-4o.ipynb +0 -0
- results/mac-results_rpp_with_mnt_2048_generic_prompt_metrics.csv +20 -0
- results/mac-results_rpp_with_mnt_2048_metrics.csv +38 -38
- scripts/eval-h100.sh +6 -5
- scripts/eval-mac.sh +3 -3
llm_toolkit/eval_rpp.py
CHANGED
@@ -64,7 +64,9 @@ if is_cuda:
|
|
64 |
print(f"(2) GPU = {gpu_stats.name}. Max memory = {max_memory} GB.")
|
65 |
print(f"{start_gpu_memory} GB of memory reserved.")
|
66 |
|
67 |
-
datasets = load_translation_dataset(
|
|
|
|
|
68 |
|
69 |
if len(sys.argv) > 1:
|
70 |
num = int(sys.argv[1])
|
@@ -83,7 +85,12 @@ def on_repetition_penalty_step_completed(model_name, predictions):
|
|
83 |
predictions,
|
84 |
)
|
85 |
|
86 |
-
metrics = calc_metrics(
|
|
|
|
|
|
|
|
|
|
|
87 |
print(f"{model_name} metrics: {metrics}")
|
88 |
|
89 |
|
|
|
64 |
print(f"(2) GPU = {gpu_stats.name}. Max memory = {max_memory} GB.")
|
65 |
print(f"{start_gpu_memory} GB of memory reserved.")
|
66 |
|
67 |
+
datasets = load_translation_dataset(
|
68 |
+
data_path, tokenizer, using_chat_template=using_chat_template
|
69 |
+
)
|
70 |
|
71 |
if len(sys.argv) > 1:
|
72 |
num = int(sys.argv[1])
|
|
|
85 |
predictions,
|
86 |
)
|
87 |
|
88 |
+
metrics = calc_metrics(
|
89 |
+
datasets["test"]["english"],
|
90 |
+
predictions,
|
91 |
+
datasets["test"]["chinese"],
|
92 |
+
debug=True,
|
93 |
+
)
|
94 |
print(f"{model_name} metrics: {metrics}")
|
95 |
|
96 |
|
llm_toolkit/translation_utils.py
CHANGED
@@ -118,7 +118,9 @@ def get_few_shot_prompt(dataset, num_shots=5):
|
|
118 |
return translation_prompt
|
119 |
|
120 |
|
121 |
-
def load_translation_dataset(
|
|
|
|
|
122 |
train_data_file = data_path.replace(".tsv", "-train.tsv")
|
123 |
test_data_file = data_path.replace(".tsv", "-test.tsv")
|
124 |
|
@@ -185,10 +187,14 @@ def load_translation_dataset(data_path, tokenizer=None, num_shots=0, for_openai=
|
|
185 |
)
|
186 |
texts.append(text)
|
187 |
else:
|
188 |
-
prompt =
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
192 |
prompts.append(prompt)
|
193 |
texts.append(prompt + output + tokenizer.eos_token)
|
194 |
|
@@ -242,7 +248,7 @@ def detect_repetition_scores(row, col, debug=False):
|
|
242 |
def count_chinese_characters(text):
|
243 |
if isinstance(text, str) is False:
|
244 |
return 0
|
245 |
-
|
246 |
# Define a regular expression pattern for Chinese characters
|
247 |
chinese_char_pattern = r"[\u4e00-\u9fff]"
|
248 |
|
@@ -266,7 +272,14 @@ def get_metrics(df, max_output_tokens=2048, variant="rpp", existing_metrics_df=N
|
|
266 |
metrics_df.reset_index(inplace=True)
|
267 |
metrics_df = metrics_df.drop(columns=["index"])
|
268 |
|
269 |
-
models =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
print(models)
|
271 |
|
272 |
tokenizers = {model: load_tokenizer(model) for model in models}
|
@@ -295,15 +308,27 @@ def get_metrics(df, max_output_tokens=2048, variant="rpp", existing_metrics_df=N
|
|
295 |
df[new_col] = df["chinese"].apply(count_chinese_characters)
|
296 |
|
297 |
for col in columns:
|
|
|
298 |
if existing_metrics_df is not None:
|
299 |
-
print(f"Using existing metrics for {col}")
|
300 |
parts = col.split(f"/{variant}-")
|
|
|
|
|
|
|
|
|
301 |
result = existing_metrics_df[
|
302 |
-
|
303 |
-
& (existing_metrics_df[variant] == int(parts[1]))
|
304 |
]
|
305 |
-
|
306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
print(f"Calculating metrics for {col}")
|
308 |
metrics = calc_metrics(
|
309 |
df["english"], df[col], sources=df["chinese"], debug=True
|
@@ -345,7 +370,11 @@ def get_metrics(df, max_output_tokens=2048, variant="rpp", existing_metrics_df=N
|
|
345 |
translation_completeness.append(1 - df[new_col].sum() / len(df))
|
346 |
|
347 |
new_col = f"output_tokens-{col}"
|
348 |
-
df[new_col] = df[col].apply(
|
|
|
|
|
|
|
|
|
349 |
|
350 |
num_max_output_tokens.append(
|
351 |
count_entries_with_max_tokens(df[new_col], max_output_tokens)
|
|
|
118 |
return translation_prompt
|
119 |
|
120 |
|
121 |
+
def load_translation_dataset(
|
122 |
+
data_path, tokenizer=None, num_shots=0, for_openai=False, using_chat_template=True
|
123 |
+
):
|
124 |
train_data_file = data_path.replace(".tsv", "-train.tsv")
|
125 |
test_data_file = data_path.replace(".tsv", "-test.tsv")
|
126 |
|
|
|
187 |
)
|
188 |
texts.append(text)
|
189 |
else:
|
190 |
+
prompt = (
|
191 |
+
tokenizer.apply_chat_template(
|
192 |
+
messages, tokenize=False, add_generation_prompt=True
|
193 |
+
)
|
194 |
+
if using_chat_template
|
195 |
+
else prompt
|
196 |
+
)
|
197 |
+
|
198 |
prompts.append(prompt)
|
199 |
texts.append(prompt + output + tokenizer.eos_token)
|
200 |
|
|
|
248 |
def count_chinese_characters(text):
|
249 |
if isinstance(text, str) is False:
|
250 |
return 0
|
251 |
+
|
252 |
# Define a regular expression pattern for Chinese characters
|
253 |
chinese_char_pattern = r"[\u4e00-\u9fff]"
|
254 |
|
|
|
272 |
metrics_df.reset_index(inplace=True)
|
273 |
metrics_df = metrics_df.drop(columns=["index"])
|
274 |
|
275 |
+
models = [
|
276 |
+
model
|
277 |
+
for model in metrics_df["model"].unique()
|
278 |
+
if ("/" in model or "gpt" in model)
|
279 |
+
and "ground_truth_" not in model
|
280 |
+
and "count_" not in model
|
281 |
+
and "output_" not in model
|
282 |
+
]
|
283 |
print(models)
|
284 |
|
285 |
tokenizers = {model: load_tokenizer(model) for model in models}
|
|
|
308 |
df[new_col] = df["chinese"].apply(count_chinese_characters)
|
309 |
|
310 |
for col in columns:
|
311 |
+
metrics = None
|
312 |
if existing_metrics_df is not None:
|
|
|
313 |
parts = col.split(f"/{variant}-")
|
314 |
+
if len(parts) == 1:
|
315 |
+
break
|
316 |
+
# print(parts)
|
317 |
+
val = float(parts[1]) if variant == "rpp" else int(parts[1])
|
318 |
result = existing_metrics_df[
|
319 |
+
existing_metrics_df["model"] == parts[0].split("/checkpoint")[0]
|
|
|
320 |
]
|
321 |
+
|
322 |
+
for i, row in result.iterrows():
|
323 |
+
# print(i, row[variant], val)
|
324 |
+
if row[variant] == val:
|
325 |
+
print(f"Using existing metrics for {col}")
|
326 |
+
metrics = row.to_dict()
|
327 |
+
# print(metrics)
|
328 |
+
break
|
329 |
+
# metrics = result.to_dict("records")[0]
|
330 |
+
|
331 |
+
if metrics is None:
|
332 |
print(f"Calculating metrics for {col}")
|
333 |
metrics = calc_metrics(
|
334 |
df["english"], df[col], sources=df["chinese"], debug=True
|
|
|
370 |
translation_completeness.append(1 - df[new_col].sum() / len(df))
|
371 |
|
372 |
new_col = f"output_tokens-{col}"
|
373 |
+
df[new_col] = df[col].apply(
|
374 |
+
lambda x: (
|
375 |
+
len(tokenizers[model](x)["input_ids"]) if isinstance(x, str) else 0
|
376 |
+
)
|
377 |
+
)
|
378 |
|
379 |
num_max_output_tokens.append(
|
380 |
count_entries_with_max_tokens(df[new_col], max_output_tokens)
|
notebooks/00_Data Analysis.ipynb
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a7460c7a3f3c921743bf1253f30d5e92247ab848620329b81298140877d9ad29
|
3 |
+
size 13090067
|
notebooks/00a_Data Analysis_greedy_decoding.ipynb
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6c02a5fa47507412db729c9335c84b3a6b1b6d72dc400270f155b03ae7561c0c
|
3 |
+
size 379759
|
notebooks/00b4080_Data Analysis_Few_Shots.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/00b_Data Analysis_Few_Shots.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/00c_Data Analysis_Fine_Tuned.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/00d_Data Analysis_Fine_Tuned_RPP.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/00e_Data Analysis_Fine_Tuned_RPP_MNT_2048.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/00f_Data Analysis_Fine_Tuned_RPP_Generic_Prompt.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/01_Few-shot_Prompting.ipynb
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cfc14de1239bf25b444213c68aba08e1f1a0f4b93d2545f39c2ee84e73c99591
|
3 |
+
size 33169
|
notebooks/01a_Few-shot_Prompting.ipynb
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e85d503993dc19b26a86029c2e2a578fb6d5bf9304be2f7854b3bc5fd595692c
|
3 |
+
size 47882
|
notebooks/01b_Few-shot_Prompting_RTX4080.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/01c_Few-shot_Prompting_OpenAI.ipynb
CHANGED
@@ -1 +1,868 @@
|
|
1 |
-
{"cells":[{"cell_type":"code","execution_count":1,"metadata":{"executionInfo":{"elapsed":476,"status":"ok","timestamp":1720679526275,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"},"user_tz":-480},"id":"uWKRSV6eZsCn"},"outputs":[],"source":["%load_ext autoreload\n","%autoreload 2"]},{"cell_type":"code","execution_count":2,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"6d394937-6c99-4a7c-9d32-7600a280032f","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":5,"status":"ok","timestamp":1720679529345,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"},"user_tz":-480},"id":"G5pNu3zgZBrL","outputId":"160a554f-fb08-4aa0-bc00-0422fb7c1fac"},"outputs":[{"name":"stdout","output_type":"stream","text":["workding dir: d:\\code\\projects\\rapget-translation\n"]}],"source":["import os\n","import sys\n","from pathlib import Path\n","\n","# check if workding_dir is in local variables\n","if \"workding_dir\" not in locals():\n"," workding_dir = str(Path.cwd().parent)\n","\n","os.chdir(workding_dir)\n","sys.path.append(workding_dir)\n","print(\"workding dir:\", workding_dir)"]},{"cell_type":"code","execution_count":3,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"9f67ec60-2f24-411c-84eb-0dd664b44775","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":3,"status":"ok","timestamp":1720679529345,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"},"user_tz":-480},"id":"hPCC-6m7ZBrM","outputId":"c7aa2c96-5e99-440a-c148-201d79465ff9"},"outputs":[{"name":"stdout","output_type":"stream","text":["loading env vars from: d:\\code\\projects\\rapget-translation\\.env\n"]},{"data":{"text/plain":["True"]},"execution_count":3,"metadata":{},"output_type":"execute_result"}],"source":["from dotenv import find_dotenv, load_dotenv\n","\n","found_dotenv = find_dotenv(\".env\")\n","\n","if len(found_dotenv) == 0:\n"," found_dotenv = find_dotenv(\".env.example\")\n","print(f\"loading env vars from: {found_dotenv}\")\n","load_dotenv(found_dotenv, override=True)"]},{"cell_type":"code","execution_count":4,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"f1597656-8042-4878-9d3b-9ebfb8dd86dc","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":3,"status":"ok","timestamp":1720679529345,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"},"user_tz":-480},"id":"1M3IraVtZBrM","outputId":"29ab35f6-2970-4ade-d85d-3174acf8cda0"},"outputs":[{"name":"stdout","output_type":"stream","text":["01-ai/Yi-1.5-9B-Chat None True datasets/mac/mac.tsv results/mac-results_few_shots_4bit.csv False 300\n"]}],"source":["import os\n","\n","model_name = os.getenv(\"MODEL_NAME\")\n","adapter_name_or_path = os.getenv(\"ADAPTER_NAME_OR_PATH\")\n","load_in_4bit = os.getenv(\"LOAD_IN_4BIT\") == \"true\"\n","data_path = os.getenv(\"DATA_PATH\")\n","results_path = os.getenv(\"RESULTS_PATH\")\n","use_english_datasets = os.getenv(\"USE_ENGLISH_DATASETS\") == \"true\"\n","max_new_tokens = int(os.getenv(\"MAX_NEW_TOKENS\", 2048))\n","\n","print(model_name, adapter_name_or_path, load_in_4bit, data_path, results_path, use_english_datasets, max_new_tokens)"]},{"cell_type":"code","execution_count":5,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"b2a43943-9324-4839-9a47-cfa72de2244b","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":564,"status":"ok","timestamp":1720679529907,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"},"user_tz":-480},"id":"UgMvt6dIZBrM","outputId":"ce37581c-fd26-46c2-ad87-d933d99f68f7"},"outputs":[{"name":"stdout","output_type":"stream","text":["Python 3.11.9\n","Name: torch\n","Version: 2.4.0+cu124\n","Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration\n","Home-page: https://pytorch.org/\n","Author: PyTorch Team\n","Author-email: packages@pytorch.org\n","License: BSD-3\n","Location: C:\\Users\\dongh\\.conda\\envs\\rapget\\Lib\\site-packages\n","Requires: filelock, fsspec, jinja2, networkx, sympy, typing-extensions\n","Required-by: accelerate, bitsandbytes, peft, torchaudio, torchvision\n","---\n","Name: transformers\n","Version: 4.43.3\n","Summary: State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow\n","Home-page: https://github.com/huggingface/transformers\n","Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)\n","Author-email: transformers@huggingface.co\n","License: Apache 2.0 License\n","Location: C:\\Users\\dongh\\.conda\\envs\\rapget\\Lib\\site-packages\n","Requires: filelock, huggingface-hub, numpy, packaging, pyyaml, regex, requests, safetensors, tokenizers, tqdm\n","Required-by: peft\n","CPU times: total: 0 ns\n","Wall time: 8.35 s\n"]}],"source":["%%time\n","os.environ[\"TOKENIZERS_PARALLELISM\"] = \"true\"\n","\n","!python --version\n","!pip show torch transformers"]},{"cell_type":"code","execution_count":6,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":1685,"status":"ok","timestamp":1720679531591,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"},"user_tz":-480},"id":"ZuS_FsLyZBrN","outputId":"2cba0105-c505-4395-afbd-2f2fee6581d0"},"outputs":[{"name":"stderr","output_type":"stream","text":["c:\\Users\\dongh\\.conda\\envs\\rapget\\Lib\\site-packages\\threadpoolctl.py:1214: RuntimeWarning: \n","Found Intel OpenMP ('libiomp') and LLVM OpenMP ('libomp') loaded at\n","the same time. Both libraries are known to be incompatible and this\n","can cause random crashes or deadlocks on Linux when loaded in the\n","same Python program.\n","Using threadpoolctl may cause crashes or deadlocks. For more\n","information and possible workarounds, please see\n"," https://github.com/joblib/threadpoolctl/blob/master/multiple_openmp.md\n","\n"," warnings.warn(msg, RuntimeWarning)\n","[nltk_data] Downloading package wordnet to\n","[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n","[nltk_data] Package wordnet is already up-to-date!\n","[nltk_data] Downloading package punkt to\n","[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n","[nltk_data] Package punkt is already up-to-date!\n","[nltk_data] Downloading package omw-1.4 to\n","[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n","[nltk_data] Package omw-1.4 is already up-to-date!\n"]},{"name":"stdout","output_type":"stream","text":["loading: d:\\code\\projects\\rapget-translation\\eval_modules\\calc_repetitions.py\n","loading d:\\code\\projects\\rapget-translation\\llm_toolkit\\translation_utils.py\n"]},{"name":"stderr","output_type":"stream","text":["[nltk_data] Downloading package wordnet to\n","[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n","[nltk_data] Package wordnet is already up-to-date!\n","[nltk_data] Downloading package punkt to\n","[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n","[nltk_data] Package punkt is already up-to-date!\n","[nltk_data] Downloading package omw-1.4 to\n","[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n","[nltk_data] Package omw-1.4 is already up-to-date!\n"]},{"name":"stdout","output_type":"stream","text":["CUDA is available, we have found 1 GPU(s)\n","NVIDIA GeForce RTX 4080 Laptop GPU\n","CUDA version: 12.4\n"]}],"source":["from llm_toolkit.llm_utils import *\n","from llm_toolkit.translation_utils import *\n","\n","device = check_gpu()"]},{"cell_type":"code","execution_count":7,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["loading train/test data files\n","DatasetDict({\n"," train: Dataset({\n"," features: ['chinese', 'english'],\n"," num_rows: 4528\n"," })\n"," test: Dataset({\n"," features: ['chinese', 'english'],\n"," num_rows: 1133\n"," })\n","})\n"]}],"source":["datasets = load_translation_dataset(data_path)"]},{"cell_type":"code","execution_count":8,"metadata":{},"outputs":[],"source":["os.getenv(\"OPENAI_MODEL\")\n","base_url = os.getenv(\"OPENAI_BASE_URL\") or None"]},{"cell_type":"code","execution_count":9,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["--------------------------------------------------\n","chinese: 那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\n","--------------------------------------------------\n","english: When Grannie Liu heard Xi-feng talk about 'difficulties' she concluded that there was no hope. Her delight and the way in which her face lit up with pleasure when she heard that she was, after all, to be given twenty taels of silver can be imagined. 'We knew you had your troubles,' she said, 'but as the saying goes, 'A starved camel is bigger than a fat horse.'\n","--------------------------------------------------\n","chinese: 后来她不挣扎了,对我说,混蛋,你要把我怎么办。\n","--------------------------------------------------\n","english: After a while, she no longer struggled and said, You bastard! What are you going to do with me?\n"]}],"source":["eval_dataset = datasets[\"test\"].select([260, 908])\n","print_row_details(eval_dataset.to_pandas(), range(len(eval_dataset)))"]},{"cell_type":"code","execution_count":10,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["You will be given a Chinese sentence to translate. If it is an incomplete sentence, or if you are unsure about the meaning, simply copy the input text as your output. Do not output any additional sentence such as explanation or reasoning.\n","\n","Example Translations:\n","Chinese: 全仗着狐仙搭救。\n","English: Because I was protected by a fox fairy.\n","Chinese: 过后,表哥告诉她俩,这人是导演,在外国留过学的,还会编剧,今天拍的这戏,就是他自编自导的。\n","English: He was the director, the cousin later told them. He had studied abroad and was also a screenwriter; in fact he had written and directed the scene they had earlier seen being filmed.\n","Chinese: 这凤姐忽然想起一件事来,便向窗外叫:“蓉儿回来!”\n","English: Xi-feng suddenly seemed to remember something, and called to him through the window, 'Rong, come back!'\n","Chinese: 三个老红卫兵走到叶文洁面前,面对着她站成了一排——当年,她们也是这样面对叶哲泰的——试图再现那早已忘却的尊严,但她们当年那魔鬼般的精神力量显然已荡然无存。\n","English: The three old Red Guards stood in front of Ye in a row—just like they had stood against Ye Zhetai—trying to recapture their long-forgotten dignity. But the demonic spiritual energy that had once propelled them was gone.\n","Chinese: 程先生照单全收,都是一个“谢”字,然后问王琦瑶有什么话说。\n","English: Mr. Cheng accepted their toast with equanimity and a 'thank you.' Then, turning to Wang Qiyao, he asked if she had anything to say.\n","\n","Chinese: {input}\n","English:\n"]}],"source":["translation_prompt = get_few_shot_prompt(datasets[\"train\"], num_shots=5)\n","print(translation_prompt)"]},{"cell_type":"code","execution_count":11,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence] Entering Chain run with input:\n","\u001b[0m{\n"," \"input\": \"那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\"\n","}\n","\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n","\u001b[0m{\n"," \"input\": \"那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\"\n","}\n","\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [1ms] Exiting Prompt run with output:\n","\u001b[0m[outputs]\n","\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] Entering LLM run with input:\n","\u001b[0m{\n"," \"prompts\": [\n"," \"System: You are a helpful assistant that translates Chinese to English.\\nHuman: You will be given a Chinese sentence to translate. If it is an incomplete sentence, or if you are unsure about the meaning, simply copy the input text as your output. Do not output any additional sentence such as explanation or reasoning.\\n\\nExample Translations:\\nChinese: 全仗着狐仙搭救。\\nEnglish: Because I was protected by a fox fairy.\\nChinese: 过后,表哥告诉她俩,这人是导演,在外国留过学的,还会编剧,今天拍的这戏,就是他自编自导的。\\nEnglish: He was the director, the cousin later told them. He had studied abroad and was also a screenwriter; in fact he had written and directed the scene they had earlier seen being filmed.\\nChinese: 这凤姐忽然想起一件事来,便向窗外叫:“蓉儿回来!”\\nEnglish: Xi-feng suddenly seemed to remember something, and called to him through the window, 'Rong, come back!'\\nChinese: 三个老红卫兵走到叶文洁面前,面对着她站成了一排——当年,她们也是这样面对叶哲泰的——试图再现那早已忘却的尊严,但她们当年那魔鬼般的精神力量显然已荡然无存。\\nEnglish: The three old Red Guards stood in front of Ye in a row—just like they had stood against Ye Zhetai—trying to recapture their long-forgotten dignity. But the demonic spiritual energy that had once propelled them was gone.\\nChinese: 程先生照单全收,都是一个“谢”字,然后问王琦瑶有什么话说。\\nEnglish: Mr. Cheng accepted their toast with equanimity and a 'thank you.' Then, turning to Wang Qiyao, he asked if she had anything to say.\\n\\nChinese: 那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\\nEnglish:\"\n"," ]\n","}\n","\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] [1.45s] Exiting LLM run with output:\n","\u001b[0m{\n"," \"generations\": [\n"," [\n"," {\n"," \"text\": \"That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \\\"We also know about difficulties, but as the saying goes: 'A dead camel is still bigger than a horse.'\\\"\",\n"," \"generation_info\": {\n"," \"finish_reason\": \"stop\",\n"," \"logprobs\": null\n"," },\n"," \"type\": \"ChatGeneration\",\n"," \"message\": {\n"," \"lc\": 1,\n"," \"type\": \"constructor\",\n"," \"id\": [\n"," \"langchain\",\n"," \"schema\",\n"," \"messages\",\n"," \"AIMessage\"\n"," ],\n"," \"kwargs\": {\n"," \"content\": \"That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \\\"We also know about difficulties, but as the saying goes: 'A dead camel is still bigger than a horse.'\\\"\",\n"," \"response_metadata\": {\n"," \"token_usage\": {\n"," \"completion_tokens\": 56,\n"," \"prompt_tokens\": 484,\n"," \"total_tokens\": 540\n"," },\n"," \"model_name\": \"gpt-4o-mini-2024-07-18\",\n"," \"system_fingerprint\": \"fp_0f03d4f0ee\",\n"," \"finish_reason\": \"stop\",\n"," \"logprobs\": null\n"," },\n"," \"type\": \"ai\",\n"," \"id\": \"run-1c7d8c24-e2d6-4ba3-b87a-16101fb1ce80-0\",\n"," \"usage_metadata\": {\n"," \"input_tokens\": 484,\n"," \"output_tokens\": 56,\n"," \"total_tokens\": 540\n"," },\n"," \"tool_calls\": [],\n"," \"invalid_tool_calls\": []\n"," }\n"," }\n"," }\n"," ]\n"," ],\n"," \"llm_output\": {\n"," \"token_usage\": {\n"," \"completion_tokens\": 56,\n"," \"prompt_tokens\": 484,\n"," \"total_tokens\": 540\n"," },\n"," \"model_name\": \"gpt-4o-mini-2024-07-18\",\n"," \"system_fingerprint\": \"fp_0f03d4f0ee\"\n"," },\n"," \"run\": null\n","}\n","\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [1.46s] Exiting Chain run with output:\n","\u001b[0m[outputs]\n"]},{"data":{"text/plain":["'That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \"We also know about difficulties, but as the saying goes: \\'A dead camel is still bigger than a horse.\\'\"'"]},"execution_count":11,"metadata":{},"output_type":"execute_result"}],"source":["from langchain_core.globals import set_debug\n","\n","set_debug(True)\n","\n","translate_via_openai(eval_dataset[\"chinese\"][0], translation_prompt, max_tokens=max_new_tokens)"]},{"cell_type":"code","execution_count":12,"metadata":{},"outputs":[],"source":["datasets[\"test\"] = eval_dataset"]},{"cell_type":"code","execution_count":13,"metadata":{},"outputs":[{"name":"stderr","output_type":"stream","text":[" 0%| | 0/2 [00:00<?, ?it/s]"]},{"name":"stdout","output_type":"stream","text":["\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence] Entering Chain run with input:\n","\u001b[0m{\n"," \"input\": \"那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\"\n","}\n","\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n","\u001b[0m{\n"," \"input\": \"那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\"\n","}\n","\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [1ms] Exiting Prompt run with output:\n","\u001b[0m[outputs]\n","\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] Entering LLM run with input:\n","\u001b[0m{\n"," \"prompts\": [\n"," \"System: You are a helpful assistant that translates Chinese to English.\\nHuman: You will be given a Chinese sentence to translate. If it is an incomplete sentence, or if you are unsure about the meaning, simply copy the input text as your output. Do not output any additional sentence such as explanation or reasoning.\\n\\nExample Translations:\\nChinese: 全仗着狐仙搭救。\\nEnglish: Because I was protected by a fox fairy.\\nChinese: 过后,表哥告诉她俩,这人是导演,在外国留过学的,还会编剧,今天拍的这戏,就是他自编自导的。\\nEnglish: He was the director, the cousin later told them. He had studied abroad and was also a screenwriter; in fact he had written and directed the scene they had earlier seen being filmed.\\nChinese: 这凤姐忽然想起一件事来,便向窗外叫:“蓉儿回来!”\\nEnglish: Xi-feng suddenly seemed to remember something, and called to him through the window, 'Rong, come back!'\\nChinese: 三个老红卫兵走���叶文洁面前,面对着她站成了一排——当年,她们也是这样面对叶哲泰的——试图再现那早已忘却的尊严,但她们当年那魔鬼般的精神力量显然已荡然无存。\\nEnglish: The three old Red Guards stood in front of Ye in a row—just like they had stood against Ye Zhetai—trying to recapture their long-forgotten dignity. But the demonic spiritual energy that had once propelled them was gone.\\nChinese: 程先生照单全收,都是一个“谢”字,然后问王琦瑶有什么话说。\\nEnglish: Mr. Cheng accepted their toast with equanimity and a 'thank you.' Then, turning to Wang Qiyao, he asked if she had anything to say.\\n\\nChinese: 那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\\nEnglish:\"\n"," ]\n","}\n"]},{"name":"stderr","output_type":"stream","text":[" 50%|█████ | 1/2 [00:02<00:02, 2.31s/it]"]},{"name":"stdout","output_type":"stream","text":["\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] [1.27s] Exiting LLM run with output:\n","\u001b[0m{\n"," \"generations\": [\n"," [\n"," {\n"," \"text\": \"That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \\\"We also know it's difficult, but as the saying goes: 'A dead camel is still bigger than a horse.'\\\"\",\n"," \"generation_info\": {\n"," \"finish_reason\": \"stop\",\n"," \"logprobs\": null\n"," },\n"," \"type\": \"ChatGeneration\",\n"," \"message\": {\n"," \"lc\": 1,\n"," \"type\": \"constructor\",\n"," \"id\": [\n"," \"langchain\",\n"," \"schema\",\n"," \"messages\",\n"," \"AIMessage\"\n"," ],\n"," \"kwargs\": {\n"," \"content\": \"That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \\\"We also know it's difficult, but as the saying goes: 'A dead camel is still bigger than a horse.'\\\"\",\n"," \"response_metadata\": {\n"," \"token_usage\": {\n"," \"completion_tokens\": 56,\n"," \"prompt_tokens\": 484,\n"," \"total_tokens\": 540\n"," },\n"," \"model_name\": \"gpt-4o-mini-2024-07-18\",\n"," \"system_fingerprint\": \"fp_9b0abffe81\",\n"," \"finish_reason\": \"stop\",\n"," \"logprobs\": null\n"," },\n"," \"type\": \"ai\",\n"," \"id\": \"run-68581936-c5f8-4d63-a40a-9ae04e88d234-0\",\n"," \"usage_metadata\": {\n"," \"input_tokens\": 484,\n"," \"output_tokens\": 56,\n"," \"total_tokens\": 540\n"," },\n"," \"tool_calls\": [],\n"," \"invalid_tool_calls\": []\n"," }\n"," }\n"," }\n"," ]\n"," ],\n"," \"llm_output\": {\n"," \"token_usage\": {\n"," \"completion_tokens\": 56,\n"," \"prompt_tokens\": 484,\n"," \"total_tokens\": 540\n"," },\n"," \"model_name\": \"gpt-4o-mini-2024-07-18\",\n"," \"system_fingerprint\": \"fp_9b0abffe81\"\n"," },\n"," \"run\": null\n","}\n","\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [1.28s] Exiting Chain run with output:\n","\u001b[0m[outputs]\n","\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence] Entering Chain run with input:\n","\u001b[0m{\n"," \"input\": \"后来她不挣扎了,对我说,混蛋,你要把我怎么办。\"\n","}\n","\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n","\u001b[0m{\n"," \"input\": \"后来她不挣扎了,对我说,混蛋,你要把我怎么办。\"\n","}\n","\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [1ms] Exiting Prompt run with output:\n","\u001b[0m[outputs]\n","\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] Entering LLM run with input:\n","\u001b[0m{\n"," \"prompts\": [\n"," \"System: You are a helpful assistant that translates Chinese to English.\\nHuman: You will be given a Chinese sentence to translate. If it is an incomplete sentence, or if you are unsure about the meaning, simply copy the input text as your output. Do not output any additional sentence such as explanation or reasoning.\\n\\nExample Translations:\\nChinese: 全仗着狐仙搭救。\\nEnglish: Because I was protected by a fox fairy.\\nChinese: 过后,表哥告诉她俩,这人是导演,在外国留过学的,还会编剧,今天拍的这戏,就是他自编自导的。\\nEnglish: He was the director, the cousin later told them. He had studied abroad and was also a screenwriter; in fact he had written and directed the scene they had earlier seen being filmed.\\nChinese: 这凤姐忽然想起一件事来,便向窗外叫:“蓉儿回来!”\\nEnglish: Xi-feng suddenly seemed to remember something, and called to him through the window, 'Rong, come back!'\\nChinese: 三个老红卫兵走到叶文洁面前,面对着她站成了一排——当年,她们也是这样面对叶哲泰的——试图再现那早已忘却的尊严,但她们当年那魔鬼般的精神力量显然已荡然无存。\\nEnglish: The three old Red Guards stood in front of Ye in a row—just like they had stood against Ye Zhetai—trying to recapture their long-forgotten dignity. But the demonic spiritual energy that had once propelled them was gone.\\nChinese: 程先生照单全收,都是一个“谢”字,然后问王琦瑶有什么话说。\\nEnglish: Mr. Cheng accepted their toast with equanimity and a 'thank you.' Then, turning to Wang Qiyao, he asked if she had anything to say.\\n\\nChinese: 后来她不挣扎了,对我说,混蛋,你要把我怎么办。\\nEnglish:\"\n"," ]\n","}\n"]},{"name":"stderr","output_type":"stream","text":["100%|██████████| 2/2 [00:04<00:00, 2.12s/it]"]},{"name":"stdout","output_type":"stream","text":["\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] [908ms] Exiting LLM run with output:\n","\u001b[0m{\n"," \"generations\": [\n"," [\n"," {\n"," \"text\": \"Later, she stopped struggling and said to me, \\\"Bastard, what are you going to do with me?\\\"\",\n"," \"generation_info\": {\n"," \"finish_reason\": \"stop\",\n"," \"logprobs\": null\n"," },\n"," \"type\": \"ChatGeneration\",\n"," \"message\": {\n"," \"lc\": 1,\n"," \"type\": \"constructor\",\n"," \"id\": [\n"," \"langchain\",\n"," \"schema\",\n"," \"messages\",\n"," \"AIMessage\"\n"," ],\n"," \"kwargs\": {\n"," \"content\": \"Later, she stopped struggling and said to me, \\\"Bastard, what are you going to do with me?\\\"\",\n"," \"response_metadata\": {\n"," \"token_usage\": {\n"," \"completion_tokens\": 24,\n"," \"prompt_tokens\": 433,\n"," \"total_tokens\": 457\n"," },\n"," \"model_name\": \"gpt-4o-mini-2024-07-18\",\n"," \"system_fingerprint\": \"fp_611b667b19\",\n"," \"finish_reason\": \"stop\",\n"," \"logprobs\": null\n"," },\n"," \"type\": \"ai\",\n"," \"id\": \"run-e4bb10fb-f7c4-4440-82ba-c13a1a82bc00-0\",\n"," \"usage_metadata\": {\n"," \"input_tokens\": 433,\n"," \"output_tokens\": 24,\n"," \"total_tokens\": 457\n"," },\n"," \"tool_calls\": [],\n"," \"invalid_tool_calls\": []\n"," }\n"," }\n"," }\n"," ]\n"," ],\n"," \"llm_output\": {\n"," \"token_usage\": {\n"," \"completion_tokens\": 24,\n"," \"prompt_tokens\": 433,\n"," \"total_tokens\": 457\n"," },\n"," \"model_name\": \"gpt-4o-mini-2024-07-18\",\n"," \"system_fingerprint\": \"fp_611b667b19\"\n"," },\n"," \"run\": null\n","}\n","\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [918ms] Exiting Chain run with output:\n","\u001b[0m[outputs]\n"]},{"name":"stderr","output_type":"stream","text":["\n"]}],"source":["predictions = eval_openai(5, datasets)"]},{"cell_type":"code","execution_count":14,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["['That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \"We also know it\\'s difficult, but as the saying goes: \\'A dead camel is still bigger than a horse.\\'\"', 'Later, she stopped struggling and said to me, \"Bastard, what are you going to do with me?\"']\n"]}],"source":["print(predictions)"]},{"cell_type":"code","execution_count":15,"metadata":{},"outputs":[{"data":{"text/plain":["{'meteor': 0.5376810911615811,\n"," 'bleu_scores': {'bleu': 0.16133991724232039,\n"," 'precisions': [0.5454545454545454,\n"," 0.26666666666666666,\n"," 0.1643835616438356,\n"," 0.09859154929577464],\n"," 'brevity_penalty': 0.7322097138745853,\n"," 'length_ratio': 0.7623762376237624,\n"," 'translation_length': 77,\n"," 'reference_length': 101},\n"," 'rouge_scores': {'rouge1': 0.5594202898550725,\n"," 'rouge2': 0.362051015096304,\n"," 'rougeL': 0.5246376811594203,\n"," 'rougeLsum': 0.5246376811594203},\n"," 'accuracy': 0.0}"]},"execution_count":15,"metadata":{},"output_type":"execute_result"}],"source":["calc_metrics(eval_dataset[\"english\"], predictions)"]}],"metadata":{"accelerator":"GPU","application/vnd.databricks.v1+notebook":{"dashboards":[],"environmentMetadata":null,"language":"python","notebookMetadata":{"mostRecentlyExecutedCommandWithImplicitDF":{"commandId":-1,"dataframes":["_sqldf"]},"pythonIndentUnit":4},"notebookName":"10_eval-lf-medium-py3.11","widgets":{}},"colab":{"gpuType":"L4","provenance":[]},"kernelspec":{"display_name":"Python 3","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.11.9"}},"nbformat":4,"nbformat_minor":0}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {
|
7 |
+
"executionInfo": {
|
8 |
+
"elapsed": 476,
|
9 |
+
"status": "ok",
|
10 |
+
"timestamp": 1720679526275,
|
11 |
+
"user": {
|
12 |
+
"displayName": "HUANG DONGHAO _",
|
13 |
+
"userId": "00977795705617022768"
|
14 |
+
},
|
15 |
+
"user_tz": -480
|
16 |
+
},
|
17 |
+
"id": "uWKRSV6eZsCn"
|
18 |
+
},
|
19 |
+
"outputs": [],
|
20 |
+
"source": [
|
21 |
+
"%load_ext autoreload\n",
|
22 |
+
"%autoreload 2"
|
23 |
+
]
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"cell_type": "code",
|
27 |
+
"execution_count": 2,
|
28 |
+
"metadata": {
|
29 |
+
"application/vnd.databricks.v1+cell": {
|
30 |
+
"cellMetadata": {
|
31 |
+
"byteLimit": 2048000,
|
32 |
+
"rowLimit": 10000
|
33 |
+
},
|
34 |
+
"inputWidgets": {},
|
35 |
+
"nuid": "6d394937-6c99-4a7c-9d32-7600a280032f",
|
36 |
+
"showTitle": false,
|
37 |
+
"title": ""
|
38 |
+
},
|
39 |
+
"colab": {
|
40 |
+
"base_uri": "https://localhost:8080/"
|
41 |
+
},
|
42 |
+
"executionInfo": {
|
43 |
+
"elapsed": 5,
|
44 |
+
"status": "ok",
|
45 |
+
"timestamp": 1720679529345,
|
46 |
+
"user": {
|
47 |
+
"displayName": "HUANG DONGHAO _",
|
48 |
+
"userId": "00977795705617022768"
|
49 |
+
},
|
50 |
+
"user_tz": -480
|
51 |
+
},
|
52 |
+
"id": "G5pNu3zgZBrL",
|
53 |
+
"outputId": "160a554f-fb08-4aa0-bc00-0422fb7c1fac"
|
54 |
+
},
|
55 |
+
"outputs": [
|
56 |
+
{
|
57 |
+
"name": "stdout",
|
58 |
+
"output_type": "stream",
|
59 |
+
"text": [
|
60 |
+
"workding dir: d:\\code\\projects\\rapget-translation\n"
|
61 |
+
]
|
62 |
+
}
|
63 |
+
],
|
64 |
+
"source": [
|
65 |
+
"import os\n",
|
66 |
+
"import sys\n",
|
67 |
+
"from pathlib import Path\n",
|
68 |
+
"\n",
|
69 |
+
"# check if workding_dir is in local variables\n",
|
70 |
+
"if \"workding_dir\" not in locals():\n",
|
71 |
+
" workding_dir = str(Path.cwd().parent)\n",
|
72 |
+
"\n",
|
73 |
+
"os.chdir(workding_dir)\n",
|
74 |
+
"sys.path.append(workding_dir)\n",
|
75 |
+
"print(\"workding dir:\", workding_dir)"
|
76 |
+
]
|
77 |
+
},
|
78 |
+
{
|
79 |
+
"cell_type": "code",
|
80 |
+
"execution_count": 3,
|
81 |
+
"metadata": {
|
82 |
+
"application/vnd.databricks.v1+cell": {
|
83 |
+
"cellMetadata": {
|
84 |
+
"byteLimit": 2048000,
|
85 |
+
"rowLimit": 10000
|
86 |
+
},
|
87 |
+
"inputWidgets": {},
|
88 |
+
"nuid": "9f67ec60-2f24-411c-84eb-0dd664b44775",
|
89 |
+
"showTitle": false,
|
90 |
+
"title": ""
|
91 |
+
},
|
92 |
+
"colab": {
|
93 |
+
"base_uri": "https://localhost:8080/"
|
94 |
+
},
|
95 |
+
"executionInfo": {
|
96 |
+
"elapsed": 3,
|
97 |
+
"status": "ok",
|
98 |
+
"timestamp": 1720679529345,
|
99 |
+
"user": {
|
100 |
+
"displayName": "HUANG DONGHAO _",
|
101 |
+
"userId": "00977795705617022768"
|
102 |
+
},
|
103 |
+
"user_tz": -480
|
104 |
+
},
|
105 |
+
"id": "hPCC-6m7ZBrM",
|
106 |
+
"outputId": "c7aa2c96-5e99-440a-c148-201d79465ff9"
|
107 |
+
},
|
108 |
+
"outputs": [
|
109 |
+
{
|
110 |
+
"name": "stdout",
|
111 |
+
"output_type": "stream",
|
112 |
+
"text": [
|
113 |
+
"loading env vars from: d:\\code\\projects\\rapget-translation\\.env\n"
|
114 |
+
]
|
115 |
+
},
|
116 |
+
{
|
117 |
+
"data": {
|
118 |
+
"text/plain": [
|
119 |
+
"True"
|
120 |
+
]
|
121 |
+
},
|
122 |
+
"execution_count": 3,
|
123 |
+
"metadata": {},
|
124 |
+
"output_type": "execute_result"
|
125 |
+
}
|
126 |
+
],
|
127 |
+
"source": [
|
128 |
+
"from dotenv import find_dotenv, load_dotenv\n",
|
129 |
+
"\n",
|
130 |
+
"found_dotenv = find_dotenv(\".env\")\n",
|
131 |
+
"\n",
|
132 |
+
"if len(found_dotenv) == 0:\n",
|
133 |
+
" found_dotenv = find_dotenv(\".env.example\")\n",
|
134 |
+
"print(f\"loading env vars from: {found_dotenv}\")\n",
|
135 |
+
"load_dotenv(found_dotenv, override=True)"
|
136 |
+
]
|
137 |
+
},
|
138 |
+
{
|
139 |
+
"cell_type": "code",
|
140 |
+
"execution_count": 4,
|
141 |
+
"metadata": {
|
142 |
+
"application/vnd.databricks.v1+cell": {
|
143 |
+
"cellMetadata": {
|
144 |
+
"byteLimit": 2048000,
|
145 |
+
"rowLimit": 10000
|
146 |
+
},
|
147 |
+
"inputWidgets": {},
|
148 |
+
"nuid": "f1597656-8042-4878-9d3b-9ebfb8dd86dc",
|
149 |
+
"showTitle": false,
|
150 |
+
"title": ""
|
151 |
+
},
|
152 |
+
"colab": {
|
153 |
+
"base_uri": "https://localhost:8080/"
|
154 |
+
},
|
155 |
+
"executionInfo": {
|
156 |
+
"elapsed": 3,
|
157 |
+
"status": "ok",
|
158 |
+
"timestamp": 1720679529345,
|
159 |
+
"user": {
|
160 |
+
"displayName": "HUANG DONGHAO _",
|
161 |
+
"userId": "00977795705617022768"
|
162 |
+
},
|
163 |
+
"user_tz": -480
|
164 |
+
},
|
165 |
+
"id": "1M3IraVtZBrM",
|
166 |
+
"outputId": "29ab35f6-2970-4ade-d85d-3174acf8cda0"
|
167 |
+
},
|
168 |
+
"outputs": [
|
169 |
+
{
|
170 |
+
"name": "stdout",
|
171 |
+
"output_type": "stream",
|
172 |
+
"text": [
|
173 |
+
"01-ai/Yi-1.5-9B-Chat None True datasets/mac/mac.tsv results/mac-results_few_shots_4bit.csv False 300\n"
|
174 |
+
]
|
175 |
+
}
|
176 |
+
],
|
177 |
+
"source": [
|
178 |
+
"import os\n",
|
179 |
+
"\n",
|
180 |
+
"model_name = os.getenv(\"MODEL_NAME\")\n",
|
181 |
+
"adapter_name_or_path = os.getenv(\"ADAPTER_NAME_OR_PATH\")\n",
|
182 |
+
"load_in_4bit = os.getenv(\"LOAD_IN_4BIT\") == \"true\"\n",
|
183 |
+
"data_path = os.getenv(\"DATA_PATH\")\n",
|
184 |
+
"results_path = os.getenv(\"RESULTS_PATH\")\n",
|
185 |
+
"use_english_datasets = os.getenv(\"USE_ENGLISH_DATASETS\") == \"true\"\n",
|
186 |
+
"max_new_tokens = int(os.getenv(\"MAX_NEW_TOKENS\", 2048))\n",
|
187 |
+
"\n",
|
188 |
+
"print(\n",
|
189 |
+
" model_name,\n",
|
190 |
+
" adapter_name_or_path,\n",
|
191 |
+
" load_in_4bit,\n",
|
192 |
+
" data_path,\n",
|
193 |
+
" results_path,\n",
|
194 |
+
" use_english_datasets,\n",
|
195 |
+
" max_new_tokens,\n",
|
196 |
+
")"
|
197 |
+
]
|
198 |
+
},
|
199 |
+
{
|
200 |
+
"cell_type": "code",
|
201 |
+
"execution_count": 5,
|
202 |
+
"metadata": {
|
203 |
+
"application/vnd.databricks.v1+cell": {
|
204 |
+
"cellMetadata": {
|
205 |
+
"byteLimit": 2048000,
|
206 |
+
"rowLimit": 10000
|
207 |
+
},
|
208 |
+
"inputWidgets": {},
|
209 |
+
"nuid": "b2a43943-9324-4839-9a47-cfa72de2244b",
|
210 |
+
"showTitle": false,
|
211 |
+
"title": ""
|
212 |
+
},
|
213 |
+
"colab": {
|
214 |
+
"base_uri": "https://localhost:8080/"
|
215 |
+
},
|
216 |
+
"executionInfo": {
|
217 |
+
"elapsed": 564,
|
218 |
+
"status": "ok",
|
219 |
+
"timestamp": 1720679529907,
|
220 |
+
"user": {
|
221 |
+
"displayName": "HUANG DONGHAO _",
|
222 |
+
"userId": "00977795705617022768"
|
223 |
+
},
|
224 |
+
"user_tz": -480
|
225 |
+
},
|
226 |
+
"id": "UgMvt6dIZBrM",
|
227 |
+
"outputId": "ce37581c-fd26-46c2-ad87-d933d99f68f7"
|
228 |
+
},
|
229 |
+
"outputs": [
|
230 |
+
{
|
231 |
+
"name": "stdout",
|
232 |
+
"output_type": "stream",
|
233 |
+
"text": [
|
234 |
+
"Python 3.11.9\n",
|
235 |
+
"Name: torch\n",
|
236 |
+
"Version: 2.4.0+cu124\n",
|
237 |
+
"Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration\n",
|
238 |
+
"Home-page: https://pytorch.org/\n",
|
239 |
+
"Author: PyTorch Team\n",
|
240 |
+
"Author-email: packages@pytorch.org\n",
|
241 |
+
"License: BSD-3\n",
|
242 |
+
"Location: C:\\Users\\dongh\\.conda\\envs\\rapget\\Lib\\site-packages\n",
|
243 |
+
"Requires: filelock, fsspec, jinja2, networkx, sympy, typing-extensions\n",
|
244 |
+
"Required-by: accelerate, bitsandbytes, peft, torchaudio, torchvision\n",
|
245 |
+
"---\n",
|
246 |
+
"Name: transformers\n",
|
247 |
+
"Version: 4.43.3\n",
|
248 |
+
"Summary: State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow\n",
|
249 |
+
"Home-page: https://github.com/huggingface/transformers\n",
|
250 |
+
"Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)\n",
|
251 |
+
"Author-email: transformers@huggingface.co\n",
|
252 |
+
"License: Apache 2.0 License\n",
|
253 |
+
"Location: C:\\Users\\dongh\\.conda\\envs\\rapget\\Lib\\site-packages\n",
|
254 |
+
"Requires: filelock, huggingface-hub, numpy, packaging, pyyaml, regex, requests, safetensors, tokenizers, tqdm\n",
|
255 |
+
"Required-by: peft\n",
|
256 |
+
"CPU times: total: 0 ns\n",
|
257 |
+
"Wall time: 8.35 s\n"
|
258 |
+
]
|
259 |
+
}
|
260 |
+
],
|
261 |
+
"source": [
|
262 |
+
"%%time\n",
|
263 |
+
"os.environ[\"TOKENIZERS_PARALLELISM\"] = \"true\"\n",
|
264 |
+
"\n",
|
265 |
+
"!python --version\n",
|
266 |
+
"!pip show torch transformers"
|
267 |
+
]
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"cell_type": "code",
|
271 |
+
"execution_count": 6,
|
272 |
+
"metadata": {
|
273 |
+
"colab": {
|
274 |
+
"base_uri": "https://localhost:8080/"
|
275 |
+
},
|
276 |
+
"executionInfo": {
|
277 |
+
"elapsed": 1685,
|
278 |
+
"status": "ok",
|
279 |
+
"timestamp": 1720679531591,
|
280 |
+
"user": {
|
281 |
+
"displayName": "HUANG DONGHAO _",
|
282 |
+
"userId": "00977795705617022768"
|
283 |
+
},
|
284 |
+
"user_tz": -480
|
285 |
+
},
|
286 |
+
"id": "ZuS_FsLyZBrN",
|
287 |
+
"outputId": "2cba0105-c505-4395-afbd-2f2fee6581d0"
|
288 |
+
},
|
289 |
+
"outputs": [
|
290 |
+
{
|
291 |
+
"name": "stderr",
|
292 |
+
"output_type": "stream",
|
293 |
+
"text": [
|
294 |
+
"c:\\Users\\dongh\\.conda\\envs\\rapget\\Lib\\site-packages\\threadpoolctl.py:1214: RuntimeWarning: \n",
|
295 |
+
"Found Intel OpenMP ('libiomp') and LLVM OpenMP ('libomp') loaded at\n",
|
296 |
+
"the same time. Both libraries are known to be incompatible and this\n",
|
297 |
+
"can cause random crashes or deadlocks on Linux when loaded in the\n",
|
298 |
+
"same Python program.\n",
|
299 |
+
"Using threadpoolctl may cause crashes or deadlocks. For more\n",
|
300 |
+
"information and possible workarounds, please see\n",
|
301 |
+
" https://github.com/joblib/threadpoolctl/blob/master/multiple_openmp.md\n",
|
302 |
+
"\n",
|
303 |
+
" warnings.warn(msg, RuntimeWarning)\n",
|
304 |
+
"[nltk_data] Downloading package wordnet to\n",
|
305 |
+
"[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n",
|
306 |
+
"[nltk_data] Package wordnet is already up-to-date!\n",
|
307 |
+
"[nltk_data] Downloading package punkt to\n",
|
308 |
+
"[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n",
|
309 |
+
"[nltk_data] Package punkt is already up-to-date!\n",
|
310 |
+
"[nltk_data] Downloading package omw-1.4 to\n",
|
311 |
+
"[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n",
|
312 |
+
"[nltk_data] Package omw-1.4 is already up-to-date!\n"
|
313 |
+
]
|
314 |
+
},
|
315 |
+
{
|
316 |
+
"name": "stdout",
|
317 |
+
"output_type": "stream",
|
318 |
+
"text": [
|
319 |
+
"loading: d:\\code\\projects\\rapget-translation\\eval_modules\\calc_repetitions.py\n",
|
320 |
+
"loading d:\\code\\projects\\rapget-translation\\llm_toolkit\\translation_utils.py\n"
|
321 |
+
]
|
322 |
+
},
|
323 |
+
{
|
324 |
+
"name": "stderr",
|
325 |
+
"output_type": "stream",
|
326 |
+
"text": [
|
327 |
+
"[nltk_data] Downloading package wordnet to\n",
|
328 |
+
"[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n",
|
329 |
+
"[nltk_data] Package wordnet is already up-to-date!\n",
|
330 |
+
"[nltk_data] Downloading package punkt to\n",
|
331 |
+
"[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n",
|
332 |
+
"[nltk_data] Package punkt is already up-to-date!\n",
|
333 |
+
"[nltk_data] Downloading package omw-1.4 to\n",
|
334 |
+
"[nltk_data] C:\\Users\\dongh\\AppData\\Roaming\\nltk_data...\n",
|
335 |
+
"[nltk_data] Package omw-1.4 is already up-to-date!\n"
|
336 |
+
]
|
337 |
+
},
|
338 |
+
{
|
339 |
+
"name": "stdout",
|
340 |
+
"output_type": "stream",
|
341 |
+
"text": [
|
342 |
+
"CUDA is available, we have found 1 GPU(s)\n",
|
343 |
+
"NVIDIA GeForce RTX 4080 Laptop GPU\n",
|
344 |
+
"CUDA version: 12.4\n"
|
345 |
+
]
|
346 |
+
}
|
347 |
+
],
|
348 |
+
"source": [
|
349 |
+
"from llm_toolkit.llm_utils import *\n",
|
350 |
+
"from llm_toolkit.translation_utils import *\n",
|
351 |
+
"\n",
|
352 |
+
"device = check_gpu()"
|
353 |
+
]
|
354 |
+
},
|
355 |
+
{
|
356 |
+
"cell_type": "code",
|
357 |
+
"execution_count": 7,
|
358 |
+
"metadata": {},
|
359 |
+
"outputs": [
|
360 |
+
{
|
361 |
+
"name": "stdout",
|
362 |
+
"output_type": "stream",
|
363 |
+
"text": [
|
364 |
+
"loading train/test data files\n",
|
365 |
+
"DatasetDict({\n",
|
366 |
+
" train: Dataset({\n",
|
367 |
+
" features: ['chinese', 'english'],\n",
|
368 |
+
" num_rows: 4528\n",
|
369 |
+
" })\n",
|
370 |
+
" test: Dataset({\n",
|
371 |
+
" features: ['chinese', 'english'],\n",
|
372 |
+
" num_rows: 1133\n",
|
373 |
+
" })\n",
|
374 |
+
"})\n"
|
375 |
+
]
|
376 |
+
}
|
377 |
+
],
|
378 |
+
"source": [
|
379 |
+
"datasets = load_translation_dataset(data_path)"
|
380 |
+
]
|
381 |
+
},
|
382 |
+
{
|
383 |
+
"cell_type": "code",
|
384 |
+
"execution_count": 8,
|
385 |
+
"metadata": {},
|
386 |
+
"outputs": [],
|
387 |
+
"source": [
|
388 |
+
"os.getenv(\"OPENAI_MODEL\")\n",
|
389 |
+
"base_url = os.getenv(\"OPENAI_BASE_URL\") or None"
|
390 |
+
]
|
391 |
+
},
|
392 |
+
{
|
393 |
+
"cell_type": "code",
|
394 |
+
"execution_count": 9,
|
395 |
+
"metadata": {},
|
396 |
+
"outputs": [
|
397 |
+
{
|
398 |
+
"name": "stdout",
|
399 |
+
"output_type": "stream",
|
400 |
+
"text": [
|
401 |
+
"--------------------------------------------------\n",
|
402 |
+
"chinese: 那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\n",
|
403 |
+
"--------------------------------------------------\n",
|
404 |
+
"english: When Grannie Liu heard Xi-feng talk about 'difficulties' she concluded that there was no hope. Her delight and the way in which her face lit up with pleasure when she heard that she was, after all, to be given twenty taels of silver can be imagined. 'We knew you had your troubles,' she said, 'but as the saying goes, 'A starved camel is bigger than a fat horse.'\n",
|
405 |
+
"--------------------------------------------------\n",
|
406 |
+
"chinese: 后来她不挣扎了,对我说,混蛋,你要把我怎么办。\n",
|
407 |
+
"--------------------------------------------------\n",
|
408 |
+
"english: After a while, she no longer struggled and said, You bastard! What are you going to do with me?\n"
|
409 |
+
]
|
410 |
+
}
|
411 |
+
],
|
412 |
+
"source": [
|
413 |
+
"eval_dataset = datasets[\"test\"].select([260, 908])\n",
|
414 |
+
"print_row_details(eval_dataset.to_pandas(), range(len(eval_dataset)))"
|
415 |
+
]
|
416 |
+
},
|
417 |
+
{
|
418 |
+
"cell_type": "code",
|
419 |
+
"execution_count": 10,
|
420 |
+
"metadata": {},
|
421 |
+
"outputs": [
|
422 |
+
{
|
423 |
+
"name": "stdout",
|
424 |
+
"output_type": "stream",
|
425 |
+
"text": [
|
426 |
+
"You will be given a Chinese sentence to translate. If it is an incomplete sentence, or if you are unsure about the meaning, simply copy the input text as your output. Do not output any additional sentence such as explanation or reasoning.\n",
|
427 |
+
"\n",
|
428 |
+
"Example Translations:\n",
|
429 |
+
"Chinese: 全仗着狐仙搭救。\n",
|
430 |
+
"English: Because I was protected by a fox fairy.\n",
|
431 |
+
"Chinese: 过后,表哥告诉她俩,这人是导演,在外国留过学的,还会编剧,今天拍的这戏,就是他自编自导的。\n",
|
432 |
+
"English: He was the director, the cousin later told them. He had studied abroad and was also a screenwriter; in fact he had written and directed the scene they had earlier seen being filmed.\n",
|
433 |
+
"Chinese: 这凤姐忽然想起一件事来,便向窗外叫:“蓉儿回来!”\n",
|
434 |
+
"English: Xi-feng suddenly seemed to remember something, and called to him through the window, 'Rong, come back!'\n",
|
435 |
+
"Chinese: 三个老红卫兵走到叶文洁面前,面对着她站成了一排——当年,她们也是这样面对叶哲泰的——试图再现那早已忘却的尊严,但她们当年那魔鬼般的精神力量显然已荡然无存。\n",
|
436 |
+
"English: The three old Red Guards stood in front of Ye in a row—just like they had stood against Ye Zhetai—trying to recapture their long-forgotten dignity. But the demonic spiritual energy that had once propelled them was gone.\n",
|
437 |
+
"Chinese: 程先生照单全收,都是一个“谢”字,然后问王琦瑶有什么话说。\n",
|
438 |
+
"English: Mr. Cheng accepted their toast with equanimity and a 'thank you.' Then, turning to Wang Qiyao, he asked if she had anything to say.\n",
|
439 |
+
"\n",
|
440 |
+
"Chinese: {input}\n",
|
441 |
+
"English:\n"
|
442 |
+
]
|
443 |
+
}
|
444 |
+
],
|
445 |
+
"source": [
|
446 |
+
"translation_prompt = get_few_shot_prompt(datasets[\"train\"], num_shots=5)\n",
|
447 |
+
"print(translation_prompt)"
|
448 |
+
]
|
449 |
+
},
|
450 |
+
{
|
451 |
+
"cell_type": "code",
|
452 |
+
"execution_count": 11,
|
453 |
+
"metadata": {},
|
454 |
+
"outputs": [
|
455 |
+
{
|
456 |
+
"name": "stdout",
|
457 |
+
"output_type": "stream",
|
458 |
+
"text": [
|
459 |
+
"\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence] Entering Chain run with input:\n",
|
460 |
+
"\u001b[0m{\n",
|
461 |
+
" \"input\": \"那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\"\n",
|
462 |
+
"}\n",
|
463 |
+
"\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
|
464 |
+
"\u001b[0m{\n",
|
465 |
+
" \"input\": \"那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\"\n",
|
466 |
+
"}\n",
|
467 |
+
"\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [1ms] Exiting Prompt run with output:\n",
|
468 |
+
"\u001b[0m[outputs]\n",
|
469 |
+
"\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] Entering LLM run with input:\n",
|
470 |
+
"\u001b[0m{\n",
|
471 |
+
" \"prompts\": [\n",
|
472 |
+
" \"System: You are a helpful assistant that translates Chinese to English.\\nHuman: You will be given a Chinese sentence to translate. If it is an incomplete sentence, or if you are unsure about the meaning, simply copy the input text as your output. Do not output any additional sentence such as explanation or reasoning.\\n\\nExample Translations:\\nChinese: 全仗着狐仙搭救。\\nEnglish: Because I was protected by a fox fairy.\\nChinese: 过后,表哥告诉她俩,这人是导演,在外国留过学的,还会编剧,今天拍的这戏,就是他自编自导的。\\nEnglish: He was the director, the cousin later told them. He had studied abroad and was also a screenwriter; in fact he had written and directed the scene they had earlier seen being filmed.\\nChinese: 这凤姐忽然想起一件事来,便向窗外叫:“蓉儿回来!”\\nEnglish: Xi-feng suddenly seemed to remember something, and called to him through the window, 'Rong, come back!'\\nChinese: 三个老红卫兵走到叶文洁面前,面对着她站成了一排——当年,她们也是这样面对叶哲泰的——试图再现那早已忘却的尊严,但她们当年那魔鬼般的精神力量显然已荡然无存。\\nEnglish: The three old Red Guards stood in front of Ye in a row—just like they had stood against Ye Zhetai—trying to recapture their long-forgotten dignity. But the demonic spiritual energy that had once propelled them was gone.\\nChinese: 程先生照单全收,都是一个“谢”字,然后问王琦瑶有什么话说。\\nEnglish: Mr. Cheng accepted their toast with equanimity and a 'thank you.' Then, turning to Wang Qiyao, he asked if she had anything to say.\\n\\nChinese: 那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\\nEnglish:\"\n",
|
473 |
+
" ]\n",
|
474 |
+
"}\n",
|
475 |
+
"\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] [1.45s] Exiting LLM run with output:\n",
|
476 |
+
"\u001b[0m{\n",
|
477 |
+
" \"generations\": [\n",
|
478 |
+
" [\n",
|
479 |
+
" {\n",
|
480 |
+
" \"text\": \"That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \\\"We also know about difficulties, but as the saying goes: 'A dead camel is still bigger than a horse.'\\\"\",\n",
|
481 |
+
" \"generation_info\": {\n",
|
482 |
+
" \"finish_reason\": \"stop\",\n",
|
483 |
+
" \"logprobs\": null\n",
|
484 |
+
" },\n",
|
485 |
+
" \"type\": \"ChatGeneration\",\n",
|
486 |
+
" \"message\": {\n",
|
487 |
+
" \"lc\": 1,\n",
|
488 |
+
" \"type\": \"constructor\",\n",
|
489 |
+
" \"id\": [\n",
|
490 |
+
" \"langchain\",\n",
|
491 |
+
" \"schema\",\n",
|
492 |
+
" \"messages\",\n",
|
493 |
+
" \"AIMessage\"\n",
|
494 |
+
" ],\n",
|
495 |
+
" \"kwargs\": {\n",
|
496 |
+
" \"content\": \"That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \\\"We also know about difficulties, but as the saying goes: 'A dead camel is still bigger than a horse.'\\\"\",\n",
|
497 |
+
" \"response_metadata\": {\n",
|
498 |
+
" \"token_usage\": {\n",
|
499 |
+
" \"completion_tokens\": 56,\n",
|
500 |
+
" \"prompt_tokens\": 484,\n",
|
501 |
+
" \"total_tokens\": 540\n",
|
502 |
+
" },\n",
|
503 |
+
" \"model_name\": \"gpt-4o-mini-2024-07-18\",\n",
|
504 |
+
" \"system_fingerprint\": \"fp_0f03d4f0ee\",\n",
|
505 |
+
" \"finish_reason\": \"stop\",\n",
|
506 |
+
" \"logprobs\": null\n",
|
507 |
+
" },\n",
|
508 |
+
" \"type\": \"ai\",\n",
|
509 |
+
" \"id\": \"run-1c7d8c24-e2d6-4ba3-b87a-16101fb1ce80-0\",\n",
|
510 |
+
" \"usage_metadata\": {\n",
|
511 |
+
" \"input_tokens\": 484,\n",
|
512 |
+
" \"output_tokens\": 56,\n",
|
513 |
+
" \"total_tokens\": 540\n",
|
514 |
+
" },\n",
|
515 |
+
" \"tool_calls\": [],\n",
|
516 |
+
" \"invalid_tool_calls\": []\n",
|
517 |
+
" }\n",
|
518 |
+
" }\n",
|
519 |
+
" }\n",
|
520 |
+
" ]\n",
|
521 |
+
" ],\n",
|
522 |
+
" \"llm_output\": {\n",
|
523 |
+
" \"token_usage\": {\n",
|
524 |
+
" \"completion_tokens\": 56,\n",
|
525 |
+
" \"prompt_tokens\": 484,\n",
|
526 |
+
" \"total_tokens\": 540\n",
|
527 |
+
" },\n",
|
528 |
+
" \"model_name\": \"gpt-4o-mini-2024-07-18\",\n",
|
529 |
+
" \"system_fingerprint\": \"fp_0f03d4f0ee\"\n",
|
530 |
+
" },\n",
|
531 |
+
" \"run\": null\n",
|
532 |
+
"}\n",
|
533 |
+
"\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [1.46s] Exiting Chain run with output:\n",
|
534 |
+
"\u001b[0m[outputs]\n"
|
535 |
+
]
|
536 |
+
},
|
537 |
+
{
|
538 |
+
"data": {
|
539 |
+
"text/plain": [
|
540 |
+
"'That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \"We also know about difficulties, but as the saying goes: \\'A dead camel is still bigger than a horse.\\'\"'"
|
541 |
+
]
|
542 |
+
},
|
543 |
+
"execution_count": 11,
|
544 |
+
"metadata": {},
|
545 |
+
"output_type": "execute_result"
|
546 |
+
}
|
547 |
+
],
|
548 |
+
"source": [
|
549 |
+
"from langchain_core.globals import set_debug\n",
|
550 |
+
"\n",
|
551 |
+
"set_debug(True)\n",
|
552 |
+
"\n",
|
553 |
+
"translate_via_openai(\n",
|
554 |
+
" eval_dataset[\"chinese\"][0], translation_prompt, max_tokens=max_new_tokens\n",
|
555 |
+
")"
|
556 |
+
]
|
557 |
+
},
|
558 |
+
{
|
559 |
+
"cell_type": "code",
|
560 |
+
"execution_count": 12,
|
561 |
+
"metadata": {},
|
562 |
+
"outputs": [],
|
563 |
+
"source": [
|
564 |
+
"datasets[\"test\"] = eval_dataset"
|
565 |
+
]
|
566 |
+
},
|
567 |
+
{
|
568 |
+
"cell_type": "code",
|
569 |
+
"execution_count": 13,
|
570 |
+
"metadata": {},
|
571 |
+
"outputs": [
|
572 |
+
{
|
573 |
+
"name": "stderr",
|
574 |
+
"output_type": "stream",
|
575 |
+
"text": [
|
576 |
+
" 0%| | 0/2 [00:00<?, ?it/s]"
|
577 |
+
]
|
578 |
+
},
|
579 |
+
{
|
580 |
+
"name": "stdout",
|
581 |
+
"output_type": "stream",
|
582 |
+
"text": [
|
583 |
+
"\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence] Entering Chain run with input:\n",
|
584 |
+
"\u001b[0m{\n",
|
585 |
+
" \"input\": \"那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\"\n",
|
586 |
+
"}\n",
|
587 |
+
"\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
|
588 |
+
"\u001b[0m{\n",
|
589 |
+
" \"input\": \"那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\"\n",
|
590 |
+
"}\n",
|
591 |
+
"\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [1ms] Exiting Prompt run with output:\n",
|
592 |
+
"\u001b[0m[outputs]\n",
|
593 |
+
"\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] Entering LLM run with input:\n",
|
594 |
+
"\u001b[0m{\n",
|
595 |
+
" \"prompts\": [\n",
|
596 |
+
" \"System: You are a helpful assistant that translates Chinese to English.\\nHuman: You will be given a Chinese sentence to translate. If it is an incomplete sentence, or if you are unsure about the meaning, simply copy the input text as your output. Do not output any additional sentence such as explanation or reasoning.\\n\\nExample Translations:\\nChinese: 全仗着狐仙搭救。\\nEnglish: Because I was protected by a fox fairy.\\nChinese: 过后,表哥告诉她俩,这人是导演,在外国留过学的,还会编剧,今天拍的这戏,就是他自编自导的。\\nEnglish: He was the director, the cousin later told them. He had studied abroad and was also a screenwriter; in fact he had written and directed the scene they had earlier seen being filmed.\\nChinese: 这凤姐忽然想起一件事来,便向窗外叫:“蓉儿回来!”\\nEnglish: Xi-feng suddenly seemed to remember something, and called to him through the window, 'Rong, come back!'\\nChinese: 三个老红卫兵走到叶文洁面前,面对着她站成了一排——当年,她们也是这样面对叶哲泰的——试图再现那早已忘却的尊严,但她们当年那魔鬼般的精神力量显然已荡然无存。\\nEnglish: The three old Red Guards stood in front of Ye in a row—just like they had stood against Ye Zhetai—trying to recapture their long-forgotten dignity. But the demonic spiritual energy that had once propelled them was gone.\\nChinese: 程先生照单全收,都是一个“谢”字,然后问王琦瑶有什么话说。\\nEnglish: Mr. Cheng accepted their toast with equanimity and a 'thank you.' Then, turning to Wang Qiyao, he asked if she had anything to say.\\n\\nChinese: 那刘姥姥先听见告艰苦,只当是没想头了, 又听见给他二十两银子,喜的眉开眼笑道:“我们也知道艰难的,但只俗语说的:‘瘦死的骆驼比马还大’呢。\\nEnglish:\"\n",
|
597 |
+
" ]\n",
|
598 |
+
"}\n"
|
599 |
+
]
|
600 |
+
},
|
601 |
+
{
|
602 |
+
"name": "stderr",
|
603 |
+
"output_type": "stream",
|
604 |
+
"text": [
|
605 |
+
" 50%|█████ | 1/2 [00:02<00:02, 2.31s/it]"
|
606 |
+
]
|
607 |
+
},
|
608 |
+
{
|
609 |
+
"name": "stdout",
|
610 |
+
"output_type": "stream",
|
611 |
+
"text": [
|
612 |
+
"\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] [1.27s] Exiting LLM run with output:\n",
|
613 |
+
"\u001b[0m{\n",
|
614 |
+
" \"generations\": [\n",
|
615 |
+
" [\n",
|
616 |
+
" {\n",
|
617 |
+
" \"text\": \"That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \\\"We also know it's difficult, but as the saying goes: 'A dead camel is still bigger than a horse.'\\\"\",\n",
|
618 |
+
" \"generation_info\": {\n",
|
619 |
+
" \"finish_reason\": \"stop\",\n",
|
620 |
+
" \"logprobs\": null\n",
|
621 |
+
" },\n",
|
622 |
+
" \"type\": \"ChatGeneration\",\n",
|
623 |
+
" \"message\": {\n",
|
624 |
+
" \"lc\": 1,\n",
|
625 |
+
" \"type\": \"constructor\",\n",
|
626 |
+
" \"id\": [\n",
|
627 |
+
" \"langchain\",\n",
|
628 |
+
" \"schema\",\n",
|
629 |
+
" \"messages\",\n",
|
630 |
+
" \"AIMessage\"\n",
|
631 |
+
" ],\n",
|
632 |
+
" \"kwargs\": {\n",
|
633 |
+
" \"content\": \"That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \\\"We also know it's difficult, but as the saying goes: 'A dead camel is still bigger than a horse.'\\\"\",\n",
|
634 |
+
" \"response_metadata\": {\n",
|
635 |
+
" \"token_usage\": {\n",
|
636 |
+
" \"completion_tokens\": 56,\n",
|
637 |
+
" \"prompt_tokens\": 484,\n",
|
638 |
+
" \"total_tokens\": 540\n",
|
639 |
+
" },\n",
|
640 |
+
" \"model_name\": \"gpt-4o-mini-2024-07-18\",\n",
|
641 |
+
" \"system_fingerprint\": \"fp_9b0abffe81\",\n",
|
642 |
+
" \"finish_reason\": \"stop\",\n",
|
643 |
+
" \"logprobs\": null\n",
|
644 |
+
" },\n",
|
645 |
+
" \"type\": \"ai\",\n",
|
646 |
+
" \"id\": \"run-68581936-c5f8-4d63-a40a-9ae04e88d234-0\",\n",
|
647 |
+
" \"usage_metadata\": {\n",
|
648 |
+
" \"input_tokens\": 484,\n",
|
649 |
+
" \"output_tokens\": 56,\n",
|
650 |
+
" \"total_tokens\": 540\n",
|
651 |
+
" },\n",
|
652 |
+
" \"tool_calls\": [],\n",
|
653 |
+
" \"invalid_tool_calls\": []\n",
|
654 |
+
" }\n",
|
655 |
+
" }\n",
|
656 |
+
" }\n",
|
657 |
+
" ]\n",
|
658 |
+
" ],\n",
|
659 |
+
" \"llm_output\": {\n",
|
660 |
+
" \"token_usage\": {\n",
|
661 |
+
" \"completion_tokens\": 56,\n",
|
662 |
+
" \"prompt_tokens\": 484,\n",
|
663 |
+
" \"total_tokens\": 540\n",
|
664 |
+
" },\n",
|
665 |
+
" \"model_name\": \"gpt-4o-mini-2024-07-18\",\n",
|
666 |
+
" \"system_fingerprint\": \"fp_9b0abffe81\"\n",
|
667 |
+
" },\n",
|
668 |
+
" \"run\": null\n",
|
669 |
+
"}\n",
|
670 |
+
"\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [1.28s] Exiting Chain run with output:\n",
|
671 |
+
"\u001b[0m[outputs]\n",
|
672 |
+
"\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence] Entering Chain run with input:\n",
|
673 |
+
"\u001b[0m{\n",
|
674 |
+
" \"input\": \"后来她不挣扎了,对我说,混蛋,你要把我怎么办。\"\n",
|
675 |
+
"}\n",
|
676 |
+
"\u001b[32;1m\u001b[1;3m[chain/start]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] Entering Prompt run with input:\n",
|
677 |
+
"\u001b[0m{\n",
|
678 |
+
" \"input\": \"后来她不挣扎了,对我说,混蛋,你要把我怎么办。\"\n",
|
679 |
+
"}\n",
|
680 |
+
"\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence > prompt:ChatPromptTemplate] [1ms] Exiting Prompt run with output:\n",
|
681 |
+
"\u001b[0m[outputs]\n",
|
682 |
+
"\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] Entering LLM run with input:\n",
|
683 |
+
"\u001b[0m{\n",
|
684 |
+
" \"prompts\": [\n",
|
685 |
+
" \"System: You are a helpful assistant that translates Chinese to English.\\nHuman: You will be given a Chinese sentence to translate. If it is an incomplete sentence, or if you are unsure about the meaning, simply copy the input text as your output. Do not output any additional sentence such as explanation or reasoning.\\n\\nExample Translations:\\nChinese: 全仗着狐仙搭救。\\nEnglish: Because I was protected by a fox fairy.\\nChinese: 过后,表哥告诉她俩,这人是导演,在外国留过学的,还会编剧,今天拍的这戏,就是他自编自导的。\\nEnglish: He was the director, the cousin later told them. He had studied abroad and was also a screenwriter; in fact he had written and directed the scene they had earlier seen being filmed.\\nChinese: 这凤姐忽然想起一件事来,便向窗外叫:“蓉儿回来!”\\nEnglish: Xi-feng suddenly seemed to remember something, and called to him through the window, 'Rong, come back!'\\nChinese: 三个老红卫兵走到叶文洁面前,面对着她站成了一排——当年,她们也是这样面对叶哲泰的——试图再现那早已忘却的尊严,但她们当年那魔鬼般的精神力量显然已荡然无存。\\nEnglish: The three old Red Guards stood in front of Ye in a row—just like they had stood against Ye Zhetai—trying to recapture their long-forgotten dignity. But the demonic spiritual energy that had once propelled them was gone.\\nChinese: 程先生照单全收,都是一个“谢”字,然后问王琦瑶有什么话说。\\nEnglish: Mr. Cheng accepted their toast with equanimity and a 'thank you.' Then, turning to Wang Qiyao, he asked if she had anything to say.\\n\\nChinese: 后来她不挣扎了,对我说,混蛋,你要把我怎么办。\\nEnglish:\"\n",
|
686 |
+
" ]\n",
|
687 |
+
"}\n"
|
688 |
+
]
|
689 |
+
},
|
690 |
+
{
|
691 |
+
"name": "stderr",
|
692 |
+
"output_type": "stream",
|
693 |
+
"text": [
|
694 |
+
"100%|██████████| 2/2 [00:04<00:00, 2.12s/it]"
|
695 |
+
]
|
696 |
+
},
|
697 |
+
{
|
698 |
+
"name": "stdout",
|
699 |
+
"output_type": "stream",
|
700 |
+
"text": [
|
701 |
+
"\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[chain:RunnableSequence > llm:ChatOpenAI] [908ms] Exiting LLM run with output:\n",
|
702 |
+
"\u001b[0m{\n",
|
703 |
+
" \"generations\": [\n",
|
704 |
+
" [\n",
|
705 |
+
" {\n",
|
706 |
+
" \"text\": \"Later, she stopped struggling and said to me, \\\"Bastard, what are you going to do with me?\\\"\",\n",
|
707 |
+
" \"generation_info\": {\n",
|
708 |
+
" \"finish_reason\": \"stop\",\n",
|
709 |
+
" \"logprobs\": null\n",
|
710 |
+
" },\n",
|
711 |
+
" \"type\": \"ChatGeneration\",\n",
|
712 |
+
" \"message\": {\n",
|
713 |
+
" \"lc\": 1,\n",
|
714 |
+
" \"type\": \"constructor\",\n",
|
715 |
+
" \"id\": [\n",
|
716 |
+
" \"langchain\",\n",
|
717 |
+
" \"schema\",\n",
|
718 |
+
" \"messages\",\n",
|
719 |
+
" \"AIMessage\"\n",
|
720 |
+
" ],\n",
|
721 |
+
" \"kwargs\": {\n",
|
722 |
+
" \"content\": \"Later, she stopped struggling and said to me, \\\"Bastard, what are you going to do with me?\\\"\",\n",
|
723 |
+
" \"response_metadata\": {\n",
|
724 |
+
" \"token_usage\": {\n",
|
725 |
+
" \"completion_tokens\": 24,\n",
|
726 |
+
" \"prompt_tokens\": 433,\n",
|
727 |
+
" \"total_tokens\": 457\n",
|
728 |
+
" },\n",
|
729 |
+
" \"model_name\": \"gpt-4o-mini-2024-07-18\",\n",
|
730 |
+
" \"system_fingerprint\": \"fp_611b667b19\",\n",
|
731 |
+
" \"finish_reason\": \"stop\",\n",
|
732 |
+
" \"logprobs\": null\n",
|
733 |
+
" },\n",
|
734 |
+
" \"type\": \"ai\",\n",
|
735 |
+
" \"id\": \"run-e4bb10fb-f7c4-4440-82ba-c13a1a82bc00-0\",\n",
|
736 |
+
" \"usage_metadata\": {\n",
|
737 |
+
" \"input_tokens\": 433,\n",
|
738 |
+
" \"output_tokens\": 24,\n",
|
739 |
+
" \"total_tokens\": 457\n",
|
740 |
+
" },\n",
|
741 |
+
" \"tool_calls\": [],\n",
|
742 |
+
" \"invalid_tool_calls\": []\n",
|
743 |
+
" }\n",
|
744 |
+
" }\n",
|
745 |
+
" }\n",
|
746 |
+
" ]\n",
|
747 |
+
" ],\n",
|
748 |
+
" \"llm_output\": {\n",
|
749 |
+
" \"token_usage\": {\n",
|
750 |
+
" \"completion_tokens\": 24,\n",
|
751 |
+
" \"prompt_tokens\": 433,\n",
|
752 |
+
" \"total_tokens\": 457\n",
|
753 |
+
" },\n",
|
754 |
+
" \"model_name\": \"gpt-4o-mini-2024-07-18\",\n",
|
755 |
+
" \"system_fingerprint\": \"fp_611b667b19\"\n",
|
756 |
+
" },\n",
|
757 |
+
" \"run\": null\n",
|
758 |
+
"}\n",
|
759 |
+
"\u001b[36;1m\u001b[1;3m[chain/end]\u001b[0m \u001b[1m[chain:RunnableSequence] [918ms] Exiting Chain run with output:\n",
|
760 |
+
"\u001b[0m[outputs]\n"
|
761 |
+
]
|
762 |
+
},
|
763 |
+
{
|
764 |
+
"name": "stderr",
|
765 |
+
"output_type": "stream",
|
766 |
+
"text": [
|
767 |
+
"\n"
|
768 |
+
]
|
769 |
+
}
|
770 |
+
],
|
771 |
+
"source": [
|
772 |
+
"predictions = eval_openai(5, datasets)"
|
773 |
+
]
|
774 |
+
},
|
775 |
+
{
|
776 |
+
"cell_type": "code",
|
777 |
+
"execution_count": 14,
|
778 |
+
"metadata": {},
|
779 |
+
"outputs": [
|
780 |
+
{
|
781 |
+
"name": "stdout",
|
782 |
+
"output_type": "stream",
|
783 |
+
"text": [
|
784 |
+
"['That Liu Laolao first heard about the hardships and thought it was hopeless, then heard about the twenty taels of silver and smiled with joy, saying, \"We also know it\\'s difficult, but as the saying goes: \\'A dead camel is still bigger than a horse.\\'\"', 'Later, she stopped struggling and said to me, \"Bastard, what are you going to do with me?\"']\n"
|
785 |
+
]
|
786 |
+
}
|
787 |
+
],
|
788 |
+
"source": [
|
789 |
+
"print(predictions)"
|
790 |
+
]
|
791 |
+
},
|
792 |
+
{
|
793 |
+
"cell_type": "code",
|
794 |
+
"execution_count": 15,
|
795 |
+
"metadata": {},
|
796 |
+
"outputs": [
|
797 |
+
{
|
798 |
+
"data": {
|
799 |
+
"text/plain": [
|
800 |
+
"{'meteor': 0.5376810911615811,\n",
|
801 |
+
" 'bleu_scores': {'bleu': 0.16133991724232039,\n",
|
802 |
+
" 'precisions': [0.5454545454545454,\n",
|
803 |
+
" 0.26666666666666666,\n",
|
804 |
+
" 0.1643835616438356,\n",
|
805 |
+
" 0.09859154929577464],\n",
|
806 |
+
" 'brevity_penalty': 0.7322097138745853,\n",
|
807 |
+
" 'length_ratio': 0.7623762376237624,\n",
|
808 |
+
" 'translation_length': 77,\n",
|
809 |
+
" 'reference_length': 101},\n",
|
810 |
+
" 'rouge_scores': {'rouge1': 0.5594202898550725,\n",
|
811 |
+
" 'rouge2': 0.362051015096304,\n",
|
812 |
+
" 'rougeL': 0.5246376811594203,\n",
|
813 |
+
" 'rougeLsum': 0.5246376811594203},\n",
|
814 |
+
" 'accuracy': 0.0}"
|
815 |
+
]
|
816 |
+
},
|
817 |
+
"execution_count": 15,
|
818 |
+
"metadata": {},
|
819 |
+
"output_type": "execute_result"
|
820 |
+
}
|
821 |
+
],
|
822 |
+
"source": [
|
823 |
+
"calc_metrics(eval_dataset[\"english\"], predictions)"
|
824 |
+
]
|
825 |
+
}
|
826 |
+
],
|
827 |
+
"metadata": {
|
828 |
+
"accelerator": "GPU",
|
829 |
+
"application/vnd.databricks.v1+notebook": {
|
830 |
+
"dashboards": [],
|
831 |
+
"environmentMetadata": null,
|
832 |
+
"language": "python",
|
833 |
+
"notebookMetadata": {
|
834 |
+
"mostRecentlyExecutedCommandWithImplicitDF": {
|
835 |
+
"commandId": -1,
|
836 |
+
"dataframes": [
|
837 |
+
"_sqldf"
|
838 |
+
]
|
839 |
+
},
|
840 |
+
"pythonIndentUnit": 4
|
841 |
+
},
|
842 |
+
"notebookName": "10_eval-lf-medium-py3.11",
|
843 |
+
"widgets": {}
|
844 |
+
},
|
845 |
+
"colab": {
|
846 |
+
"gpuType": "L4",
|
847 |
+
"provenance": []
|
848 |
+
},
|
849 |
+
"kernelspec": {
|
850 |
+
"display_name": "Python 3",
|
851 |
+
"name": "python3"
|
852 |
+
},
|
853 |
+
"language_info": {
|
854 |
+
"codemirror_mode": {
|
855 |
+
"name": "ipython",
|
856 |
+
"version": 3
|
857 |
+
},
|
858 |
+
"file_extension": ".py",
|
859 |
+
"mimetype": "text/x-python",
|
860 |
+
"name": "python",
|
861 |
+
"nbconvert_exporter": "python",
|
862 |
+
"pygments_lexer": "ipython3",
|
863 |
+
"version": "3.11.9"
|
864 |
+
}
|
865 |
+
},
|
866 |
+
"nbformat": 4,
|
867 |
+
"nbformat_minor": 0
|
868 |
+
}
|
notebooks/02_Fine_Tune_OpenAI.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/02a_Fine_Tune_GPT-4o.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
results/mac-results_rpp_with_mnt_2048_generic_prompt_metrics.csv
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
model,rpp,comet,meteor,spbleu,bleu_1,rouge_l,ews_score,repetition_score,total_repetitions,rap,translation_completeness,num_max_output_tokens
|
2 |
+
Qwen/Qwen2-72B-Instruct,1.00,0.7457879471336964,0.4655033970145371,11.09789843749336,0.1109789843749336,0.4309698494389731,0.0,48.81906443071492,48.81906443071492,0.4214638674295989,0.9902912621359223,10
|
3 |
+
internlm/internlm2_5-7b-chat,1.00,0.7357995069773978,0.4297612514398102,15.060226683930628,0.1506022668393063,0.4097577795330234,0.0,11.742277140335393,11.742277140335393,0.5502106789386991,1.0,2
|
4 |
+
internlm/internlm2_5-7b-chat,1.02,0.7377187550620283,0.4246676977198055,14.728605282752795,0.147286052827528,0.4063246630867048,0.0,5.420123565754634,5.420123565754634,0.6209294646606592,1.0,1
|
5 |
+
internlm/internlm2_5-7b-chat,1.04,0.7371160490183523,0.4173352728374962,13.846403511622256,0.1384640351162226,0.3988121301027288,0.0,5.3097969991173875,5.3097969991173875,0.6220549062227617,1.0,1
|
6 |
+
internlm/internlm2_5-7b-chat,1.06,0.7338597697698218,0.3997609847704189,12.213374588416173,0.1221337458841617,0.3841365748920261,0.0,5.316857899382171,5.316857899382171,0.6192022797578944,1.0,1
|
7 |
+
internlm/internlm2_5-7b-chat,1.08,0.7318234702626478,0.3881614120395272,11.369735763522288,0.1136973576352228,0.372963223209074,0.0,5.340688437775817,5.340688437775817,0.6171325620248217,1.0,1
|
8 |
+
internlm/internlm2_5-7b-chat,1.10,0.7288648442604431,0.3784182249483568,10.377989030628608,0.103779890306286,0.3618424457502351,0.0,5.316857899382171,5.316857899382171,0.6149877562344177,1.0,1
|
9 |
+
microsoft/Phi-3.5-mini-instruct,1.00,0.710605339281136,0.3788926591792472,9.70032874202361,0.097003287420236,0.3556134739443916,1.7987643424536628,16.421006178287733,18.219770520741395,0.4898856540979652,1.0,4
|
10 |
+
microsoft/Phi-3.5-mini-instruct,1.02,0.7150978385770836,0.3741049510326346,9.910633597905436,0.0991063359790543,0.3453160556383774,0.0,10.690203000882612,10.690203000882612,0.543484568672847,1.0,2
|
11 |
+
microsoft/Phi-3.5-mini-instruct,1.04,0.7074641684778791,0.3538698731015666,9.19721270538052,0.0919721270538052,0.3225824135517728,0.0,0.10944395410414828,0.10944395410414828,0.7041355304734901,1.0,0
|
12 |
+
microsoft/Phi-3.5-mini-instruct,1.06,0.6962301708225224,0.3252854575717334,6.967166383106307,0.069671663831063,0.2948764736589108,0.0,0.09355692850838482,0.09355692850838482,0.6934257926979845,1.0,0
|
13 |
+
microsoft/Phi-3.5-mini-instruct,1.08,0.6823413657174107,0.301599095293242,5.452744292893752,0.0545274429289375,0.2726387617958179,0.0,0.0264783759929391,0.0264783759929391,0.6815586491033614,1.0,0
|
14 |
+
microsoft/Phi-3.5-mini-instruct,1.10,0.6717851540206916,0.2885734336603344,4.751039447225815,0.0475103944722581,0.2604284999048123,0.0,0.04589585172109444,0.04589585172109444,0.670451845604288,1.0,0
|
15 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.00,0.7222260562908512,0.4039898602650971,13.461179673541356,0.1346117967354136,0.3819960428004565,0.0,5.837599293909974,5.837599293909974,0.6020108921217914,1.0,1
|
16 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.02,0.723643534970515,0.4051102919608809,13.18537912294539,0.1318537912294539,0.3824621732976229,0.0,5.7855251544571935,5.7855251544571935,0.6039124380139065,1.0,1
|
17 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.04,0.7238812581796301,0.4039456988919502,13.314773371306682,0.1331477337130668,0.3813737464821349,0.0,5.804060017652251,5.804060017652251,0.6038540012915103,1.0,1
|
18 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.06,0.7252625281686607,0.4012797167602334,13.19924345265053,0.1319924345265053,0.3798291332004637,0.0,5.795233892321271,5.795233892321271,0.6051287090305499,1.0,1
|
19 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.08,0.7261167238322592,0.3987395126194482,12.656486100206328,0.1265648610020633,0.376975448872996,0.0,5.804060017652251,5.804060017652251,0.6057188028233036,1.0,1
|
20 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.10,0.7264630642225547,0.3964859769229444,12.284961706379857,0.1228496170637985,0.3744555065346823,0.0,0.16328331862312445,0.16328331862312445,0.7213887920596253,1.0,0
|
results/mac-results_rpp_with_mnt_2048_metrics.csv
CHANGED
@@ -1,43 +1,43 @@
|
|
1 |
model,rpp,comet,meteor,spbleu,bleu_1,rouge_l,ews_score,repetition_score,total_repetitions,rap,translation_completeness,num_max_output_tokens
|
2 |
-
Qwen/Qwen2-72B-Instruct,1.00,0.7570169081439618,0.
|
3 |
-
Qwen/Qwen2-72B-Instruct,1.02,0.7573581492858762,0.
|
4 |
-
Qwen/Qwen2-72B-Instruct,1.04,0.7574983964372501,0.476362681282195,18.52063321160408,0.1852063321160408,0.
|
5 |
-
Qwen/Qwen2-72B-Instruct,1.06,0.7563851308422812,0.
|
6 |
-
Qwen/Qwen2-72B-Instruct,1.08,0.7554470169417962,0.
|
7 |
-
Qwen/Qwen2-72B-Instruct,1.10,0.7550096405046973,0.4515778511124262,16.22452191616505,0.
|
8 |
Qwen/Qwen2-7B-Instruct,1.00,0.7457721890965501,0.442240791493943,14.38814929350883,0.1438814929350883,0.4160546438584113,0.0,12.81288614298323,12.81288614298323,0.5490966301804292,0.9947043248014121,2
|
9 |
Qwen/Qwen2-7B-Instruct,1.02,0.7474080664545482,0.4400998640836595,15.16172261831792,0.1516172261831792,0.4160749445105633,0.0,7.1562224183583405,7.1562224183583405,0.605472251398711,0.9947043248014121,1
|
10 |
-
Qwen/Qwen2-7B-Instruct,1.04,0.7484375637974869,0.4390136558190875,14.958631815014014,0.
|
11 |
-
Qwen/Qwen2-7B-Instruct,1.06,0.7471612840233287,0.
|
12 |
-
Qwen/Qwen2-7B-Instruct,1.08,0.74519401609845,0.423560805217557,13.
|
13 |
-
Qwen/Qwen2-7B-Instruct,1.10,0.7432071187016402,0.
|
14 |
internlm/internlm2_5-7b-chat,1.00,0.739699612254078,0.4289996929258777,14.734881589173108,0.1473488158917311,0.4096466800937898,0.0,12.751103265666373,12.751103265666373,0.5450982095784719,1.0,2
|
15 |
-
internlm/internlm2_5-7b-chat,1.02,0.740223803961056,0.
|
16 |
-
internlm/internlm2_5-7b-chat,1.04,0.7398856264610577,0.4154585167056314,13.
|
17 |
-
internlm/internlm2_5-7b-chat,1.06,0.7379362287241489,0.
|
18 |
-
internlm/internlm2_5-7b-chat,1.08,0.7319988705684732,0.3873176839854818,11.
|
19 |
-
internlm/internlm2_5-7b-chat,1.10,0.7295350462119345,0.3769306874386757,10.305163787094209,0.
|
20 |
-
microsoft/Phi-3.5-mini-instruct,1.00,0.7107840433177544,0.
|
21 |
-
microsoft/Phi-3.5-mini-instruct,1.02,0.7164765837070485,0.3780585837553919,10.291240080163629,0.
|
22 |
-
microsoft/Phi-3.5-mini-instruct,1.04,0.7111233387336411,0.
|
23 |
-
microsoft/Phi-3.5-mini-instruct,1.06,0.7024363270136286,0.3298733737040869,7.076233088011138,0.
|
24 |
-
microsoft/Phi-3.5-mini-instruct,1.08,0.6882111219210848,0.3054541022592767,5.105510599247868,0.
|
25 |
-
microsoft/Phi-3.5-mini-instruct,1.10,0.6712992989638161,0.2903831801547132,4.091958857999118,0.
|
26 |
-
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.00,0.7501818982248062,0.
|
27 |
-
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.02,0.7485114382045625,0.
|
28 |
-
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.04,0.7500591586357918,0.
|
29 |
-
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.06,0.748812871571673,0.
|
30 |
-
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.08,0.7473851635144647,0.4442106511292453,16.16623784482793,0.
|
31 |
-
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.10,0.7465709781131172,0.
|
32 |
-
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.00,0.7426396049131678,0.
|
33 |
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.02,0.7436477056353469,0.4329054166518245,15.19102241646024,0.1519102241646024,0.4068967964789407,0.0,5.77846425419241,5.77846425419241,0.6207074516423631,1.0,1
|
34 |
-
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.04,0.7440943776351209,0.
|
35 |
-
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.06,0.7426502735395928,0.
|
36 |
-
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.08,0.7408098006080129,0.4206626658729054,13.933703757385222,0.
|
37 |
-
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.10,0.7392685912871718,0.
|
38 |
-
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.00,0.7240239171358935,0.4068335357738006,13.565136550617618,0.
|
39 |
-
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.02,0.7263097057327799,0.4064914781094827,13.42987641622816,0.1342987641622816,0.
|
40 |
-
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.04,0.7276128307708258,0.
|
41 |
-
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.06,0.7276865132383193,0.4014727027723293,13.10860799057166,0.1310860799057166,0.
|
42 |
-
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.08,0.726393195584298,0.3987018836449559,12.850537785783194,0.1285053778578319,0.
|
43 |
-
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.10,0.7244012304511832,0.
|
|
|
1 |
model,rpp,comet,meteor,spbleu,bleu_1,rouge_l,ews_score,repetition_score,total_repetitions,rap,translation_completeness,num_max_output_tokens
|
2 |
+
Qwen/Qwen2-72B-Instruct,1.00,0.7570169081439618,0.4789208192601603,18.953782447211417,0.1895378244721141,0.4520943414365094,0.0,0.09885260370697264,0.09885260370697264,0.7537966634953808,1.0,0
|
3 |
+
Qwen/Qwen2-72B-Instruct,1.02,0.7573581492858762,0.4796836675632054,19.0137490702917,0.190137490702917,0.4520458023287854,0.0,0.08120035304501325,0.08120035304501325,0.7547074311557754,1.0,0
|
4 |
+
Qwen/Qwen2-72B-Instruct,1.04,0.7574983964372501,0.476362681282195,18.52063321160408,0.1852063321160408,0.4489040568717591,0.0,0.10503089143865843,0.10503089143865843,0.7540766638515739,1.0,0
|
5 |
+
Qwen/Qwen2-72B-Instruct,1.06,0.7563851308422812,0.4679636383950649,17.982473951038504,0.1798247395103851,0.441062203630729,0.0,0.07325684024713151,0.07325684024713151,0.7539950363948406,1.0,0
|
6 |
+
Qwen/Qwen2-72B-Instruct,1.08,0.7554470169417962,0.4597578197711645,17.067954025424825,0.1706795402542483,0.4317496244624469,0.0,0.04766107678729038,0.04766107678729038,0.753890250753016,1.0,0
|
7 |
+
Qwen/Qwen2-72B-Instruct,1.10,0.7550096405046973,0.4515778511124262,16.22452191616505,0.1622452191616504,0.4242083184666598,0.0,0.05736981465136805,0.05736981465136805,0.7531385283434515,1.0,0
|
8 |
Qwen/Qwen2-7B-Instruct,1.00,0.7457721890965501,0.442240791493943,14.38814929350883,0.1438814929350883,0.4160546438584113,0.0,12.81288614298323,12.81288614298323,0.5490966301804292,0.9947043248014121,2
|
9 |
Qwen/Qwen2-7B-Instruct,1.02,0.7474080664545482,0.4400998640836595,15.16172261831792,0.1516172261831792,0.4160749445105633,0.0,7.1562224183583405,7.1562224183583405,0.605472251398711,0.9947043248014121,1
|
10 |
+
Qwen/Qwen2-7B-Instruct,1.04,0.7484375637974869,0.4390136558190875,14.958631815014014,0.1495863181501401,0.4138111632957468,0.0,0.1853486319505737,0.1853486319505737,0.742515336500048,0.999117387466902,0
|
11 |
+
Qwen/Qwen2-7B-Instruct,1.06,0.7471612840233287,0.4328321576515084,14.28087386760537,0.1428087386760537,0.4069074178015074,0.0,0.2030008826125331,0.2030008826125331,0.7406965407448669,0.9982347749338041,0
|
12 |
+
Qwen/Qwen2-7B-Instruct,1.08,0.74519401609845,0.423560805217557,13.659683698817108,0.1365968369881711,0.3966315425573522,0.0,0.22153574580759047,0.22153574580759047,0.7381694832783203,1.0,0
|
13 |
+
Qwen/Qwen2-7B-Instruct,1.10,0.7432071187016402,0.4135053136541433,12.922649874705083,0.1292264987470507,0.3876193185383525,0.0,0.17740511915269197,0.17740511915269197,0.737574218462684,1.0,0
|
14 |
internlm/internlm2_5-7b-chat,1.00,0.739699612254078,0.4289996929258777,14.734881589173108,0.1473488158917311,0.4096466800937898,0.0,12.751103265666373,12.751103265666373,0.5450982095784719,1.0,2
|
15 |
+
internlm/internlm2_5-7b-chat,1.02,0.740223803961056,0.4266246904302194,14.583816688798017,0.1458381668879802,0.4071727106228415,0.0,9.824360105913504,9.824360105913504,0.5706323412193933,1.0,1
|
16 |
+
internlm/internlm2_5-7b-chat,1.04,0.7398856264610577,0.4154585167056314,13.534659133050225,0.1353465913305021,0.3968657713589718,0.0,6.527802294792586,6.527802294792586,0.6073521998554903,1.0,1
|
17 |
+
internlm/internlm2_5-7b-chat,1.06,0.7379362287241489,0.4039588647855378,12.346740971499404,0.1234674097149939,0.3872447044295494,0.0,6.533980582524272,6.533980582524272,0.6056712925221626,0.999117387466902,1
|
18 |
+
internlm/internlm2_5-7b-chat,1.08,0.7319988705684732,0.3873176839854818,11.075674965706344,0.1107567496570634,0.3724352909668609,0.0,9.820829655781113,9.820829655781113,0.5643254582029298,0.999117387466902,1
|
19 |
+
internlm/internlm2_5-7b-chat,1.10,0.7295350462119345,0.3769306874386757,10.305163787094209,0.1030516378709421,0.3634496155759507,0.0,6.525154457193292,6.525154457193292,0.5988898943353679,0.999117387466902,1
|
20 |
+
microsoft/Phi-3.5-mini-instruct,1.00,0.7107840433177544,0.3796831545348129,8.71296896471494,0.0871296896471493,0.3589874395901284,0.0,28.42630185348632,28.42630185348632,0.4485492990665038,1.0,6
|
21 |
+
microsoft/Phi-3.5-mini-instruct,1.02,0.7164765837070485,0.3780585837553919,10.291240080163629,0.1029124008016362,0.3546952732427276,0.0,10.696381288614297,10.696381288614297,0.5444787777612768,1.0,2
|
22 |
+
microsoft/Phi-3.5-mini-instruct,1.04,0.7111233387336411,0.3547161333845742,8.966881655527896,0.0896688165552789,0.3300979657678754,0.0,3.7484554280670785,3.7484554280670785,0.6247493045810047,1.0,1
|
23 |
+
microsoft/Phi-3.5-mini-instruct,1.06,0.7024363270136286,0.3298733737040869,7.076233088011138,0.0707623308801113,0.3019513312669543,0.0,0.10767872903795234,0.10767872903795234,0.6991841213752065,1.0,0
|
24 |
+
microsoft/Phi-3.5-mini-instruct,1.08,0.6882111219210848,0.3054541022592767,5.105510599247868,0.0510551059924786,0.2736030007297014,0.0,3.29567519858782,3.29567519858782,0.6124452738619192,1.0,1
|
25 |
+
microsoft/Phi-3.5-mini-instruct,1.10,0.6712992989638161,0.2903831801547132,4.091958857999118,0.0409195885799911,0.251653275009876,0.0,0.07766990291262135,0.07766990291262135,0.6690512007506374,1.0,0
|
26 |
+
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.00,0.7501818982248062,0.4611110508507017,17.87914973742753,0.1787914973742752,0.4340662057009564,0.0,0.088261253309797,0.088261253309797,0.747329847981863,1.0,0
|
27 |
+
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.02,0.7485114382045625,0.4571517219079576,17.436884594979905,0.174368845949799,0.4311385932640979,0.0,0.09267431597528684,0.09267431597528684,0.7455246732136059,1.0,0
|
28 |
+
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.04,0.7500591586357918,0.4560467960364254,17.440173470996626,0.1744017347099662,0.4302844557731285,0.0,0.13062665489849956,0.13062665489849956,0.7458552866168927,1.0,0
|
29 |
+
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.06,0.748812871571673,0.4520416361219855,16.89523258317781,0.168952325831778,0.4260026774745837,0.0,0.12533097969991175,0.12533097969991175,0.7447841638756355,1.0,0
|
30 |
+
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.08,0.7473851635144647,0.4442106511292453,16.16623784482793,0.1616623784482792,0.4195129470585874,0.0,0.18711385701676964,0.18711385701676964,0.7414159053529263,1.0,0
|
31 |
+
shenzhi-wang/Llama3.1-70B-Chinese-Chat,1.10,0.7465709781131172,0.4379837926138161,15.60172257624066,0.1560172257624066,0.4132562932940978,0.0,0.08649602824360106,0.08649602824360106,0.743788967986371,1.0,0
|
32 |
+
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.00,0.7426396049131678,0.433632501662176,15.209540658023398,0.1520954065802339,0.4089208235151474,0.0,5.798764342453663,5.798764342453663,0.619577239776096,1.0,1
|
33 |
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.02,0.7436477056353469,0.4329054166518245,15.19102241646024,0.1519102241646024,0.4068967964789407,0.0,5.77846425419241,5.77846425419241,0.6207074516423631,1.0,1
|
34 |
+
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.04,0.7440943776351209,0.4320478700956207,15.05135166158296,0.1505135166158296,0.4062008380201262,0.0,0.11827007943512798,0.11827007943512798,0.7403141356055205,1.0,0
|
35 |
+
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.06,0.7426502735395928,0.4275429314912545,14.449130821290163,0.1444913082129016,0.4001409979222783,0.0,0.176522506619594,0.176522506619594,0.7370491441666694,1.0,0
|
36 |
+
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.08,0.7408098006080129,0.4206626658729054,13.933703757385222,0.1393370375738522,0.3964824268676203,0.0,0.21888790820829657,0.21888790820829657,0.7339083936807739,1.0,0
|
37 |
+
shenzhi-wang/Llama3.1-8B-Chinese-Chat,1.10,0.7392685912871718,0.4111211240399151,13.303738403756984,0.1330373840375698,0.3870959581563503,0.0,0.13857016769638128,0.13857016769638128,0.7348764469929082,1.0,0
|
38 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.00,0.7240239171358935,0.4068335357738006,13.565136550617618,0.1356513655061761,0.3866395067055498,0.0,0.1059135039717564,0.1059135039717564,0.7207261791424407,1.0,0
|
39 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.02,0.7263097057327799,0.4064914781094827,13.42987641622816,0.1342987641622816,0.3863697821025159,0.0,6.238305383936452,6.238305383936452,0.5999878425713037,1.0,1
|
40 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.04,0.7276128307708258,0.4054859896994975,13.295092218891954,0.1329509221889195,0.3851203729935697,0.0,0.1297440423654016,0.1297440423654016,0.7235619893938705,1.0,0
|
41 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.06,0.7276865132383193,0.4014727027723293,13.10860799057166,0.1310860799057166,0.3804952786306688,0.0,0.20741394527802295,0.20741394527802295,0.7212559915451495,1.0,0
|
42 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.08,0.726393195584298,0.3987018836449559,12.850537785783194,0.1285053778578319,0.3788945955746495,0.0,0.2903795233892321,0.2903795233892321,0.717473994791502,1.0,0
|
43 |
+
shenzhi-wang/Mistral-7B-v0.3-Chinese-Chat,1.10,0.7244012304511832,0.3932239948456176,12.361161644811926,0.1236116164481192,0.3733413807007665,0.0,0.1500441306266549,0.1500441306266549,0.7197459635880831,1.0,0
|
scripts/eval-h100.sh
CHANGED
@@ -57,14 +57,15 @@ export RESULTS_PATH=results/mac-results_rpp_with_mnt_2048_generic_prompt.csv
|
|
57 |
export BATCH_SIZE=1
|
58 |
export LOAD_IN_4BIT=true
|
59 |
|
|
|
60 |
./scripts/eval-rpp.sh Qwen Qwen2-72B-Instruct checkpoint-105
|
61 |
|
62 |
|
63 |
-
export BATCH_SIZE=4
|
64 |
-
export LOAD_IN_4BIT=false
|
65 |
|
66 |
-
./scripts/eval-rpp.sh shenzhi-wang Mistral-7B-v0.3-Chinese-Chat checkpoint-70
|
67 |
|
68 |
-
./scripts/eval-rpp.sh shenzhi-wang Llama3.1-8B-Chinese-Chat checkpoint-105
|
69 |
|
70 |
-
./scripts/eval-rpp.sh microsoft Phi-3.5-mini-instruct checkpoint-210
|
|
|
57 |
export BATCH_SIZE=1
|
58 |
export LOAD_IN_4BIT=true
|
59 |
|
60 |
+
export START_REPETITION_PENALTY=1.02
|
61 |
./scripts/eval-rpp.sh Qwen Qwen2-72B-Instruct checkpoint-105
|
62 |
|
63 |
|
64 |
+
# export BATCH_SIZE=4
|
65 |
+
# export LOAD_IN_4BIT=false
|
66 |
|
67 |
+
# ./scripts/eval-rpp.sh shenzhi-wang Mistral-7B-v0.3-Chinese-Chat checkpoint-70
|
68 |
|
69 |
+
# ./scripts/eval-rpp.sh shenzhi-wang Llama3.1-8B-Chinese-Chat checkpoint-105
|
70 |
|
71 |
+
# ./scripts/eval-rpp.sh microsoft Phi-3.5-mini-instruct checkpoint-210
|
scripts/eval-mac.sh
CHANGED
@@ -54,10 +54,10 @@ export RESULTS_PATH=results/mac-results_rpp_with_mnt_2048_generic_prompt.csv
|
|
54 |
|
55 |
#./scripts/eval-rpp.sh Qwen Qwen2-7B-Instruct checkpoint-105
|
56 |
|
57 |
-
|
58 |
|
59 |
-
./scripts/eval-rpp.sh
|
60 |
|
|
|
61 |
./scripts/eval-rpp.sh shenzhi-wang Llama3.1-8B-Chinese-Chat checkpoint-105
|
62 |
|
63 |
-
./scripts/eval-rpp.sh microsoft Phi-3.5-mini-instruct checkpoint-210
|
|
|
54 |
|
55 |
#./scripts/eval-rpp.sh Qwen Qwen2-7B-Instruct checkpoint-105
|
56 |
|
57 |
+
# ./scripts/eval-rpp.sh shenzhi-wang Mistral-7B-v0.3-Chinese-Chat checkpoint-70
|
58 |
|
59 |
+
# ./scripts/eval-rpp.sh microsoft Phi-3.5-mini-instruct checkpoint-210
|
60 |
|
61 |
+
export BATCH_SIZE=1
|
62 |
./scripts/eval-rpp.sh shenzhi-wang Llama3.1-8B-Chinese-Chat checkpoint-105
|
63 |
|
|