ragas
ragas copied to clipboard
Can this part of the code be applied to Chinese scenarios
[ ] I checked the documentation and related resources and couldn't find an answer to my question.
Your Question Can this part of the code be applied to Chinese scenarios? I see there are many places in the code that enforce English directly.
- such as, the below part1,
sentence for sentence in sentences if sentence.strip().endswith(".") - the below part2,
language="english",
Code Examples
# code in _faithfulness.py
@dataclass
class Faithfulness(MetricWithLLM):
...
def _create_statements_prompt(self, row: t.Dict) -> PromptValue:
assert self.sentence_segmenter is not None, "sentence_segmenter is not set"
text, question = row["answer"], row["question"]
sentences = self.sentence_segmenter.segment(text)
sentences = [
sentence for sentence in sentences if sentence.strip().endswith(".")
]
sentences = "\n".join([f"{i}:{x}" for i, x in enumerate(sentences)])
prompt_value = self.statement_prompt.format(
question=question, answer=text, sentences=sentences
)
return prompt_value
Code Examples
LONG_FORM_ANSWER_PROMPT = Prompt(
name="long_form_answer",
output_format_instruction=_statements_output_instructions,
instruction="Given a question, an answer, and sentences from the answer analyze the complexity of each sentence given under 'sentences' and break down each sentence into one or more fully understandable statements while also ensuring no pronouns are used in each statement. Format the outputs in JSON.",
examples=[
{
"question": "Who was Albert Einstein and what is he best known for?",
"answer": "He was a German-born theoretical physicist, widely acknowledged to be one of the greatest and most influential physicists of all time. He was best known for developing the theory of relativity, he also made important contributions to the development of the theory of quantum mechanics.",
"sentences": """
0:He was a German-born theoretical physicist, widely acknowledged to be one of the greatest and most influential physicists of all time.
1:He was best known for developing the theory of relativity, he also made important contributions to the development of the theory of quantum mechanics.
""",
"analysis": StatementsAnswers.parse_obj(
[
{
"sentence_index": 0,
"simpler_statements": [
"Albert Einstein was a German-born theoretical physicist.",
"Albert Einstein is recognized as one of the greatest and most influential physicists of all time.",
],
},
{
"sentence_index": 1,
"simpler_statements": [
"Albert Einstein was best known for developing the theory of relativity.",
"Albert Einstein also made important contributions to the development of the theory of quantum mechanics.",
],
},
]
).dicts(),
}
],
input_keys=["question", "answer", "sentences"],
output_key="analysis",
language="english",
)