-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.5.1: Minor bugfixes and improvements. (#48)
* Improve regex efficiency. * Fix edge case for srt subtitle. * Add LLM-based translation quality evaluator. * Fix issue always causing false format-checking for context generation. * Update noise suppression test-suites. * Bump up to version 1.5.1
- Loading branch information
Showing
14 changed files
with
224 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright (C) 2024. Hao Zheng | ||
# All rights reserved. | ||
import abc | ||
|
||
from openlrc.agents import TranslationEvaluatorAgent | ||
from openlrc.logger import logger | ||
|
||
|
||
class TranslationEvaluator(abc.ABC): | ||
""" | ||
Base class for all evaluators. | ||
""" | ||
|
||
@abc.abstractmethod | ||
def evaluate(self, src_texts, target_texts, src_lang, target_lang): | ||
""" | ||
Evaluate the translated texts. | ||
:return: The evaluation result. | ||
""" | ||
raise NotImplementedError() | ||
|
||
|
||
class LLMTranslationEvaluator(TranslationEvaluator): | ||
""" | ||
Evaluate the translated texts using large language models. | ||
""" | ||
|
||
def __init__(self, chatbot_model: str = 'gpt-3.5-turbo'): | ||
self.agenet = TranslationEvaluatorAgent(chatbot_model=chatbot_model) | ||
self.recommended_model = { | ||
'gpt-4', | ||
'claude-3-sonnet', | ||
'claude-3-opus', | ||
'gemini-1.5-pro' | ||
} | ||
|
||
for m in self.recommended_model: | ||
if chatbot_model.startswith(m): | ||
self.agenet = TranslationEvaluatorAgent(chatbot_model=chatbot_model) | ||
break | ||
else: | ||
logger.warning(f'Chatbot model {chatbot_model} is not in the recommended list for evaluating translations.') | ||
|
||
def evaluate(self, src_texts, target_texts, src_lang=None, target_lang=None): | ||
return self.agenet.evaluate(src_texts, target_texts) | ||
|
||
|
||
class EmbeddingTranslationEvaluator(TranslationEvaluator): | ||
""" | ||
Evaluate the translated texts using embeddings. | ||
""" | ||
|
||
def evaluate(self, src_texts, target_texts, src_lang, target_lang): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.