metricv commited on
Commit
502b5eb
·
1 Parent(s): 767dc8f

Use UTF-8 for ChatGPT encoding

Browse files
chatgpt-test-8192.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:00e4d4fa140de6063c5e50e09650ea97c03b7bc4dbdbbac4b7936ea156ab2e08
3
- size 206716
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc5154242c5b2f0cee22b6c51f616872caf841484d4d065803ac81bf1144ce98
3
+ size 228619
chatgpt-train-8192.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2823ecd0037645295e54ab13ee67e5c69ac313bad291bfdbb5cc34a479c20be9
3
- size 959800
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3112bcdb43fa7ba4ec8c7cd43e0be6d02bc1bfef6d5925c440bc85b3ab6e2966
3
+ size 937891
combined-8192.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:44fa5866835ba87097521e8102fd215f6f711dc63045550056829ba859281ae6
3
- size 1166513
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eff7831baad2e2d1876bcedca85954c5f5a66cdd3772c3509f2c8b93efe52478
3
+ size 1166510
generate_chatgpt_varlen.py CHANGED
@@ -80,7 +80,7 @@ def new_message(eng_in, chs_out, prev_in = None, prev_out = None):
80
 
81
  def write_jsonl(message_groups, filename):
82
  json_lines = []
83
- with open(filename, "w", encoding='utf-8-sig') as fout:
84
  for i in range(len(message_groups)):
85
  if(i>0):
86
  msg_obj = new_message(
@@ -165,11 +165,11 @@ if __name__ == "__main__":
165
  test = jsonl_lines[:split_index]
166
  train = jsonl_lines[split_index:]
167
 
168
- with open (f"chatgpt-train-{args.maxlen}.jsonl", "w", encoding='utf-8-sig') as fout:
169
  for line in train:
170
  fout.write(line + "\n")
171
 
172
- with open (f"chatgpt-test-{args.maxlen}.jsonl", "w", encoding='utf-8-sig') as fout:
173
  for line in test:
174
  fout.write(line + "\n")
175
 
 
80
 
81
  def write_jsonl(message_groups, filename):
82
  json_lines = []
83
+ with open(filename, "w", encoding='utf-8') as fout:
84
  for i in range(len(message_groups)):
85
  if(i>0):
86
  msg_obj = new_message(
 
165
  test = jsonl_lines[:split_index]
166
  train = jsonl_lines[split_index:]
167
 
168
+ with open (f"chatgpt-train-{args.maxlen}.jsonl", "w", encoding='utf-8') as fout:
169
  for line in train:
170
  fout.write(line + "\n")
171
 
172
+ with open (f"chatgpt-test-{args.maxlen}.jsonl", "w", encoding='utf-8') as fout:
173
  for line in test:
174
  fout.write(line + "\n")
175
 
train_chatgpt.ipynb ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 13,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import openai\n",
10
+ "from openai import OpenAI\n",
11
+ "import os"
12
+ ]
13
+ },
14
+ {
15
+ "cell_type": "code",
16
+ "execution_count": 20,
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "client = OpenAI(api_key=None)"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "code",
25
+ "execution_count": 21,
26
+ "metadata": {},
27
+ "outputs": [],
28
+ "source": [
29
+ "BASE_MODEL = \"gpt-4o-2024-08-06\"\n",
30
+ "\n",
31
+ "INPUT_TRAIN = \"chatgpt-train-8192.jsonl\"\n",
32
+ "INPUT_TEST = \"chatgpt-test-8192.jsonl\"\n",
33
+ "\n",
34
+ "assert os.path.isfile(INPUT_TEST)\n",
35
+ "assert os.path.isfile(INPUT_TRAIN)"
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": 22,
41
+ "metadata": {},
42
+ "outputs": [],
43
+ "source": [
44
+ "train_file = client.files.create(\n",
45
+ " file=open(INPUT_TRAIN, \"rb\"),\n",
46
+ " purpose=\"fine-tune\"\n",
47
+ ")\n",
48
+ "\n",
49
+ "test_file = client.files.create(\n",
50
+ " file=open(INPUT_TEST, \"rb\"),\n",
51
+ " purpose=\"fine-tune\"\n",
52
+ ")"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": 23,
58
+ "metadata": {},
59
+ "outputs": [
60
+ {
61
+ "data": {
62
+ "text/plain": [
63
+ "FineTuningJob(id='ftjob-gmBbrQUbH7ebPO9eapimGI0T', created_at=1728612535, error=Error(code=None, message=None, param=None), fine_tuned_model=None, finished_at=None, hyperparameters=Hyperparameters(n_epochs='auto', batch_size='auto', learning_rate_multiplier='auto'), model='gpt-4o-2024-08-06', object='fine_tuning.job', organization_id='org-uw3iag65cO1uuHFelRfNqH99', result_files=[], seed=2060928557, status='validating_files', trained_tokens=None, training_file='file-BO3hthNeSTuawThRSDeDUTxh', validation_file='file-4C0xDKTAfiL8EqqMIMfYQLde', estimated_finish=None, integrations=[], user_provided_suffix=None)"
64
+ ]
65
+ },
66
+ "execution_count": 23,
67
+ "metadata": {},
68
+ "output_type": "execute_result"
69
+ }
70
+ ],
71
+ "source": [
72
+ "client.fine_tuning.jobs.create(\n",
73
+ " training_file=train_file.id,\n",
74
+ " validation_file=test_file.id,\n",
75
+ " model=BASE_MODEL\n",
76
+ ")"
77
+ ]
78
+ },
79
+ {
80
+ "cell_type": "code",
81
+ "execution_count": null,
82
+ "metadata": {},
83
+ "outputs": [],
84
+ "source": []
85
+ }
86
+ ],
87
+ "metadata": {
88
+ "kernelspec": {
89
+ "display_name": "metricsubs-chunktranslate",
90
+ "language": "python",
91
+ "name": "python3"
92
+ },
93
+ "language_info": {
94
+ "codemirror_mode": {
95
+ "name": "ipython",
96
+ "version": 3
97
+ },
98
+ "file_extension": ".py",
99
+ "mimetype": "text/x-python",
100
+ "name": "python",
101
+ "nbconvert_exporter": "python",
102
+ "pygments_lexer": "ipython3",
103
+ "version": "3.12.0"
104
+ }
105
+ },
106
+ "nbformat": 4,
107
+ "nbformat_minor": 2
108
+ }