Remove unnecessary files
Browse files- etlex-utf8.csv +0 -3
- etlex_convert_to_qwen2_finetune.py +0 -128
- lexitron2_etlex_finetune.qwen2.txt +0 -3
- lexitron2_telex_finetune.qwen2.txt +0 -3
- telex-utf8.csv +0 -3
- telex_convert_to_qwen2_finetune.py +0 -128
etlex-utf8.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:1fc84e257a5d44db9b821731f41cc28da8d41054bf96445db7cdf10622cd08ac
|
| 3 |
-
size 9599159
|
|
|
|
|
|
|
|
|
|
|
|
etlex_convert_to_qwen2_finetune.py
DELETED
|
@@ -1,128 +0,0 @@
|
|
| 1 |
-
import csv
|
| 2 |
-
import random
|
| 3 |
-
import json
|
| 4 |
-
|
| 5 |
-
def create_training_data():
|
| 6 |
-
training_data = []
|
| 7 |
-
|
| 8 |
-
# Read CSV file
|
| 9 |
-
with open('etlex-utf8.csv', 'r', encoding='utf-8') as f:
|
| 10 |
-
reader = csv.reader(f)
|
| 11 |
-
word_data = list(reader)
|
| 12 |
-
|
| 13 |
-
for row in word_data:
|
| 14 |
-
if len(row) < 7: # Skip incomplete rows
|
| 15 |
-
continue
|
| 16 |
-
|
| 17 |
-
english_word = row[1]
|
| 18 |
-
thai_word = row[3]
|
| 19 |
-
category = row[4]
|
| 20 |
-
thai_syn = row[5]
|
| 21 |
-
eng_syn = row[6]
|
| 22 |
-
eng_ant = row[7]
|
| 23 |
-
|
| 24 |
-
if not english_word: # Skip entries without English word
|
| 25 |
-
continue
|
| 26 |
-
|
| 27 |
-
# Create different types of prompts
|
| 28 |
-
prompt_types = [
|
| 29 |
-
f"What is the Thai translation of '{english_word}'?",
|
| 30 |
-
f"How do you say '{english_word}' in Thai?",
|
| 31 |
-
f"Can you translate '{english_word}' to Thai?",
|
| 32 |
-
f"What does '{english_word}' mean in Thai?",
|
| 33 |
-
f"Give me the Thai equivalent of '{english_word}'",
|
| 34 |
-
f"Please translate '{english_word}' into Thai",
|
| 35 |
-
f"What's the Thai word for '{english_word}'?",
|
| 36 |
-
f"I need the Thai translation for '{english_word}'",
|
| 37 |
-
f"How would you translate '{english_word}' to Thai?",
|
| 38 |
-
f"Could you tell me what '{english_word}' is in Thai?",
|
| 39 |
-
f"What is '{english_word}' in Thai language?",
|
| 40 |
-
f"Translate '{english_word}' from English to Thai",
|
| 41 |
-
f"Can you explain the meaning of '{english_word}' in Thai?",
|
| 42 |
-
f"I want to know how to say '{english_word}' in Thai",
|
| 43 |
-
f"Please provide the Thai translation and usage of '{english_word}'",
|
| 44 |
-
f"What's the Thai meaning of '{english_word}'?",
|
| 45 |
-
f"How is '{english_word}' expressed in Thai?",
|
| 46 |
-
f"Give me the Thai definition of '{english_word}'",
|
| 47 |
-
f"I'd like to know the Thai equivalent of '{english_word}'",
|
| 48 |
-
f"What's the Thai word and meaning for '{english_word}'?",
|
| 49 |
-
f"คำว่า '{english_word}' แปลว่าอะไร",
|
| 50 |
-
f"'{english_word}' แปลเป็นภาษาไทยว่าอย่างไร",
|
| 51 |
-
f"ช่วยแปลคำว่า '{english_word}' เป็นภาษาไทยหน่อย",
|
| 52 |
-
f"'{english_word}' ภาษาไทยคือคำว่าอะไร",
|
| 53 |
-
f"อยากทราบความหมายภาษาไทยของคำว่า '{english_word}'",
|
| 54 |
-
f"ขอคำแปลภาษาไทยของ '{english_word}'",
|
| 55 |
-
f"'{english_word}' มีความหมายในภาษาไทยว่าอย่างไร",
|
| 56 |
-
f"ช่วยบอกความหมายภาษาไทยของ '{english_word}' หน่อย",
|
| 57 |
-
f"'{english_word}' ในภาษาไทยแปลว่าอะไร",
|
| 58 |
-
f"ขอความหมายภาษาไทยของคำว่า '{english_word}'"
|
| 59 |
-
]
|
| 60 |
-
|
| 61 |
-
# Randomly select prompt type
|
| 62 |
-
prompt = random.choice(prompt_types)
|
| 63 |
-
|
| 64 |
-
# Convert category abbreviation to full name
|
| 65 |
-
category_mapping = {
|
| 66 |
-
'N': 'Noun',
|
| 67 |
-
'V': 'Verb',
|
| 68 |
-
'VT': 'Transitive Verb',
|
| 69 |
-
'VI': 'Intransitive Verb',
|
| 70 |
-
'ADJ': 'Adjective',
|
| 71 |
-
'ADV': 'Adverb',
|
| 72 |
-
'PREP': 'Preposition',
|
| 73 |
-
'CONJ': 'Conjunction',
|
| 74 |
-
'CLAS': 'Classifier',
|
| 75 |
-
'PRON': 'Pronoun',
|
| 76 |
-
'DET': 'Determiner',
|
| 77 |
-
'ABBR': 'Abbreviation'
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
# Map the abbreviated category to full name, default to original if not found
|
| 81 |
-
category = category_mapping.get(category, category)
|
| 82 |
-
|
| 83 |
-
# Create response based on available information
|
| 84 |
-
response = f"คำว่า '{english_word}' เป็นคำประเภท {category}"
|
| 85 |
-
|
| 86 |
-
if thai_word:
|
| 87 |
-
response += f" แปลเป็นภาษาไทยว่า '{thai_word}'"
|
| 88 |
-
|
| 89 |
-
if thai_syn:
|
| 90 |
-
response += f"\nคำที่มีความหมายเหมือนกันในภาษาไทย: {thai_syn}"
|
| 91 |
-
|
| 92 |
-
if eng_ant:
|
| 93 |
-
response += f"\nคำที่มีความหมายตรงข้ามในภาษาอังกฤษ: {eng_ant}"
|
| 94 |
-
|
| 95 |
-
if eng_syn:
|
| 96 |
-
response += f"\nคำที่มีความหมายเหมือนกันในภาษาอังกฤษ: {eng_syn}"
|
| 97 |
-
|
| 98 |
-
# Create data in both formats
|
| 99 |
-
# Format 1: Qwen2 conversation format
|
| 100 |
-
conversation = (
|
| 101 |
-
"<|im_start|>system\n"
|
| 102 |
-
"คุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์.<|im_end|>\n"
|
| 103 |
-
f"<|im_start|>user\n{prompt}<|im_end|>\n"
|
| 104 |
-
f"<|im_start|>assistant\n{response}<|im_end|>"
|
| 105 |
-
)
|
| 106 |
-
|
| 107 |
-
# Format 2: JSONL format
|
| 108 |
-
json_data = {
|
| 109 |
-
"instruction": prompt,
|
| 110 |
-
"output": response
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
training_data.append((conversation, json_data))
|
| 114 |
-
|
| 115 |
-
return training_data
|
| 116 |
-
|
| 117 |
-
# Generate training data
|
| 118 |
-
training_examples = create_training_data()
|
| 119 |
-
|
| 120 |
-
# Write to output files
|
| 121 |
-
with open('lexitron2_etlex_finetune.qwen2.txt', 'w', encoding='utf-8') as f:
|
| 122 |
-
for example, _ in training_examples:
|
| 123 |
-
example = example.replace('\n', '\\n')
|
| 124 |
-
f.write(example + '\n')
|
| 125 |
-
|
| 126 |
-
with open('lexitron2_etlex_finetune.jsonl', 'w', encoding='utf-8') as f:
|
| 127 |
-
for _, json_data in training_examples:
|
| 128 |
-
f.write(json.dumps(json_data, ensure_ascii=False) + '\n')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lexitron2_etlex_finetune.qwen2.txt
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b39446598adc66ab0fb90af377c8f1949f90531e235965d604df416178537ff6
|
| 3 |
-
size 49092774
|
|
|
|
|
|
|
|
|
|
|
|
lexitron2_telex_finetune.qwen2.txt
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:3415788521911fe59e56f6ad49e64c44010964b0a3e1da8914df4d62a8c19a76
|
| 3 |
-
size 38678047
|
|
|
|
|
|
|
|
|
|
|
|
telex-utf8.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:54e4ae3f5befc2fb0c18ea84f4b6152def64391818fea0dc90df829964b2f38a
|
| 3 |
-
size 14559356
|
|
|
|
|
|
|
|
|
|
|
|
telex_convert_to_qwen2_finetune.py
DELETED
|
@@ -1,128 +0,0 @@
|
|
| 1 |
-
import csv
|
| 2 |
-
import random
|
| 3 |
-
import json
|
| 4 |
-
|
| 5 |
-
def create_training_data():
|
| 6 |
-
training_data = []
|
| 7 |
-
|
| 8 |
-
# Read CSV file
|
| 9 |
-
with open('telex-utf8.csv', 'r', encoding='utf-8') as f:
|
| 10 |
-
reader = csv.reader(f)
|
| 11 |
-
word_data = list(reader)
|
| 12 |
-
|
| 13 |
-
for row in word_data:
|
| 14 |
-
if len(row) < 11: # Skip incomplete rows
|
| 15 |
-
continue
|
| 16 |
-
|
| 17 |
-
thai_word = row[1]
|
| 18 |
-
english_syn = row[3]
|
| 19 |
-
category = row[4]
|
| 20 |
-
thai_syn = row[5]
|
| 21 |
-
example = row[6]
|
| 22 |
-
antonym = row[7]
|
| 23 |
-
definition = row[8]
|
| 24 |
-
related_eng = row[9]
|
| 25 |
-
unit_label = row[10]
|
| 26 |
-
|
| 27 |
-
if not thai_word: # Skip entries without Thai word
|
| 28 |
-
continue
|
| 29 |
-
|
| 30 |
-
# Create different types of prompts
|
| 31 |
-
prompt_types = [
|
| 32 |
-
f"คำว่า '{thai_word}' แปลว่าอะไร",
|
| 33 |
-
f"ช่วยอธิบายความหมายของคำว่า '{thai_word}'",
|
| 34 |
-
f"'{thai_word}' มีความหมายว่าอย่างไร",
|
| 35 |
-
f"ขอตัวอย่างประโยคของคำว่า '{thai_word}'",
|
| 36 |
-
f"ยกตัวอย่างการใช้คำว่า '{thai_word}'",
|
| 37 |
-
f"ช่วยอธิบายคำว่า '{thai_word}' หน่อย",
|
| 38 |
-
f"'{thai_word}' หมายถึงอะไร",
|
| 39 |
-
f"อยากทราบความหมายของคำว่า '{thai_word}'",
|
| 40 |
-
f"คำว่า '{thai_word}' ใช้ในบริบทไหนได้บ้าง",
|
| 41 |
-
f"ขอความหมายของคำว่า '{thai_word}'",
|
| 42 |
-
f"'{thai_word}' คืออะไร",
|
| 43 |
-
f"ช่วยยกตัวอย่างการใช้คำว่า '{thai_word}' ในประโยค",
|
| 44 |
-
f"คำว่า '{thai_word}' สามารถใช้ในประโยคอย่างไรได้บ้าง",
|
| 45 |
-
f"อยากรู้ว่าคำว่า '{thai_word}' ใช้ในประโยคยังไง",
|
| 46 |
-
f"ขอทราบความหมายและตัวอย่างการใช้คำว่า '{thai_word}'",
|
| 47 |
-
f"ช่วยอธิบายความหมายและยกตัวอย่างการใช้คำว่า '{thai_word}'",
|
| 48 |
-
f"'{thai_word}' มีวิธีใช้อย่างไร",
|
| 49 |
-
f"คำว่า '{thai_word}' มีความหมายและใช้อย่างไร",
|
| 50 |
-
f"อยากทราบรายละเอียดเกี่ยวกับคำว่า '{thai_word}'",
|
| 51 |
-
f"ขอคำอธิบายและตัวอย่างการใช้คำว่า '{thai_word}'"
|
| 52 |
-
]
|
| 53 |
-
|
| 54 |
-
# Randomly select prompt type
|
| 55 |
-
prompt = random.choice(prompt_types)
|
| 56 |
-
# Convert category abbreviation to full name
|
| 57 |
-
category_mapping = {
|
| 58 |
-
'N': 'Noun (คำนาม)',
|
| 59 |
-
'V': 'Verb (คำกริยา)',
|
| 60 |
-
'VT': 'Transitive Verb (คำกริยาที่ต้องการกรรม)',
|
| 61 |
-
'VI': 'Intransitive Verb (คำกริยาไม่ต้องการกรรม)',
|
| 62 |
-
'ADJ': 'Adjective (คำคุณศัพท์)',
|
| 63 |
-
'ADV': 'Adverb (คำวิเศษณ์)',
|
| 64 |
-
'PREP': 'Preposition (คำบุพบท)',
|
| 65 |
-
'CONJ': 'Conjunction (คำสันธาน)',
|
| 66 |
-
'CLAS': 'Classifier (คำลักษณนาม)',
|
| 67 |
-
'PRON': 'Pronoun (คำสรรพนาม)',
|
| 68 |
-
'DET': 'Determiner (คำกำหนด)',
|
| 69 |
-
'ABBR': 'Abbreviation (คำย่อ)'
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
# Map the abbreviated category to full name, default to original if not found
|
| 73 |
-
category = category_mapping.get(category, category)
|
| 74 |
-
# Create response based on available information
|
| 75 |
-
response = f"คำว่า '{thai_word}' เป็นคำประเภท {category}"
|
| 76 |
-
|
| 77 |
-
if english_syn:
|
| 78 |
-
response += f" แปลเป็นภาษาอังกฤษว่า {english_syn}"
|
| 79 |
-
|
| 80 |
-
if definition:
|
| 81 |
-
response += f"\nความหมาย: {definition}"
|
| 82 |
-
|
| 83 |
-
if thai_syn:
|
| 84 |
-
response += f"\nคำที่มีความหมายเหมือนกัน: {thai_syn}"
|
| 85 |
-
|
| 86 |
-
if antonym:
|
| 87 |
-
response += f"\nคำที่มีความหมายตรงข้าม: {antonym}"
|
| 88 |
-
|
| 89 |
-
if example:
|
| 90 |
-
response += f"\nตัวอย่างประโยค: {example}"
|
| 91 |
-
|
| 92 |
-
if unit_label:
|
| 93 |
-
response += f"\nลักษณนาม: {unit_label}"
|
| 94 |
-
|
| 95 |
-
if related_eng:
|
| 96 |
-
response += f"\nคำภาษาอังกฤษที่เกี่ยวข้อง: {related_eng}"
|
| 97 |
-
|
| 98 |
-
# Create data in both formats
|
| 99 |
-
# Format 1: Qwen2 conversation format
|
| 100 |
-
conversation = (
|
| 101 |
-
"<|im_start|>system\n"
|
| 102 |
-
"คุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n"
|
| 103 |
-
f"<|im_start|>user\n{prompt}<|im_end|>\n"
|
| 104 |
-
f"<|im_start|>assistant\n{response}<|im_end|>"
|
| 105 |
-
)
|
| 106 |
-
|
| 107 |
-
# Format 2: JSONL format
|
| 108 |
-
json_data = {
|
| 109 |
-
"instruction": prompt,
|
| 110 |
-
"output": response
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
training_data.append((conversation, json_data))
|
| 114 |
-
|
| 115 |
-
return training_data
|
| 116 |
-
|
| 117 |
-
# Generate training data
|
| 118 |
-
training_examples = create_training_data()
|
| 119 |
-
|
| 120 |
-
# Write to output files
|
| 121 |
-
with open('lexitron2_telex_finetune.qwen2.txt', 'w', encoding='utf-8') as f:
|
| 122 |
-
for example, _ in training_examples:
|
| 123 |
-
example = example.replace('\n', '\\n')
|
| 124 |
-
f.write(example + '\n')
|
| 125 |
-
|
| 126 |
-
with open('lexitron2_telex_finetune.jsonl', 'w', encoding='utf-8') as f:
|
| 127 |
-
for _, json_data in training_examples:
|
| 128 |
-
f.write(json.dumps(json_data, ensure_ascii=False) + '\n')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|