Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
10zinten committed Dec 28, 2024
1 parent 5a70a9c commit 2387c72
Show file tree
Hide file tree
Showing 9 changed files with 18,339 additions and 10,112 deletions.
2 changes: 1 addition & 1 deletion analyse_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ def export_to_csv(label):


if __name__ == "__main__":
label = "target_gt"
label = "04_commentary_assisted"
export_to_csv(label)
15 changes: 9 additions & 6 deletions experiments/04_commentary_assisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ def load_commentaries():
def generate_prompt(tibetan_text, text_id):
text_commentaries = commentaries[text_id]
return f"""
Translate the Input Buddhist Tibetan text into English using the Tibetan Commentaries provided.
In order to translate the Input Buddhist Tibetan text into English using Tibetan commentaries, do the following:
1. Translate and summarize each commentary
2. Combine the meaning of the commentaries
3. Translate the Input text in accordance to the combine meaning of the commentaries.
## Core Instructions
- Enclose final English translation in <t> tags
Core Instructions
Enclose final English translation in <t> tags
Input:
{tibetan_text}
Input: {tibetan_text}
Commentary 1: {text_commentaries[0]}
Expand All @@ -42,6 +44,7 @@ def generate_prompt(tibetan_text, text_id):
if __name__ == "__main__":
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("--test", action="store_true")
arg_parser.add_argument("--replace", action="store_true")
args = arg_parser.parse_args()

exp_name = Path(__file__).stem
Expand All @@ -52,4 +55,4 @@ def generate_prompt(tibetan_text, text_id):
claud_sonet_chat,
generate_prompt,
)
exp.run_experiment(test=args.test)
exp.run_experiment(replace=args.replace, test=args.test)
4 changes: 2 additions & 2 deletions experiments/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def is_translated(self, text_id):
and self.exp_name in results[text_id]["target_pred"]
)

def run_experiment(self, test=False):
def run_experiment(self, replace=False, test=False):
for text_id, source_text in self.get_source_texts():
if self.is_translated(text_id):
if not replace and self.is_translated(text_id):
continue
prompt = self.prompt_generator(source_text, text_id)
response = self.llm(prompt)
Expand Down
Loading

0 comments on commit 2387c72

Please sign in to comment.