Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

summarization.py 3.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  1. # install transformers module
  2. from transformers import pipeline
  3. import textwrap
  4. import numpy as np
  5. import pandas as pd
  6. from pprint import pprint
  7. def wrap(x):
  8. return textwrap.fill(x, replace_whitespace = False, fix_sentence_endings=True)
  9. # A key market indicator hasn’t been this high since the Great Recession
  10. text = "10-year Treasury yields are flirting with 5% for the first time since 2007, before the global financial crisis. The 30-year fixed rate mortgage has been advancing towards 8% — a level not seen since the dot-com bubble popped in 2000. \
  11. Rates may fluctuate, but it’s clear that we’re in the middle of a paradigm shift, said Rob Almeida at MFS Investment Management. It’s unlikely that rates will return to pre-pandemic lows, he said.\
  12. There are a few reasons that the 10-year has advanced so quickly since last year, when it sat around 4%: Strong economic growth and elevated inflation tend to push yields higher. The US Treasury has issued a lot of government debt\
  13. in recent months, and with expensive wars in Ukraine and the Middle East looming, more could be coming soon. \
  14. Those things bring down bond prices and push yields higher, attracting buyers.\
  15. Regardless of why it’s happening, for American consumers, an elevated 10-year Treasury return means economic pain: more costly car loans, credit card rates and even student debt.\
  16. It also means more expensive mortgage rates. Mortgage rates tend to track the yield on 10-year US Treasuries. When Treasury yields go up, so do mortgage rates; when they go down, mortgage rates tend to follow.\
  17. But what’s bad for the economy tends to be good for bringing prices down. Fed officials, including Powell, have indicated that rates could be high enough to help lower inflation towards their target goal of 2%.\
  18. But they’re leaving the door open for further hikes based on future economic data."
  19. # install sentencepiece for google-pegasus
  20. #pip install protobuf==3.20.*
  21. #pip install sentencepiece
  22. summarizer = pipeline('summarization', model="google/pegasus-large")
  23. summary_list = summarizer(text)
  24. summary = summary_list[0]["summary_text"]
  25. print(summary)
  26. #distilbart-cnn-12-6 model
  27. """10-year Treasury yields are flirting with 5% for the first time since 2007, before the global financial crisis . \
  28. The 30-year fixed rate mortgage has been advancing towards 8% \
  29. — a level not seen since the dot-com bubble popped in 2000 . Strong economic growth \
  30. and elevated inflation tend to push yields higher ."""
  31. #bart is trained on CNN daily
  32. #bart-large-cnn
  33. """10-year Treasury yields are flirting with 5% for the first time since 2007, before the global financial crisis.\
  34. The 30-year fixed rate mortgage has been advancing towards 8% — a level not seen since the dot-com bubble popped in 2000.\
  35. Strong economic growth and elevated inflation tend to push yields higher."""
  36. #google-pegasus
  37. """It’s unlikely that rates will return to pre-pandemic lows, he said.There are a few reasons that the 10-year \
  38. has advanced so quickly since last year,\
  39. when it sat around 4%: Strong economic growth and elevated inflation tend to push yields higher."""
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...