Skip to content

Tibetan Translator Comparison

TenzinGayche edited this page Dec 17, 2025 · 1 revision

Tibetan Translator: V1 vs V2 Comparison

This page documents the key differences between tibetan_translator (v1) and tibetan_translator_v2.


πŸ“Š Summary Table

Aspect tibetan_translator (v1) tibetan_translator_v2
Input Processing 3 Commentary Translators UCCA + Word-by-Word + Summary
Input Source Raw Tibetan commentaries Pre-processed semantic data
Philosophy Commentary-driven translation Semantic-analysis-driven translation
Dependencies Standalone Depends on ucca_generator, word_by_word_generator
Extra Files Has llm_provider.py Missing llm_provider.py
Best Use Case Traditional scholarly texts with commentaries Detailed linguistic analysis needed

πŸ”„ Workflow Differences

V1: Commentary-Based Workflow

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚           START             β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                   β”‚                   β”‚
              β–Ό                   β–Ό                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ commentary_         β”‚ β”‚ commentary_         β”‚ β”‚ commentary_         β”‚
β”‚ translator_1        β”‚ β”‚ translator_2        β”‚ β”‚ translator_3        β”‚
β”‚                     β”‚ β”‚                     β”‚ β”‚                     β”‚
β”‚ Translates          β”‚ β”‚ Translates          β”‚ β”‚ Translates          β”‚
β”‚ Commentary 1        β”‚ β”‚ Commentary 2        β”‚ β”‚ Commentary 3        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                       β”‚                       β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                                  β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚         aggregator          β”‚
                    β”‚                             β”‚
                    β”‚ Combines translated         β”‚
                    β”‚ commentaries using LLM      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                                  β–Ό
                         (continues to translation)

V2: Semantic-Analysis Workflow

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚           START             β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                   β”‚                   β”‚
              β–Ό                   β–Ό                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    process_ucca     β”‚ β”‚ process_word_by_    β”‚ β”‚ process_multilevel_ β”‚
β”‚                     β”‚ β”‚       word          β”‚ β”‚      summary        β”‚
β”‚ Loads UCCA graph    β”‚ β”‚                     β”‚ β”‚                     β”‚
β”‚ analysis from state β”‚ β”‚ Loads word-by-word  β”‚ β”‚ Loads multi-level   β”‚
β”‚                     β”‚ β”‚ translation         β”‚ β”‚ summary             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                       β”‚                       β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                                  β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚         aggregator          β”‚
                    β”‚                             β”‚
                    β”‚ Combines UCCA + word-by-    β”‚
                    β”‚ word + summary using LLM    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                                  β–Ό
                         (continues to translation)

πŸ“¦ Input Processing Functions

V1: Commentary Translators

# From tibetan_translator/processors/commentary.py

def commentary_translator_1(state: State):
    """Translate first commentary with expertise focus."""
    if not state['commentary1']:
        return {"commentary1": None, "commentary1_translation": None}
    
    prompt = get_commentary_translation_prompt(
        state['sanskrit'], 
        state['source'], 
        state['commentary1'],
        language=state.get('language', 'English')
    )
    return {"commentary1": state['commentary1'], 
            "commentary1_translation": state['commentary1']}

def commentary_translator_2(state: State):
    """Translate second commentary with philosophical focus."""
    # Similar structure...

def commentary_translator_3(state: State):
    """Translate third commentary with traditional focus."""
    # Similar structure...

V2: Semantic Data Loaders

# From tibetan_translator_v2/processors/commentary.py

def process_ucca(state: State):
    """Loads the UCCA data into the state for the aggregator."""
    return {"ucca": state.get("ucca", "")}

def process_word_by_word(state: State):
    """Loads the word-by-word translation into the state for the aggregator."""
    return {"word_by_word": state.get("word_by_word", "")}

def process_multilevel_summary(state: State):
    """Loads the multi-level summary into the state for the aggregator."""
    return {"multilevel_summary": state.get("multilevel_summary", "")}

πŸ”— Aggregator Differences

V1 Aggregator: Combines Commentaries

def aggregator(state: State):
    """Combine commentaries based on availability."""
    
    # Check which commentaries exist
    has_commentary1 = state.get('commentary1_translation') not in [None, "", "None"]
    has_commentary2 = state.get('commentary2_translation') not in [None, "", "None"]
    has_commentary3 = state.get('commentary3_translation') not in [None, "", "None"]
    
    commentary_count = sum([has_commentary1, has_commentary2, has_commentary3])
    
    # If no commentaries, create source analysis
    if commentary_count == 0:
        source_analysis = create_source_analysis(state['source'], ...)
        return {"combined_commentary": source_analysis, "commentary_source": "source_analysis"}
    
    # If one commentary, use it directly
    if commentary_count == 1:
        if has_commentary1:
            return {"combined_commentary": state['commentary1_translation']}
        # ...
    
    # If multiple, combine them
    combined = ""
    if has_commentary1:
        combined += f"Commentary 1:\n{state['commentary1_translation']}\n\n"
    if has_commentary2:
        combined += f"Commentary 2:\n{state['commentary2_translation']}\n\n"
    if has_commentary3:
        combined += f"Commentary 3:\n{state['commentary3_translation']}\n\n"
    
    # Use LLM to create unified commentary
    prompt_messages = get_combined_commentary_prompt(...)
    response = llm_thinking.invoke(prompt_messages)
    
    return {"combined_commentary": commentary_content}

V2 Aggregator: Combines Semantic Analysis

def aggregator(state: State):
    """Combine UCCA, word-by-word, and summary into a new commentary."""
    
    # Combine the new inputs into a single string
    combined_inputs = (
        f"UCCA Analysis:\n{state.get('ucca', 'Not available.')}\n\n"
        f"Word-by-Word Translation:\n{state.get('word_by_word', 'Not available.')}\n\n"
        f"Multi-Level Summary:\n{state.get('multilevel_summary', 'Not available.')}\n\n"
    )
    
    # Use LLM to create combined commentary from semantic analysis
    prompt_messages = get_combined_commentary_prompt(
        source_text=state['source'], 
        commentaries=combined_inputs,
        has_commentaries=True,
        language=state.get('language', 'English')
    )
    
    response = llm_thinking.invoke(prompt_messages)
    
    return {"combined_commentary": commentary_content}

πŸ“‹ State Fields Differences

V1 State (Commentary-focused)

class State(TypedDict):
    translation: List[str]
    commentary1_translation: str     # βœ… Used in workflow
    commentary2_translation: str     # βœ… Used in workflow
    commentary3_translation: str     # βœ… Used in workflow
    source: str
    sanskrit: str
    language: str
    feedback_history: List[str]
    format_feedback_history: List[str]
    commentary1: str                 # βœ… Input commentary
    commentary2: str                 # βœ… Input commentary
    commentary3: str                 # βœ… Input commentary
    combined_commentary: str
    commentary_source: str           # "traditional" or "source_analysis"
    key_points: List[KeyPoint]
    plaintext_translation: str  
    itteration: int
    format_iteration: int
    formated: bool
    glossary: List[GlossaryEntry]

V2 State (Semantic-analysis-focused)

class State(TypedDict):
    translation: List[str]
    commentary1_translation: str     # Present but not used in workflow
    commentary2_translation: str     # Present but not used in workflow
    commentary3_translation: str     # Present but not used in workflow
    source: str
    sanskrit: str
    language: str
    feedback_history: List[str]
    format_feedback_history: List[str]
    commentary1: str                 # Present but not used in workflow
    commentary2: str                 # Present but not used in workflow
    commentary3: str                 # Present but not used in workflow
    combined_commentary: str
    key_points: List[KeyPoint]
    plaintext_translation: str  
    itteration: int
    format_iteration: int
    formated: bool
    glossary: List[GlossaryEntry]
    # V2 Additional Fields:
    ucca: str                        # βœ… NEW: UCCA graph analysis
    word_by_word: str                # βœ… NEW: Word-by-word translation
    multilevel_summary: str          # βœ… NEW: Multi-level summary

πŸ”§ Workflow.py Comparison

V1 Workflow Nodes

# tibetan_translator/workflow.py

optimizer_builder.add_node("commentary_translator_1", commentary_translator_1)
optimizer_builder.add_node("commentary_translator_2", commentary_translator_2)
optimizer_builder.add_node("commentary_translator_3", commentary_translator_3)
optimizer_builder.add_node("aggregator", aggregator)
optimizer_builder.add_node("translation_generator", translation_generator)
optimizer_builder.add_node("llm_call_evaluator", llm_call_evaluator)
optimizer_builder.add_node("generate_glossary", generate_glossary)

# Edges
optimizer_builder.add_edge(START, "commentary_translator_1")
optimizer_builder.add_edge(START, "commentary_translator_2")
optimizer_builder.add_edge(START, "commentary_translator_3")
optimizer_builder.add_edge("commentary_translator_1", "aggregator")
optimizer_builder.add_edge("commentary_translator_2", "aggregator")
optimizer_builder.add_edge("commentary_translator_3", "aggregator")

V2 Workflow Nodes

# tibetan_translator_v2/workflow.py

optimizer_builder.add_node("process_ucca", process_ucca)
optimizer_builder.add_node("process_word_by_word", process_word_by_word)
optimizer_builder.add_node("process_multilevel_summary", process_multilevel_summary)
optimizer_builder.add_node("aggregator", aggregator)
optimizer_builder.add_node("translation_generator", translation_generator)
optimizer_builder.add_node("llm_call_evaluator", llm_call_evaluator)
optimizer_builder.add_node("generate_glossary", generate_glossary)

# Edges
optimizer_builder.add_edge(START, "process_ucca")
optimizer_builder.add_edge(START, "process_word_by_word")
optimizer_builder.add_edge(START, "process_multilevel_summary")
optimizer_builder.add_edge("process_ucca", "aggregator")
optimizer_builder.add_edge("process_word_by_word", "aggregator")
optimizer_builder.add_edge("process_multilevel_summary", "aggregator")

🎯 When to Use Which Version

Use V1 (tibetan_translator) When:

  • βœ… You have traditional scholarly commentaries
  • βœ… Working with texts that have established commentary traditions
  • βœ… Need a standalone translation pipeline
  • βœ… Commentary interpretation is critical to translation accuracy
  • βœ… Quick setup without pre-processing requirements

Use V2 (tibetan_translator_v2) When:

  • βœ… You have pre-generated UCCA semantic graphs
  • βœ… Word-by-word translations are available
  • βœ… Multi-level summaries have been prepared
  • βœ… Need fine-grained semantic analysis
  • βœ… Working with texts that lack traditional commentaries
  • βœ… Building a full semantic pipeline with ucca_generator

πŸ“ˆ Data Flow Comparison

V1 Data Flow

Raw Tibetan Text + 3 Commentaries
              β”‚
              β–Ό
    [Translate each commentary]
              β”‚
              β–Ό
    [Combine into unified commentary]
              β”‚
              β–Ό
    [Generate translation using commentary]
              β”‚
              β–Ό
    [Evaluate and refine]
              β”‚
              β–Ό
    Final Translation + Glossary

V2 Data Flow

Raw Tibetan Text + UCCA + Word-by-Word + Summary
              β”‚
              β–Ό
    [Load pre-processed semantic data]
              β”‚
              β–Ό
    [Combine into unified analysis]
              β”‚
              β–Ό
    [Generate translation using semantic analysis]
              β”‚
              β–Ό
    [Evaluate and refine]
              β”‚
              β–Ό
    Final Translation + Glossary

πŸ”— Related Pages

Clone this wiki locally