Page MenuHomePhabricator

Generate article summaries for summary experiment
Closed, ResolvedPublic5 Estimated Story PointsSpike

Description

Background

We would like to generate the summaries selected by the criteria in T375363: [SPIKE] Define and document article criteria for article summarization content

User story

  • As a product team, we would like to define what a "good" set of articles for this experiment looks like, so that we can learn whether this feature would be helpful to readers

Requirements

This task was created by Version 1.2.0 of the Web team task template using phabulous

Event Timeline

ovasileva triaged this task as High priority.
ovasileva renamed this task from [SPIKE] Estimate cost of generating article summaries to [SPIKE] Estimate cost and generating article summaries for summary experiment.Sep 26 2024, 3:51 PM

While working on T374635 - Precompute Article Summaries we've discovered methods for generating a large amount of summaries that can be applied to this task. The learnings from that task are as follows:

Article selection

  • Per T375363, we need to generate a large list of articles that we'll be making summaries for. We have the categorymembers action API to help us with this.

Article summary generation

  • Per Martin Gerlach's Jupyter Notebook, we should use the Aya-23-8B LLM from Cohere to generate article summaries. This model has good language support (although for this experiment, I presume we'll be sticking to english).
  • This model can be used via the Cohere Chat API. We can either pass in the intro text of every article we want to the API, or just the article URL (results seem to be the same).
  • The Cohere API free tier has an API limit of 10 requests per minute and 1000 requests per month.
  • The Aya-23-8B model can also run on personal computers! (new MacBook Pros, 64gb memory recommended) If we exhaust the free tier, we can generate summaries by running the model locally through a Python script or the jan.ai app for Mac which can spin up a server running the Aya model.

Article Summary storage

  • The article summaries should all be bundled with the extension. 10,000 summaries of about 200 words each are estimated to take up about 13mb. This payload will be downloaded by extension users once when the extension is installed or updated. It will not affect on-page performance.
  • Each summary should be stored in a single file, named after the article title. This should make it easy to retrieve the summaries in the browser extension because each file will be accessible via a URL. (If we run into issues with this approach we can explore a DB like sqlite)
ovasileva renamed this task from [SPIKE] Estimate cost and generating article summaries for summary experiment to Estimate cost and generating article summaries for summary experiment.Sep 26 2024, 5:26 PM
ovasileva removed a project: Spike.
ovasileva updated the task description. (Show Details)
Jdlrobson renamed this task from Estimate cost and generating article summaries for summary experiment to Fenerating article summaries for summary experiment.Sep 26 2024, 5:32 PM
Jdlrobson renamed this task from Fenerating article summaries for summary experiment to Generate article summaries for summary experiment.

I just pushed a patch to the following repo which we can use to generate the summaries:

https://gitlab.wikimedia.org/repos/web/simple-summary-server

There are a few parts to this script.

  1. A simple summary server which proxies the calls to the Cohere API and returns the simplified summaries
  2. A batch summarizer which populates a CSV file with the simplified summaries as well as the original intro paragraphs (provided by the summary API endpoint) for a list of titles.

That list of titles will be created in T375363

Based on T377747, we've generated a list of 8510 article summaries, using the Cohere API, and committed them to the extension repo:

https://gitlab.wikimedia.org/repos/web/web-experiments-extension/-/tree/main/src/assets/summaries?ref_type=heads

This list excludes the filtered titles from this list..

The summaries are generated from the first section of a given article using the following preamble and prompt config:

"max_tokens": 200,
"temperature": 0.01,
"preamble": "You are writing encyclopedic articles in the style of Wikipedia using simplified language and a neutral tone.",
"prompt_template": """
## Instructions
Summarize the text below at a 7-th grade reading level, in English, using 100 words or less. Return only the summary.

## Input text
{input_text}
"""

Signing this off in lieu of @ovasileva. The list looks great. Can confirm the filtered out titles are not present in this list.