Â
1. Learning Objectives
By the end of this lesson, you will be able to:
-
Understand the need for automatic summarization of long financial documents (10âK, earnings calls, news).
-
Differentiate between extractive and abstractive summarization and choose the right approach.
-
Implement extractive summarization using TextRank and BERTâbased sentence scoring.
-
Fineâtune transformer models (BART, T5, PEGASUS) for abstractive summarization of financial text.
-
Evaluate summaries using ROUGE, BLEU, and BERTScore, with domainâspecific considerations.
-
Generate structured summaries (e.g., bullet points, key metrics) for earnings reports.
-
Understand the challenges of factuality and numerical accuracy in abstractive summarization.
2. Why Summarization in Finance?
-
Financial analysts read hundreds of pages of filings and transcripts.
-
Automated summarization can produce executive summaries, highlighting key figures (revenue, EPS, guidance).
-
News summarization helps traders quickly grasp market-moving events.
-
Generating summaries from multiple sources can provide a consolidated view.
Use cases:
-
Earnings call summarization:Â Extract prepared remarks and Q&A highlights.
-
Research report summarization:Â Condense analyst notes.
-
Regulatory filing summarization:Â Produce a oneâpage summary of a 10âK.
3. Extractive Summarization
Selects the most important sentences from the original document and concatenates them.
3.1 GraphâBased: TextRank
Build a graph where nodes are sentences, edges represent similarity (e.g., cosine similarity of TFâIDF vectors). Use PageRank to score sentences.
PageRank equation:
PR(vi)=(1âd)+dâvjâIn(vi)wj,iâvkâOut(vj)wj,kPR(vj)
where w_{j,i} is the similarity between sentences j and i.
Implementation:
import networkx as nx similarity_matrix = cosine_similarity(tfidf_matrix) # sentences x sentences nx_graph = nx.from_numpy_array(similarity_matrix) scores = nx.pagerank(nx_graph) top_sentences = sorted(scores, key=scores.get, reverse=True)[:num_sentences]
3.2 Neural Extractive Models
BERTâbased models (e.g., BERTâSUM) classify each sentence as included or not, using the [CLS] representation of the sentence.
Training:Â Binary classification (include/discard) with crossâentropy loss.
4. Abstractive Summarization
Generates new sentences that capture the essence, potentially paraphrasing and fusing information.
4.1 SequenceâtoâSequence (Seq2Seq) with Transformers
Models like BART, T5, and PEGASUS are preâtrained for summarization.
BART:Â Denoising autoencoder â corrupts text (e.g., token masking, sentence permutation) and learns to reconstruct. Fineâtuned for summarization with crossâentropy loss over target tokens.
T5:Â Textâtoâtext transfer transformer â treats summarization as a textâtoâtext problem: input = “summarize: [document]”, output = summary.
PEGASUS:Â Preâtrained with gapâsentence generation â removes important sentences and trains to predict them. This is highly effective for summarization.
4.2 Fineâtuning on Financial Data
Use datasets like:
-
FinSum:Â A summarization dataset of financial news and reports.
-
EarningsCallSum:Â Transcripts with humanâwritten summaries.
Training objective:Â Minimise negative logâlikelihood of target summary tokens:
L=âât=1TlogâĄP(ytâŁy<t,x)
Implementation with HuggingFace:
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, Seq2SeqTrainingArguments, Seq2SeqTrainer model = AutoModelForSeq2SeqLM.from_pretrained("google/pegasus-large") tokenizer = AutoTokenizer.from_pretrained("google/pegasus-large") # Prepare dataset with input_ids and labels trainer = Seq2SeqTrainer( model=model, args=training_args, train_dataset=train_dataset, eval_dataset=eval_dataset, tokenizer=tokenizer, ) trainer.train()
4.3 Controlling Summary Length and Style
Set max_length and min_length in generation. Use length_penalty to encourage brevity.
Beam search (width 4â8) is standard; diversity penalty can reduce repetition.
5. Evaluation Metrics for Summarization
-
ROUGE (RecallâOriented Understudy for Gisting Evaluation):
ROUGEâN: Counts nâgram overlap.
ROUGE-N=âsârefâgramnâsCountmatch(gramn)âsârefâgramnâsCount(gramn)
ROUGEâL: Longest common subsequence (LCS) between summary and reference.
-
BLEU:Â Precisionâbased nâgram overlap (less common for summarization, more for translation).
-
BERTScore:Â Computes similarity using contextual embeddings (BERT) â correlates better with human judgment.
For financial summaries: Also check factuality â ensure numbers (EPS, revenue) are correct. Use factual consistency metrics like QAFactEval.
6. Challenges and Mitigations
| Challenge | Mitigation |
|---|---|
| Factual hallucination (model invents numbers) | Use extractive oracle to constrain generation; add a numeric verification layer postâgeneration. |
| Numerical precision (e.g., rounding errors) | Train with exact numbers as entities; use copy mechanism to copy from source. |
| Long documents (>512 tokens) | Use Longformerâbased summarization or hierarchical (sentenceâlevel then documentâlevel). |
| Domain adaptation | Fineâtune on financial corpora; use domainâspecific tokenisation (e.g., keep “$”, “%”). |
7. Hybrid Approaches: Extractive + Abstractive
First extract the most relevant sentences (e.g., using BERTâSUM), then feed them to an abstractive model to rewrite and condense. This reduces input length and improves factuality.
Example pipeline:
-
Use a transformerâbased extractive model to select topâk sentences.
-
Concatenate them.
-
Input to a BART/T5 model for final summary.
8. Generating Structured Summaries (KeyâValue Format)
For earnings reports, we often want a structured summary:
Revenue: $XX.XXB (beat/meet/miss) EPS: $X.XX (beat/meet/miss) Guidance: [raised/lowered/confirmed] Key Drivers: [segment growth, cost control] Risks: [supply chain, regulatory]
This can be framed as a templateâfilling task where we extract entities and values from the document, then fill a template.
Approach:Â Use NER and relation extraction to populate the template; generate natural language using a preâdefined template or a language model.
9. Summary for the AI Practitioner
-
Extractive summarization (TextRank, BERTâSUM) is safe and factually consistent; useful for quick scanning.
-
Abstractive summarization (BART, T5, PEGASUS) produces more fluent and concise summaries but risks hallucination.
-
Fineâtuning on financial datasets is crucial; general models struggle with domain terminology.
-
Evaluation should combine ROUGE, BERTScore, and factuality checks (especially for numbers).
-
Hybrid extractiveâabstractive pipelines offer a good tradeâoff between fidelity and conciseness.
-
Structured summaries (with templates) can be more actionable for financial decisions.
10. References
-
Rush, A. M., et al. (2015). A neural attention model for abstractive sentence summarization. EMNLP.
-
Lewis, M., et al. (2020). BART: Denoising sequenceâtoâsequence preâtraining for natural language generation. ACL.
-
Zhang, J., et al. (2020). PEGASUS: Preâtraining with extracted gapâsentences for abstractive summarization. ICML.
-
Lin, C.âY. (2004). ROUGE: A package for automatic evaluation of summaries. ACL Workshop.
-
Zhang, T., et al. (2020). BERTScore: Evaluating text generation with BERT. ICLR.
-
Mehta, P., et al. (2021). FinSum: A dataset for summarization of financial news. Workshop on Financial NLP.