Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread Summaries Workflow Analysis and Proposal #61

Open
kouloumos opened this issue Oct 18, 2024 · 0 comments
Open

Thread Summaries Workflow Analysis and Proposal #61

kouloumos opened this issue Oct 18, 2024 · 0 comments

Comments

@kouloumos
Copy link
Contributor

kouloumos commented Oct 18, 2024

Context

The current thread summarization workflow was initially developed for the TLDR product, where it continues to serve its purpose. This process plays a vital role in summarizing large threads to provide concise, useful insights for users. However, after a period of usage, it's clear there are some architectural challenges and potential areas for improvement, particularly as our infrastructure evolves.

Current Workflow Overview

summarizer_workflow

The thread summary generation process involves:

  • Daily Updates: The thread summary is updated every day via a cron job.
  • Input Data: Each time the summary is generated, it uses:
    • The individual summaries of all previous posts in the thread.
    • The actual content of new posts added since the last summary update.
  • Individual Post Summaries: As part of the summarization workflow, each post in a thread also receives its own individual summary, which is then used to feed into the thread summary.
Click to expand: Thread Summarization Workflow Diagram
sequenceDiagram
    participant ES as Elasticsearch
    participant S as Summarizer
    participant OpenAI
    participant G as GitHub

note over ES, G: Summarize bitcoin-dev, lightning-dev, delvingbitcoin
    loop daily at 01:00 AM UTC - XML Generation Script
        loop for each source
            S->>+ES: Query ES index for last 30-days
            ES-->>-S: Return relevant documents
            S->>S: Retrieve all existing XML files (summaries) for the given source
            loop for each thread
                loop for each new post without XML file (summary)
                    S->>+OpenAI: Prompt for summary
                    OpenAI-->>-S: Return generated summary
                    S->>S: Generate XML file with summary
                end
                S->>S: Compile input for summary generation using <br> - the individual summaries of previous posts <br> - the actual content of newer posts
                S->>+OpenAI: Prompt for summary of the thread
                OpenAI-->>-S: Return generated summary
                S->>S: Generate `combined_summary` XML file <br>
            end
        end
        S->>+G: Commit XML files
    end

    note over ES, S: Add Summaries to Elasticsearch Index
    loop daily at 02:00 AM UTC - Push Summary From XML Files to ES INDEX
        S->>+ES: Query for documents without summary
        ES-->>-S: Return relevant documents
        loop for each document
            S->>S: Extract summary from relevant XML file
            S->>ES: Update document with summary
        end
    end

    note over ES, S: Add Combined Summaries to Elasticsearch Index
    loop daily at 02:30 AM UTC - Push Combined Summary From XML Files to ES INDEX
        S->>S: Process all 'combined_summary' XML files to <br> transform them into documents
        loop for each 'combined_summary' document
            S->>ES: Check existence, insert or update accordingly
        end
        
    end
Loading

source: Sequence Diagram of Bitcoin Search ecosystem

Challenges and Questions

While the current system works, several points deserve scrutiny:

  1. Duplication of Data:

    • The XML files containing thread and post summaries are used directly in the TLDR project, where this repo is a submodule.
    • The same information is duplicated in Elasticsearch, leading to potential inconsistencies and inefficiencies. Is this duplication necessary, or can we streamline the architecture to avoid redundancy?
  2. Individual Post Summaries:

    • Do the individual post summaries add significant value? Many posts, especially short replies, may have summaries longer than the posts themselves. It’s unclear how useful these summaries are, particularly for very short or simple posts.
    • Actionable Insight: It would be helpful to run an analysis on the length of individual post summaries versus their original content to assess the real value.
      Edit: see Summary Efficiency Analysis #62
  3. Thread Summary Accuracy:

    • Given that each thread summary is built using the individual post summaries along with new content, how does this impact the accuracy and coherence of the thread summary? Is this the most effective way to capture the overall essence of the thread?
    • Could there be cases where the overall thread summary diverges or loses critical context because it's based on potentially incomplete or low-quality post summaries?

Limitations of Current Architecture

  • Dependency on Individual Summaries: The reliance on individual post summaries may be a bottleneck. If those summaries are not consistently useful or coherent, the thread summary suffers as a result.
  • Complexity of Synchronization: Updates made to a summary in Elasticsearch might not reflect in the XML files (or vice versa) without additional logic for synchronization, making it prone to data drift.
  • Scalability Issues: As the number of summaries and threads grows, the overhead of maintaining both the XML and Elasticsearch versions increases. This could lead to performance bottlenecks or complicated deployment pipelines.
  • XML as a Format: XML parsing adds an unnecessary layer of complexity to handling thread summaries.
  • Submodule Dependency: While using the repo as a submodule within TLDR ensures synchronization between the two, it also introduces tight coupling between projects. This creates dependencies that could complicate the development process.
  • No Central Resource Representation: As mentioned in the (upcoming) related terminology issue, there’s no explicit document representing the thread itself. The current design relies on aggregating post summaries but doesn’t have a centralized reference document for the thread, which complicates downstream processes like combined summaries.

Improvements and Potential Solutions

  1. Rethinking the Summarization Strategy:

    • Refining Individual Post Summaries: We could introduce a filter or threshold to only summarize posts that meet a certain length or complexity, eliminating the need to summarize very short or redundant replies.
    • Thread Summary Focus: Instead of building the thread summary from individual post summaries, we could explore models that directly summarize the overall thread content for better coherence.
  2. Eliminating Duplication:

    • We should consider refactoring the workflow so that either the XML or Elasticsearch is the authoritative data source, reducing redundancy and complexity in maintaining two systems.
  3. Decouple from the Submodule Architecture:

    • If TLDR is primarily accessing summaries from this repo via XML, we could re-architect the solution to decouple the projects. Let TLDR interface directly with Elasticsearch, which would streamline the system and eliminate the need for the submodule.
  4. Combined Summaries:

    • Establishing a central thread resource document would simplify the process for creating combined summaries, as we would no longer need to create a separate document for the thread summary. This could also help in ranking threads or integrating across sources.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant