{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c54188ab-acab-4f76-8a00-c5b7655e288b",
   "metadata": {},
   "source": [
    "# Chapter 3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "81631471-2964-4915-baea-a2c049b33743",
   "metadata": {},
   "source": [
    "## Summarizing a document bigger than the LLM’s context window"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "02505e40-3967-4861-a109-2742bc64bca8",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"./Moby-Dick.txt\", 'r', encoding='utf-8') as f:\n",
    "    moby_dick_book = f.read()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e9d211ad-6929-4169-9e10-09012c505554",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_openai import ChatOpenAI\n",
    "from langchain_text_splitters import TokenTextSplitter\n",
    "from langchain_core.prompts import PromptTemplate\n",
    "from langchain_core.output_parsers import StrOutputParser\n",
    "from langchain_core.runnables import RunnableLambda, RunnableParallel\n",
    "import getpass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e629d25f-5046-42bd-973e-fb6e1512de3e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Enter your OPENAI_API_KEY ········\n"
     ]
    }
   ],
   "source": [
    "OPENAI_API_KEY = getpass.getpass('Enter your OPENAI_API_KEY')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "42d498d8-d621-4375-971b-ab36b227a56e",
   "metadata": {},
   "outputs": [],
   "source": [
    "llm = ChatOpenAI(openai_api_key=OPENAI_API_KEY,model_name=\"gpt-5-nano\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "fc3416e6-9173-414b-be35-d8b6cfc426ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Split\n",
    "text_chunks_chain = (\n",
    "    RunnableLambda(lambda x: \n",
    "        [\n",
    "            {\n",
    "                'chunk': text_chunk, \n",
    "            }\n",
    "            for text_chunk in \n",
    "               TokenTextSplitter(chunk_size=3000, chunk_overlap=100).split_text(x)\n",
    "        ]\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4e697025-0355-4b18-9093-59721dfefed7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Map\n",
    "summarize_chunk_prompt_template = \"\"\"\n",
    "Write a concise summary of the following text, and include the main details.\n",
    "Text: {chunk}\n",
    "\"\"\"\n",
    "\n",
    "summarize_chunk_prompt = PromptTemplate.from_template(summarize_chunk_prompt_template)\n",
    "summarize_chunk_chain = summarize_chunk_prompt | llm\n",
    "\n",
    "summarize_map_chain = (\n",
    "    RunnableParallel (\n",
    "        {\n",
    "            'summary': summarize_chunk_chain | StrOutputParser()        \n",
    "        }\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "862989b8-a32a-4dd3-9426-d2cdec9a5318",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Reduce\n",
    "summarize_summaries_prompt_template = \"\"\"\n",
    "Write a coincise summary of the following text, which joins several summaries, and include the main details.\n",
    "Text: {summaries}\n",
    "\"\"\"\n",
    "\n",
    "summarize_summaries_prompt = PromptTemplate.from_template(summarize_summaries_prompt_template)\n",
    "summarize_reduce_chain = (\n",
    "    RunnableLambda(lambda x: \n",
    "        {\n",
    "            'summaries': '\\n'.join([i['summary'] for i in x]), \n",
    "        })\n",
    "    | summarize_summaries_prompt \n",
    "    | llm \n",
    "    | StrOutputParser()\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "637bd1e2-ed81-4862-8af4-91c4239765ac",
   "metadata": {},
   "outputs": [],
   "source": [
    "map_reduce_chain = (\n",
    "   text_chunks_chain\n",
    "   | summarize_map_chain.map()\n",
    "   | summarize_reduce_chain\n",
    ")     "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "ba1581b0-c541-44d0-81b9-d29d2aaaa72b",
   "metadata": {},
   "outputs": [],
   "source": [
    "summary = map_reduce_chain.invoke(moby_dick_book)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "338812b8-c4dd-445b-bcc0-7517d56e0bb7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "- Bibliographic basics: Moby-Dick; or The Whale by Herman Melville. Project Gutenberg edition (eBook #2701), English, UTF-8.\n",
      "\n",
      "- Core aim and mood: Ishmael goes to sea to cure his gloom and rest his mind; the sea is framed as a mysterious, life-siphoning force, and his voyage is presented as part of a fated plan.\n",
      "\n",
      "- Initial setting: He travels to New Bedford seeking cheap, honest seafaring work; the Spouter Inn in a dim, smoky room introduces a grand, unsettling painting and a wall of weapons, setting a ominous, mythic atmosphere.\n",
      "\n",
      "- Key characters and fate hints: An imposing harpooneer (Queequeg) is anticipated as a future shipmate; Bulkington, a formidable Southerner, arrives and becomes Ishmael’s potential comrade-in-waiting; the landlord’s odd tales foreshadow dangers and curiosities of whaling life.\n",
      "\n",
      "- Bed-sharing arrangement and odd lore: The inn warns that Ishmael will share a bed with the harpooneer; the landlord recounts bizarre, ritualistic details about the harpooneer’s recent South Seas trading and a last New Zealand head for sale.\n",
      "\n",
      "- Queequeg’s entrance and first impressions: Queequeg arrives, tattooed and culturally exotic, carrying a New Zealand head, tomahawk, and seal-skin wallet; he performs a Congo idol rite, then homestays with Ishmael for the night, despite Ishmael’s initial fear.\n",
      "\n",
      "- The morning after: Ishmael wakes to Queequeg’s tattooed arm draped over him; Queequeg’s manner—civilized yet savage, wearing a beaver hat and pilot jacket, shaving with a harpoon head—presents a vivid image of a “civilized savage” and foreshadows their growing companionship; the scene closes with Queequeg leaving, setting up The Counterpane and their voyage ahead.\n"
     ]
    }
   ],
   "source": [
    "print(summary)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0bc1b8ce-97d1-4bf8-980a-acf763b0b17d",
   "metadata": {},
   "source": [
    "## Summarizing across documents"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "7bbe6bb1-c8a0-4440-a465-3c4426124000",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_community.document_loaders import WikipediaLoader\n",
    "\n",
    "wikipedia_loader = WikipediaLoader(query=\"Paestum\", load_max_docs=2)\n",
    "wikipedia_docs = wikipedia_loader.load()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "bde07708-1499-40c0-9f64-32650b36a113",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_community.document_loaders import Docx2txtLoader\n",
    "from langchain_community.document_loaders import PyPDFLoader\n",
    "from langchain_community.document_loaders import TextLoader\n",
    "\n",
    "word_loader = Docx2txtLoader(\"Paestum/Paestum-Britannica.docx\")\n",
    "word_docs = word_loader.load()\n",
    "\n",
    "pdf_loader = PyPDFLoader(\"Paestum/PaestumRevisited.pdf\")\n",
    "pdf_docs = pdf_loader.load()\n",
    "\n",
    "txt_loader = TextLoader(\"Paestum/Paestum-Encyclopedia.txt\")\n",
    "txt_docs = txt_loader.load()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "b3615a11-ca38-41de-95b8-4ece197644d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "all_docs = wikipedia_docs + word_docs + pdf_docs + txt_docs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "5dc508b9-2ee1-4cf2-b5a2-c347e8d4ba19",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_openai import ChatOpenAI\n",
    "from langchain_core.prompts import PromptTemplate\n",
    "import getpass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4b9e5655-397b-40aa-aeb3-867150ed4fe8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Enter your OPENAI_API_KEY ········\n"
     ]
    }
   ],
   "source": [
    "OPENAI_API_KEY = getpass.getpass('Enter your OPENAI_API_KEY')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "776b6bd0-07ed-410c-bc1e-57cd94d002a2",
   "metadata": {},
   "outputs": [],
   "source": [
    "llm = ChatOpenAI(openai_api_key=OPENAI_API_KEY,model_name=\"gpt-5-nano\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "67a7db89-2e71-4dee-95d2-b02696170311",
   "metadata": {},
   "outputs": [],
   "source": [
    "doc_summary_template = \"\"\"Write a concise summary of the following text:\n",
    "{text}\n",
    "DOC SUMMARY:\"\"\"\n",
    "doc_summary_prompt = PromptTemplate.from_template(doc_summary_template)\n",
    "\n",
    "doc_summary_chain = doc_summary_prompt | llm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "53fc69f8-7c6f-499e-a584-2fb3f844bd69",
   "metadata": {},
   "outputs": [],
   "source": [
    "refine_summary_template = \"\"\"\n",
    "Your must produce a final summary from the current refined summary\n",
    "which has been generated so far and from the content of an additional document.\n",
    "This is the current refined summary generated so far: {current_refined_summary}\n",
    "This is the content of the additional document: {text}\n",
    "Only use the content of the additional document if it is useful, \n",
    "otherwise return the current full summary as it is.\"\"\"\n",
    "\n",
    "refine_summary_prompt = PromptTemplate.from_template(refine_summary_template)\n",
    "\n",
    "refine_chain = refine_summary_prompt | llm | StrOutputParser()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "419dcb26-5d23-4e25-9479-c719018979db",
   "metadata": {},
   "outputs": [],
   "source": [
    "def refine_summary(docs):\n",
    "\n",
    "    intermediate_steps = []\n",
    "    current_refined_summary = ''\n",
    "    for doc in docs:\n",
    "        intermediate_step = \\\n",
    "           {\"current_refined_summary\": current_refined_summary, \n",
    "            \"text\": doc.page_content}\n",
    "        intermediate_steps.append(intermediate_step)\n",
    "        \n",
    "        current_refined_summary = refine_chain.invoke(intermediate_step)\n",
    "        \n",
    "    return {\"final_summary\": current_refined_summary,\n",
    "            \"intermediate_steps\": intermediate_steps}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "dd718bbb-43ee-4f52-80ec-2033b7702ac0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'final_summary': 'Integrated final summary (synthesizing the current refined summary with the additional document)\\n\\nPoseidonia/Paestum traces a long arc from a flourishing Greek urban center to a Lucanian-influenced city and finally to a Roman colonial town, with continuity in sacred spaces and intercultural exchange tempered by strategic political remodeling under Rome. The site also preserves remarkable early Greek architecture, most famously the Doric temples whose surviving ruins illuminate Paestum’s initial monumental character.\\n\\n1) Early core and material culture (7th–5th centuries BCE)\\n- Urban and sacred framework: A fortified Greek polis with a four-gated wall, an agora north of the Hera sanctuary, the Temple of Athena, and the two Hera temples (I and II). The surviving group of Doric temples (c. 530–460 BCE) represents Paestum’s early monumental architecture. The Paestum Order—characterized by exaggerated entasis and broad, squat capitals—became a model that later Neo-Classical architects celebrated.\\n- Civic life and cult practice: A bouleuterion/ekklesiasterion within the defended area, formal gate systems, and sanctuaries sustaining public cult. The Tomb of the Diver exemplifies intercultural exchange with Italic and Etruscan worlds.\\n- Interregional exchange: Ongoing ties with the Greek world and Italic groups support prosperity amid southern Italian rivalries.\\n\\n2) Greek prosperity to Lucanian influence\\n- Lucanian period and continuity: Following the fall of Sybaris, Poseidonia remains prosperous and comes under Lucanian influence from the 4th century BCE to around 273 BCE, interpreted as gradual integration rather than a sudden conquest.\\n- Lucanian signatures in the urban fabric: Greek sacred spaces (bouleuterion, heroon, sanctuaries) persist, while the landscape shows Lucanian incorporation—agricultural intensification, higher settlement density, and new burial practices with increased decorative elements.\\n- Naming and identity: Poseidonia remains the widely used toponym during the Lucanian period, reinforcing continuity of identity rather than a sharp Greek-to-Lucanian rupture.\\n\\n3) Roman colonization and transformation\\n- Roman incursion and colonization: In 273 BCE Rome establishes a Latin colony at Poseidonia, integrating the Greek/Lucanian settlement into the Roman imperial system.\\n- Roman colonial model and urban reorganization: Rome acts as a model but adapts the pattern to fit colonial purposes; a Roman forum is laid out in the southern part of the old agora, and traditional Greek/juridical structures in the agora are demolished or replaced. Sanctuaries remain in use (intramural and extramural) and continue to be objects of worship, preserving religious continuity.\\n- Political and material continuity with change: The city retains much of its sacred layout, while new political buildings cluster around the forum. A Temple of Peace begins in the 2nd century BCE, and Paestum maintains strong ties with Rome, including a degree of autonomy and the right to mint coins.\\n- Diplomatic and military alignment: Paestum demonstrates loyalty to Rome during crises (e.g., Hannibal’s campaigns in the Second Punic War) and aligns politically and diplomatically with Rome, illustrating a hybrid identity that preserves Greek/Lucanian roots within a Roman framework.\\n- River-route disruption: In 133 BCE, the via Popilia to the east of Paestum alters connectivity by cutting off principal routes to the peninsula, reshaping its regional integration and communications.\\n- Ritual of colonization: The colonia’s founding follows a ritualized pattern (deductio, ploughing of the sulcus primigenius, delineation of the pomoerium) that underpins Roman expansion into existing urban networks, including Poseidonia.\\n\\n4) Decline, landscape, and modern rediscovery\\n- Environmental and imperial pressures: Siltation of the Silarus River leading to malarial swamps contributes to long-term decline, even as settlement persists under successive rulers.\\n- Post-antique trajectory: The site experiences sackings (notably by Muslim forces in AD 871) and enters a long period of obscurity before modern rediscovery and archaeology.\\n- Archaeology, landscape, and museums: The ancient city covered roughly 120 hectares, with about 25 hectares excavated; walls extend ~5 km with multiple gates and towers. A national archaeological museum at the site houses finds from Foce del Sele, including Lucanian frescoes illuminating a hybrid cultural milieu. Paestum today lies to the east of the ancient walls, with accessible road, rail, and a nearby airport (Salerno–Pontecagnano).\\n\\nIntegrated nuance from the additional document\\n- Naming and continuity: The Lucanian-period city is treated as Poseidonia, reinforcing cultural continuity rather than a sharp Greek-to-Lucanian rupture.\\n- Lucanian impact: Lucanian influence appears in demographic and settlement dynamics and burial practices, rather than through wholesale architectural overhauls or replacement of Greek religious life.\\n- Latin colonization ritual: The colonia’s founding follows a ritualized pattern (deductio, ploughing of the sulcus primigenius, delineation of the pomoerium) that underpins Roman expansion into existing urban networks, including Poseidonia.\\n\\nIn short, Poseidonia/Paestum begins as a prominent Greek polis with a defined architectural core, sustains intercultural exchange into the Lucanian era, undergoes gradual Lucanian integration without wholesale cultural collapse, and is transformed under Roman colonial patterns while retaining essential Greek and Lucanian sacred and urban features. The combination of continuity in religious life with a clear Roman urban remodeling—coupled with environmental decline and eventual modern rediscovery—frames the city’s resilient yet evolving urban character across centuries. The surviving Doric temples and the Paestum Order also underscore the site’s enduring architectural prestige, influencing later architectural appreciation and study.', 'intermediate_steps': [{'current_refined_summary': '', 'text': 'Paestum ( PEST-əm, US also  PEE-stəm, Latin: [ˈpae̯stũː]) was a major ancient Greek city on the coast of the Tyrrhenian Sea, in Magna Graecia. The ruins of Paestum are famous for their three ancient Greek temples in the Doric order dating from about 550 to 450 BCE that are in an excellent state of preservation. The city walls and amphitheatre are largely intact, and the bottom of the walls of many other structures remain, as well as paved roads. The site is open to the public, and there is a modern national museum within it, which also contains the finds from the associated Greek site of Foce del Sele.\\nPaestum was established around 600 BCE by settlers from Sybaris, a Greek colony in southern Italy, under the name of Poseidonia (Ancient Greek: Ποσειδωνία). The city thrived as a Greek settlement for about two centuries, witnessing the development of democracy. In 400 BCE, the Lucanians seized the city. Romans took over in 273 BCE, renaming it Paestum and establishing a Latin colony. Later, its decline ensued from shifts in trade routes and the onset of flooding and marsh formation. As Pesto or Paestum, the town became a bishopric (now only titular), but it was abandoned in the Early Middle Ages, and left undisturbed and largely forgotten until the eighteenth century.\\nToday the remains of the city are found in the modern frazione of Paestum, which is part of the comune of Capaccio Paestum in the Province of Salerno in the region of Campania, Italy. The modern settlement, directly to the south of the archaeological site, is a popular seaside resort with long sandy beaches. The Paestum railway station on the Naples-Salerno-Reggio Calabria railway line is directly to the east of the ancient city walls.\\n\\n\\n== Name ==\\nThe Greek settlers who founded the city originally named it Poseidonia (Ancient Greek: Ποσειδωνία). It was eventually conquered by the local Lucanians and later the Romans. The Lucanians renamed it to Paistos and the Romans gave the city its current name.\\n\\n\\n== Ancient ruins and features ==\\n\\nMuch of the most celebrated features of the site today are the three large temples in the Archaic version of the Greek Doric order, dating from about 550 to 450 BCE. All are typical of the period, with massive colonnades having a very pronounced entasis (widening as they go down), and very wide capitals resembling upturned mushrooms. Above the columns, only the second Temple of Hera retains most of its entablature, the other two having only the architrave in place.\\nThese were dedicated to Hera and Athena (Juno and Minerva to the Romans), although previously they often have been identified otherwise, following eighteenth-century arguments. The two temples of Hera are right next to each other, while the Temple of Athena is on the other side of the town center. There were other temples, both Greek and Roman, which are far less well preserved. \\nPaestum is far from any sources of good marble. Unsurprisingly, the three main temples had few stone reliefs, perhaps using painting instead. Painted terracotta was used for some detailed parts of the structure. The large pieces of terracotta that have survived are in the museum.\\n\\nThe whole ancient city of Paestum covered an area of approximately 120 hectares. Only the 25 hectares that contain the three main temples and the other main buildings have been excavated. The other 95 hectares remain on private land and have not been studied.\\nThe ancient city was surrounded by defensive walls, which are largely intact. The walls are approximately 4.75 km (3 mi) long in its polygonal perimeter, typically 7 m (23 ft) high, and 5–7 m (16–23 ft) thick. Corresponding with the cardinal points, there were four main openings in the wall: Porta Sirena (east to the hills); Porta Giustizia (south, now to the modern village Paestum); Porta Marina (west to the sea); and Porta Aurea (north), which was later destroyed. Positioned along the wall were 24 square or round towers. There may have been as many as 28, but some '}, {'current_refined_summary': 'Here is a final summary combining the current refined content with the additional Paestum document:\\n\\nPaestum is an ancient Greek city on the Tyrrhenian coast of Magna Graecia, founded around 600 BCE as Poseidonia by settlers from Sybaris. It flourished for about two centuries, developing democracy before being captured by the Lucanians circa 400 BCE and renamed Paistos; the Romans later renamed it Paestum in 273 BCE as a Latin colonia. The city declined due to shifts in trade routes and the formation of marshes, and was abandoned in the Early Middle Ages, remaining largely forgotten until the 18th century. Today, the remains lie in the modern frazione of Paestum, part of Capaccio Paestum in Campania, Italy, near the coast; the area includes a seaside resort and a railway station on the Naples–Salerno–Reggio Calabria line just east of the ancient walls. The site is notable for its three large Doric temples (Hera I, Hera II, and Athena) dating from about 550–450 BCE, with Hera temples especially well preserved as to their entablature; the Athena temple lies across the town center. The temples show typical Archaic Doric features, including massive columns with pronounced entasis and limited stone reliefs, with some painted terracotta used in decorative parts. The city covered about 120 hectares, though only roughly 25 hectares containing the main temples and buildings have been excavated; the remaining 95 hectares are on private land. The ancient defenses are largely intact: a polygonal wall about 4.75 km long, typically 7 m high and 5–7 m thick, with four gates (Porta Sirena, Porta Giustizia, Porta Marina, Porta Aurea) and around 24 towers (possibly up to 28 originally). The modern site includes a national museum housing finds from Foce del Sele.\\n\\nKey facts\\n- Location: Coastal Tyrrhenian site in Capaccio Paestum, Province of Salerno, Campania, Italy\\n- Founding and name: Founded circa 600 BCE as Poseidonia; renamed Paistos by Lucanians; Romans later Paestum\\n- History: Greek settlement with democracy; captured by Lucanians (c. 400 BCE); Roman Latin colony (273 BCE); declined due to trade shifts and marsh formation; abandoned in the Early Middle Ages\\n- Main ruins: Three Doric temples (Hera I, Hera II, Athena) dating to 550–450 BCE\\n- Architecture: Doric order; heavy entasis; limited marble reliefs; terracotta elements; best-preserved entablature on Hera I\\n- City layout: Large walls enclosing ~4.75 km of perimeter; four gates and ~24 towers (possible 28 originally); total site area ~120 hectares, with ~25 hectares excavated\\n- Modern status: Accessible archaeological site with a national museum; seaside resort area nearby; Paestum railway station to the east of the walls\\n- Notable museum: Contains finds from Foce del Sele\\n\\nIf you’d like, I can further tailor this into a shorter concise paragraph or expand any section with more detail.', 'text': 'Paestum (Italian: [ˈpɛstum]) is a frazione of the comune (municipality) of Capaccio Paestum in the Cilento area of southern Italy. It lies in the province of Salerno which is part of the region of Campania. It is situated on the Tyrrhenian coast and is notable for the famous ruins of the  ancient city of the same name nearby.\\n\\n\\n== Overview ==\\nPaestum can be reached by the road linking Agropoli to Battipaglia. Paestum railway station is on the Naples-Salerno-Reggio Calabria railway line. The nearest airport is Salerno-Pontecagnano (QSR), 30 km from Paestum.\\n\\n\\n== References ==\\n\\n\\n== External links ==\\n Media related to Paestum at Wikimedia Commons'}, {'current_refined_summary': 'Paestum is a coastal frazione of the comune Capaccio Paestum in the Cilento area of southern Campania, Italy, located on the Tyrrhenian coast in the province of Salerno. It preserves the ruins of the ancient Greek city Poseidonia, founded around 600 BCE and later renamed Paistos by the Lucanians and Paestum by the Romans. The site is renowned for three Doric temples—Hera I, Hera II, and Athena—dating to about 550–450 BCE. Hera I has the best-preserved entablature, and the temples exhibit typical Archaic Doric features such as massive columns with pronounced entasis and limited stone reliefs, with some terracotta decorative elements. The ancient city covered roughly 120 hectares, of which about 25 hectares have been excavated; the remaining 95 hectares lie on private land. The formidable polygonal wall encloses approximately 4.75 km, with four gates and around 24 towers (possibly up to 28 originally). Today the site includes a national museum with finds from Foce del Sele and remains a popular archaeological and coastal destination, with a seaside resort area nearby and a Paestum railway station on the Naples–Salerno–Reggio Calabria line.\\n\\nAccess and context: Paestum can be reached by road via the Agropoli–Battipaglia route, and the nearest airport is Salerno–Pontecagnano (about 30 km away). The modern locality sits to the east of the ancient walls and remains part of Campania’s Cilento region, retaining its cultural landscape alongside contemporary tourism and transport links. \\n\\nIf you’d like, I can tailor this into a shorter concise paragraph or expand any section with more detail.', 'text': 'Paestum\\n\\nancient city, Italy\\n\\nPrint\\xa0Cite\\xa0Share\\xa0Feedback\\xa0\\n\\nAlso known as: Poseidonia\\n\\nWritten and fact-checked by\\xa0\\n\\n\\n\\n\\n\\nThe Editors of Encyclopaedia Britannica\\n\\nLast Updated:\\xa0Article History\\n\\n\\n\\n\\n\\nPaestum: Temple of Apollo\\n\\nSee all media\\n\\nCategory:\\xa0Geography & Travel\\n\\nGreek:\\xa0Poseidonia\\n\\nRelated Places:\\n\\n\\xa0\\n\\nItaly\\xa0ancient Greece\\xa0Basilicata\\n\\nSee all related content →\\n\\nPaestum, Greek\\xa0Poseidonia, ancient city in southern\\xa0Italy\\xa0near the west coast, 22 miles (35 km) southeast of modern\\xa0Salerno\\xa0and 5 miles (8 km) south of the Sele (ancient Silarus) River. Paestum is noted for its splendidly preserved Greek temples.\\n\\n\\n\\n\\n\\nVisit the ruins of the ancient Greek colony of Paestum and discover its history, culture, and society\\n\\nSee all videos for this article\\n\\nPoseidonia was probably founded about 600\\xa0BC\\xa0by Greek colonists from\\xa0Sybaris, along the\\xa0Gulf of Taranto, and it had become a flourishing town by 540, judging from its temples. After many years’ resistance the city came under the domination of the\\xa0Lucanians\\xa0(an\\xa0indigenous\\xa0Italic people) sometime before 400\\xa0BC, after which its name was changed to Paestum. Alexander, the king of Epirus, defeated the Lucanians at Paestum about 332\\xa0BC, but the city remained Lucanian until 273, when it came under Roman rule and a Latin colony was founded there. The city supported\\xa0Rome\\xa0during the\\xa0Second Punic War. The locality was still prosperous during the early years of the Roman Empire, but the gradual silting up of the mouth of the Silarus River eventually created a malarial swamp, and Paestum was finally deserted after being sacked by Muslim raiders in\\xa0AD\\xa0871. The abandoned site’s remains were rediscovered in the 18th century.\\n\\n\\n\\nBritannica Quiz\\n\\nAncient Greece\\n\\n\\n\\n\\n\\nPaestum, Italy: Temple of Athena\\n\\nThe ancient Greek part of Paestum consists of two sacred areas containing three Doric temples in a remarkable state of preservation. During the ensuing Roman period a typical\\xa0forum\\xa0and town\\xa0layout\\xa0grew up between the two ancient Greek sanctuaries. Of the three temples, the\\xa0Temple of Athena\\xa0(the so-called Temple of Ceres) and the Temple of\\xa0Hera\\xa0I (the so-called Basilica) date from the 6th century\\xa0BC, while the Temple of Hera II (the so-called Temple of Neptune) was probably built about 460\\xa0BC\\xa0and is the best preserved of the three. The Temple of Peace in the forum is a Corinthian-Doric building begun perhaps in the 2nd century\\xa0BC. Traces of a Roman amphitheatre and other buildings, as well as intersecting main streets, have also been found. The circuit of the town walls, which are built of travertine blocks and are 15–20 feet (5–6 m) thick, is about 3 miles (5 km) in circumference. In July 1969 a farmer uncovered an ancient Lucanian tomb that contained Greek frescoes painted in the early\\xa0classical style. Paestum’s archaeological museum contains these and other\\xa0treasures\\xa0from the site.'}, {'current_refined_summary': 'Paestum is a coastal frazione of the comune Capaccio Paestum in the Cilento region of southern Campania, Italy, situated on the Tyrrhenian coast about 35 km southeast of Salerno and near the mouth of the Sele River. It preserves the ruins of the ancient Greek city Poseidonia, founded around 600 BCE by Greek colonists from Sybaris and flourishing by the mid-6th century BCE. After centuries of Lucanian control, the city was renamed Paestum; Alexander of Epirus defeated the Lucanians there circa 332 BCE, but it remained Lucanian until Roman rule was established in 273 BCE, when a Latin colony was founded and Paestum prospered in the early Roman Empire. The site was eventually abandoned after the Silarus river silted up, creating malarial swamps, and was sacked by Muslim raiders in AD 871; its remains were rediscovered in the 18th century.\\n\\nThe ancient Greek core comprises two sacred precincts containing three Doric temples in remarkable preservation: the Temple of Athena (often called the Temple of Ceres) and the Temple of Hera I (the Basilica) date from the 6th century BCE, while the Temple of Hera II (the Temple of Neptune) is dated to about 460 BCE and is the best-preserved of the three. In the Roman period a forum and town layout developed between the sanctuaries, and traces of a Roman amphitheatre and other buildings have been found; a Roman temple—often referred to as the Temple of Peace—began in the 2nd century BCE within the forum. The temple architecture is characteristic of Archaic Doric style, with massive columns, pronounced entasis, and limited stone reliefs, and Hera I preserves the best-entablature, with occasional terracotta decoration.\\n\\nThe ancient city covered about 120 hectares, of which roughly 25 hectares have been excavated; the remaining 95 hectares lie on private land. The fortifying polygonal walls enclose roughly 5 km (about 3 miles) in circumference, with four gates and originally around 24–28 towers. Today the site hosts a national archaeological museum with finds from Foce del Sele and includes artifacts such as Lucanian-era frescoes uncovered in 1969. The modern locality sits east of the ancient walls and remains part of Campania’s Cilento region, balancing cultural heritage with contemporary tourism. Paestum is accessible by road via the Agropoli–Battipaglia route, with Paestum railway station on the Naples–Salerno–Reggio Calabria line, and the nearest airport is Salerno–Pontecagnano about 30 km away.', 'text': '16 \\nwho came across the place before the historical Greek settlement was founded.53 Strabo, however, does claim, similarly to Aristotle, that it was the Achaeans who founded Sybaris and he also describes the mother colony, Sybaris, and mentions the name of its founder: Is of Helice.54       The Greeks flourished at Poseidonia for some 200 years. The city enjoyed the status of an autonomous Greek polis and was endowed with a defensive wall with four gates, probably built in phases. Inside the city walls three Doric-style temples were erected in the sixth and fifth centuries. There has been some disagreement on which gods the temples were dedicated too, however, even though within the scope of this study they are referred to as Hera I, Hera II and the Temple of Athena, they might as well have been dedicated to more than one god. A Greek agora was also laid out north of the sanctuary of Hera (Fig. 6). It was adorned with a variety of Greek features; among them a bouleuterion or possible ekklesiasterion.55 An intriguing structure identified as a heroon, a place that has been interpreted as being dedicated to founder of the city, was built on the western edge of the agora around 510-500 BC.56 Outside the walls of the city a possible harbour, its existence and position is however debated, several nekropoleis and extramural cult sites were located; of which one will be the focus of this study: The Sanctuary of Santa Venera south of the city wall. Poseidonia came to enjoy intense cultural and commercial exchange with the rest of the Greek world as well as non-Greek populations like the Etruscans to the north and other Italic tribes from the hinterland. The Etruscan influence combined with the Greek and local Poseidonian style can for example be seen in the very famous fifth century tomb known as Tomba del Tuffatore, the Tomb of the Diver.57 Altogether Poseidonia prospered  and continued doing so. When its mother colony, Sybaris, fell in 510 BC Poseidonia along with other colonies filled the gap as a commercial and cultural centre.58 However, as the fifth century closed, changes loomed on the horizon and the Greek settlement at Poseidonia was to be forever marked by what was to come.   2.1.2. The Lucanian period There were many subdivisions of the Italic population and among them were the Lucanians; an Oscan-speaking people with an already established close contact with the Greek cities of Magna                                                 53 Pedley 1990, 30.  54 Strab1. 6.6.13. 55 Pedley 1990, 79. 56 Pedley 1990, 38-39. 57 Mello 1985, 14. 58 Mello 1985, 14.'}, {'current_refined_summary': 'Paestum is a coastal frazione of the comune Capaccio Paestum in the Cilento region of southern Campania, Italy, situated on the Tyrrhenian coast about 35 km southeast of Salerno near the mouth of the Sele River. It preserves the ruins of the ancient Greek city Poseidonia, founded around 600 BCE by Greek colonists linked to Sybaris (the broader context notes that Sybaris itself had founders such as Is of Helice). The Greeks prospered at Poseidonia for about two centuries, establishing an autonomous polis with a defensive wall, four gates, and substantial urban features.\\n\\nKey historical developments:\\n- The Greek core features three Doric temples (Temple of Athena, Temple of Hera I, Temple of Hera II) dating to the 6th–5th centuries BCE, an agora north of the Hera sanctuary, and a possible heroon on the western edge of the agora (around 510–500 BCE). Etruscan influence and interregional exchange are evidenced by artifacts such as the Tomb of the Diver.\\n- Poseidonia enjoyed intense cultural and commercial exchange with the broader Greek world and with non-Greek Italic populations; after the fall of Sybaris in 510 BCE, Poseidonia continued to flourish as a center of trade and culture.\\n- In respect to Italic dynamics, the site enters a Lucanian period before Roman domination. The Lucanians were later challenged by the rising power of Rome; a Roman presence develops in the late Republican period, with a forum and town plan expanding between the sanctuaries, and a Temple of Peace beginning in the 2nd century BCE.\\n- The city was eventually abandoned due to environmental changes (the Silarus River silted up, producing malarial swamps) and was sacked by Muslim raiders in AD 871. Its ruins were rediscovered in the 18th century.\\n\\nArchaeological and architectural notes:\\n- The ancient city covered about 120 hectares, with roughly 25 hectares excavated; about 95 hectares lie on private land.\\n- The fortifying polygonal walls enclose about 5 km (roughly 3 miles) with four gates and an estimated 24–28 towers.\\n- The Roman phase includes a forum and a developed town layout between sanctuaries, along with traces of a Roman amphitheatre and a temple often called the Temple of Peace (begun in the 2nd century BCE).\\n- The site today houses the national archaeological museum, displaying finds from Foce del Sele, including Lucanian frescoes uncovered in 1969.\\n\\nContemporary context and access:\\n- The modern locality sits east of the ancient walls within Campania’s Cilento region, balancing heritage with tourism.\\n- Paestum is accessible by road (Agropoli–Battipaglia), has Paestum railway station on the Naples–Salerno–Reggio Calabria line, and the nearest airport is Salerno–Pontecagnano about 30 km away.\\n\\nIncorporated additions from the additional document:\\n- The Greek settlement included a formal wall with four gates and a northward agora featuring civic spaces such as a bouleuterion or ekklesiasterion; an early heroon was built around 510–500 BCE on the agora’s edge.\\n- External sites included probable harbours, multiple necropoleis, and extramural cult sites, including the Sanctuary of Santa Venera south of the city walls.\\n- The cultural milieu blended Greek, Etruscan, and local Poseidonian styles, exemplified by iconic tombs like the Tomb of the Diver, and Poseidonia’s role as a bridge between the mother colony Sybaris and other Italic populations.\\n- After Sybaris fell in 510 BCE, Poseidonia continued to prosper, but the broader regional dynamics shifted in the ensuing centuries, leading to Lucanian and then Roman influences before eventual decline.', 'text': '17 \\nGraecia. 59 The Lucanians, the local name for the south Italian Samnite people, occupied the inland area between the Ionian and the Tyrrhenian coast in the fourth century BC. Samnite people were expanding in numbers and in need of new homes, and therefore looked to the prosperous Greek and Etruscan coastal cities. At the end of the fifth century cities like Cumae and Capua had been captured by the Samnites and around 400 BC also Poseidonia came to be under control of the Lucanians.60 This is the traditional interpretation among scholars. However, in the final discussion of this study I hope to nuance this interpretation a bit.  Consequently, there has been a strong belief among many scholars that a “profound cultural change took place in the second half of the fifth century” at Poseidonia as a result of this Lucanian invasion.61 However, recent research has showed us otherwise. It is clear that Poseidonia at some point became a Lucanian city and that this happened gradually and peacefully. Much of the earlier historical interpretation of the Lucanian overtaking of Poseidonia derives from a statement made by Aristoxenos of Tarentum, a pupil of Aristoteles writing in the fourth century BC. He claims that the Greeks were essentially enslaved by the “Tyrrhenians”. This have led scholars to blame the Lucanians for this supposed regression in culture, politics and economy. The “Tyrrhenians” in this case have been interpreted as the Lucanians but it might as well refer to the Romans, Campanians, another Samnite people or the Etruscans; the latter have in fact in ancient literature been generally referred to as “Tyrrhenians”.62 The pessimistic literary evidence concerning the new trends in Poseidonia does, however, not have much support in the archaeological material. The supposed subjugation of the Greeks and the violent conquest of the city may in fact rather be a reflection of Greek attitudes in Tarentum or maybe even part of a larger process going on in Southern Italy at the time: Lucanization.63 But the evidence from Poseidonia suggests that the Greek practises continued; the bouleuterion and the heroon remained in use and so did the Greek sanctuaries and the Greek language.64 Some scholars claim that the change of the Greek name Poseidonia to Paistos or Paistom (later Paestum) can be seen as evidence of a conflict between Greeks and Lucanians, if this renaming happened under the Lucanian rule. The exact time of the change is however unsure, it might as well be a result of the later Roman conquest.65 Pedley does, on the contrary, not agree with the renaming \\n                                                59 Fracchia & Gualtieri 1989, 217. 60 Pedley 1990, 97. 61 Pedley 1990, 97; Horsnaes 2002, 11. 62 Isayev 2007, 17-18. 63 Isayev 2007, 18-19; Zuchtriegel 2016, 14.  64 Pedley 1990, 97. 65 Mello 1985, 15.'}, {'current_refined_summary': 'Final integrated summary\\n\\nPaestum is the coastal settlement (frazione) of Capaccio Paestum in southern Campania, Italy, occupying a Tyrrhenian littoral stretch near the mouth of the Sele River. It preserves the ruins of the ancient Greek city Poseidonia, founded around 600 BCE by Greek colonists linked to Sybaris. The Greek core was a fortified polis with a four-gated wall, urban features, and monumental temples that reflect a flourishing civic culture.\\n\\nKey elements of Poseidonia’s layout and material culture\\n- Architectural core: three Doric temples (Temple of Athena, Temple of Hera I, Temple of Hera II) dating to the 6th–5th centuries BCE, an agora to the north of the Hera sanctuary, and a potential heroon on the agora’s western edge (circa 510–500 BCE). External sites included harbours, multiple necropoleis, and extramural cult spaces such as the Sanctuary of Santa Venera south of the walls.\\n- Civic and cultural life: a bouleuterion/ekklesiasterion and other civic spaces within a formal wall and gate system; a tomb known as the Tomb of the Diver illustrates intercultural exchange with Etruscan and broader Italic contacts.\\n- Interregional ties: sustained intense cultural and commercial exchange with the Greek world and with Italic groups, with Poseidonia continuing to prosper after Sybaris fell in 510 BCE.\\n\\nFrom Greek prosperity to Lucanian and Roman influence\\n- Transition and integration: after the fall of Sybaris, Poseidonia remained a prosperous center, and in the late fifth to early fourth centuries BCE it came under Lucanian (the southern Italic Samnite group) control. Traditional interpretations long asserted a swift, profound Lucanian takeover, but newer scholarship suggests a gradual, peaceful Lucanian influence.\\n- Scholarly nuance on the conquest: Aristoxenos of Tarentum (a later source) framed the shift as a Greek subjugation by “Tyrrhenians,” a term ambiguously identifiable with Lucanians or other groups (Etruscans, Romans, etc.). Archaeological evidence at Poseidonia, however, indicates continuity of Greek practices—bouleuterion, heroon, and sanctuaries remained in use—casting doubt on a violent, abrupt cultural collapse. The question of whether the city’s Greek name Poseidonia was changed to Paistos/Paistom (later Paestum) under Lucanian or later Roman rule remains debated.\\n- Roman transformation and decline: by the late Republican period, Roman influence expands with a developed town plan and a forum between sanctuaries, including a Temple of Peace begun in the 2nd century BCE. Environmental factors—especially siltation of the Silarus River and resulting malarial swamps—contributed to subsequent decline. The site was ultimately sacked by Muslim raids in AD 871.\\n\\nArchaeology, landscape, and modern context\\n- Site footprint and remains: the ancient city covered roughly 120 hectares, with about 25 hectares excavated; approximately 95 hectares lie on private land. The fortifying polygonal walls stretch about 5 km and enclosed a landscape that housed four gates and an estimated 24–28 towers. The Roman phase left a forum and extended town layout between sanctuaries, along with traces of a Roman amphitheatre and the Temple of Peace.\\n- Museums and finds: the on-site national archaeological museum houses finds from Foce del Sele, including Lucanian frescoes uncovered in 1969, highlighting the hybrid cultural milieu of Poseidonia.\\n- Modern accessibility: Paestum Today sits east of the ancient walls in the Cilento area. It is accessible by road (via the Agropoli–Battipaglia corridor), has Paestum railway station on the Naples–Salerno–Reggio Calabria line, and the nearest airport is Salerno–Pontecagnano (about 30 km away).\\n\\nIntegrated nuance from the additional document\\n- The shift from Greek to Lucanian control was likely gradual rather than a sudden conquest, and Greek institutions (bouleuterion, heroon) persisted well into the Lucanian period.\\n- The debated renaming from Poseidonia to Paestum (or Paistos/Paistom) may reflect political changes, but the timing and significance of any such renaming remain uncertain; some scholars doubt a straightforward, violent Greek-to-Lucanian renaming scenario.\\n- The broader southern Italian context (Tarentum’s influence, Isayev’s and Pedley’s discussions, and the idea of “Lucanization”) informs interpretations of Poseidonia’s cultural continuity and transformation.\\n\\nIn short, Poseidonia/Paestum began as a flourishing Greek polis with notable temples and civic spaces, maintained substantial intercultural exchanges, experienced a scholarly-debated Lucanian influence that appears gradual and non-catastrophic to its Greek practices, and later developed under Roman rule before environmental decline and eventual rediscovery in modern times.', 'text': '18 \\nand states that the city continued to be called Poseidonia during the Lucanian period.66 In the present study I too will continue to use the name Poseidonia, in line with most scholars.       During the fourth century BC and up to the establishing of the Latin colony in 273 BC Poseidonia prospered as revealed in the archaeological record. Although there were no major large-scale building programmes to match the constructions of the Greek temples and sanctuaries those places continued to be looked after and the gods were worshiped by the new inhabitants.67 However, two stoai were built at the Greek agora as well as an Asklepieion (Table). The changes that came along with the Lucanians are to be seen in the agriculturalization and the density of settlement of the territory of Poseidonia as well as new burial practices in terms of extraordinary decorations.68   2.1.3. The Latin colony In 273 BC the expanding city of Rome had reached past the river Sele and stood at the gates of the Greek/Lucanian city of Poseidonia. Rome had been expanding for years, and the Republic was founding colonies, ex novo or, in the case of Poseidonia-Paestum, taking over already established settlements, all over the Italian peninsula. The Roman colonies, perhaps especially the ones that were founded during the late Republic, were behaving in a strikingly uniform way. The Roman, or the Latin, colony, is well known for its formulaic way of structure and features; in other words, we know the nature of a Roman colony without having to see one. The foundation ritual has been described in ancient literary sources and is said to originate from the time of Rome’s mythological foundation when Romulus, 753 BC, with permission of the gods laid out the sacred boundary, pomerium, around the city.69 The founding ritual of the colonies is describes by Bispham in the article ‘Coloniam deducere: how Roman was the Roman colonisation during the middle Republic?’:   Firstly, the deductio, or marching out, of the colonists from Rome to the site of the colony; the deductor (founder), in ritual dress (the cinctus Gabinus), ploughs the sulcus primigenius (the original furrow), tracing the line of the future walls and instantiating a ritual barrier, the pomoerium.70    In other words, it is clear that there was a model for Roman colonization and that the newly founded colonies were using the same set of rules and rituals to express their relationship, as                                                 66 Pedley 1990, 97.  67 Pedley 1990, 112. 68 Pedley 1990, 97. 69 Plut. Vit. Rom. 11.1-4. 70 Bispham 2006, 74.'}, {'current_refined_summary': 'Final integrated summary\\n\\nPoseidonia, the Greek-founded polis at the Tyrrhenian littoral near the mouth of the Sele River, is typically identified with the later Roman fortress-town of Paestum. The refined view synthesized here regards Poseidonia as a flourishing Greek urban center from its 7th–6th century BCE origins, with a well-defined architectural core and extensive intercultural exchange that persisted into the Lucanian and early Roman periods.\\n\\nKey elements of Poseidonia’s early core and material culture\\n- Urban and sacred framework: A fortified Greek polis with a four-gated wall, an agora to the north of the Hera sanctuary, the Temple of Athena, and two additional temples (Temple of Hera I and Temple of Hera II) dating to the 6th–5th centuries BCE. Monumental temples and civic spaces reflect a prosperous urban culture.\\n- Civic life and cult practice: A bouleuterion/ekklesiasterion within the defended area, a formal gate system, and sanctuaries that sustained public cult. The Tomb of the Diver exemplifies intercultural exchange with Etruria and other Italic contacts.\\n- Interregional exchange: Ongoing cultural and commercial ties with the Greek world and Italic groups helped Poseidonia prosper even as broader rivalries evolved in southern Italy.\\n\\nFrom Greek prosperity to Lucanian influence\\n- Lucanian period and continuity: After the fall of Sybaris, Poseidonia remained prosperous and, in the 4th century BCE up to 273 BCE, came under Lucanian influence. Recent interpretation emphasizes a gradual, less violent integration rather than abrupt conquest.\\n- Lucanian signatures in the urban fabric: While Greek sacred spaces and practices persisted (including the bouleuterion, heroon, and sanctuaries), the landscape shows changes typical of Lucanian incorporation—agricultural intensification, higher settlement density in the territory, and new burial practices with heightened decorative elements.\\n- Naming and identity: For purposes of scholarly use, Poseidonia remains the widely used toponym during the Lucanian period, with debates about renaming (e.g., to Paistos/Paistom) remaining unsettled.\\n\\nThe Latin colony and Roman transformation\\n- Roman incursion and colonization: In 273 BCE Rome established a Latin colony at Poseidonia, integrating an already thriving Greek/Lucanian settlement into the Roman imperial colonization pattern.\\n- Roman colonial formula: The Latin colony followed a familiar model, including the deductio ritual—founders marching from Rome, the cinctus Gabinus in ritual dress, the ploughing of the sulcus primigenius, and the formal delineation of the pomoerium, signaling the boundary and new political order. This reflects a standardized Roman approach to founding colonies in the mid-republican era.\\n- Continuity within change: Even as a Roman colony, Poseidonia retained much of its Greek/Lucanian sacred layout, including sanctuaries and civic spaces. The Roman phase also left a developed town plan with a forum between sanctuaries and evidence of a Temple of Peace begun in the 2nd century BCE.\\n\\nDecline, landscape, and modern rediscovery\\n- Environmental and imperial pressures: Environmental factors—most notably siltation of the Silarus River causing malarial swamps—contributed to long-term decline, even as the site remained occupied and reorganized under successive rulers.\\n- Post-antique trajectory: The site suffered sackings (notably by Muslim raids in AD 871) and entered a long arc of obscurity before its modern rediscovery and archaeology.\\n- Archaeology, landscape, and museums: Today, the ancient city covered roughly 120 hectares, with about 25 hectares excavated and a substantial portion on private land. The fortifying walls stretch some 5 km with multiple gates and towers. An on-site national archaeological museum houses finds from Foce del Sele, including Lucanian frescoes that illuminate a hybrid cultural milieu. Paestum Today sits to the east of the ancient walls, with accessible road, rail, and a nearby airport (Salerno–Pontecagnano).\\n\\nIntegrated nuance from the additional document\\n- Naming and continuity: The city is treated as Poseidonia in the Lucanian period, aligning with a broad scholarly consensus and reinforcing the sense of cultural continuity rather than a sharp Greek-to-Lucanian rupture.\\n- Lucanian impact: Lucanian influence is seen in demographic and settlement dynamics and new burial practices, rather than through sweeping architectural programs or the replacement of Greek religious life.\\n- Latin colonization ritual: The colonization process is described in detail as a ritualized, replicable pattern (deductio, ploughing, pomoerium) that underpinned Roman expansion into existing urban networks, including Poseidonia.\\n\\nIn short, Poseidonia/Paestum began as a prominent Greek polis with notable temples and civic spaces, maintained substantial intercultural exchanges through the Lucanian era, experienced gradual Lucanian integration without wholesale cultural collapse, and later transformed under Roman colonial patterns before environmental decline and eventual rediscovery in modern times. The ongoing scholarly emphasis on continuity of Greek institutions during Lucanian influence, and the canonical Roman colonization ritual, helps explain the city’s resilient yet evolving urban character across centuries.', 'text': '19 \\nwell as their obedience and loyalty to their mother colony: Rome.71 However, Poseidonia, renamed Paestum after the founding of the Latin colony inside its walls, being an early example of Roman colonization as well as an already established city with all its functions and features, this ‘model of colonization’ cannot be applied in the same way. As the following analysis of Poseidonia-Paestum will show, Rome was the model for the colony’s political system. The rôle of the city was, however, adapted to fit its purposes as a colony as well as a product of new and previous influence and it was thus not a direct replica.72       After the founding of the Latin colony the city was altered radically (Table). The Greek/Lucanian agora ceased to be in use and instead a Roman forum was laid out in the southern part of the old agora. Traditional Roman buildings, especially those relating to political and juridical aspects, were constructed at the new forum and simultaneously the buildings with similar functions at the agora were demolished. The sanctuaries, however, remained in use, both the intramural and the extramural. They were respected by the new settlers and continued to be objects of worship.73 A striking continuity of divine worshipping is analysed in detail in the further analysis of the Sanctuary of Santa Venera.      The bonds with the mother colony, the city of Rome, were strong; both in a juridical and political sense as well as affectional. Paestum supported Rome in times of need and aligned itself with its mother colony politically and diplomatically. When the Carthaginian general Hannibal was roaming around southern Italy during the second Punic War, 218-201 BC, and literally breathing down the necks of the Paestans, the city still remained loyal to Rome. However, the many wars and the feeling of unsafety these times must have given rise to might have been a hard blow on the Paestan society. That said, it is a well-known fact that nothing binds a society together like a common enemy, and Paestum was thus rewarded for its loyalty. A certain degree of autonomy was given to the city and also the privilege of striking its own coins.74 Thus, Rome continued to be a strong influencer on the Paestan society although it is evident, which is shown in the further analysis of some aspects of the nature of Roman influence, that the city never forgot its Greek and Lucanian roots. In 133 the via Popilia, running to the east of Paestum, was constructed and as a result of this the city was unfortunately cut off from principal routes connecting the city to the rest of the peninsula.75                                                            71 Bispham 2006, 73-74. 72 Sewell 2010, 86. 73 Pedley 1990, 113. 74 Pedley 1990, 113. 75 Pedley 1990, 113-114.'}, {'current_refined_summary': 'Integrated final summary (incorporating the current refined summary with key points from the additional document)\\n\\nPoseidonia/Paestum traces a long arc from a flourishing Greek urban center to a Lucanian-influenced city and finally to a Roman colonial town, with continuity in sacred spaces and intercultural exchange tempered by strategic political remodeling under Rome.\\n\\n1) Early core and material culture (7th–5th centuries BCE)\\n- Urban and sacred framework: A fortified Greek polis with a four-gated wall, an agora north of the Hera sanctuary, the Temple of Athena, and the two Hera temples (I and II). Monumental temples and civic spaces signal a prosperous urban culture.\\n- Civic life and cult practice: Bouleuterion/ekklesiasterion within the defended area, formal gate systems, and sanctuaries sustaining public cult. The Tomb of the Diver exemplifies intercultural exchange with other Italic and Etruscan worlds.\\n- Interregional exchange: Ongoing ties with the Greek world and Italic groups support prosperity amid southern Italian rivalries.\\n\\n2) Greek prosperity to Lucanian influence\\n- Lucanian period and continuity: Following the fall of Sybaris, Poseidonia remains prosperous and comes under Lucanian influence from the 4th century BCE to around 273 BCE, interpreted as a gradual integration rather than a sudden conquest.\\n- Lucanian signatures in the urban fabric: Greek sacred spaces (bouleuterion, heroon, sanctuaries) persist, while the landscape shows Lucanian incorporation—agricultural intensification, higher settlement density, and new burial practices with increased decorative elements.\\n- Naming and identity: Poseidonia remains the widely used toponym during the Lucanian period, with debates about renaming remaining unsettled.\\n\\n3) Roman colonization and transformation\\n- Roman incursion and colonization: In 273 BCE Rome establishes a Latin colony at Poseidonia, integrating the Greek/Lucanian settlement into the Roman imperial system.\\n- Roman colonial model and urban reorganization: Rome acts as model but adapts the pattern to fit colonial purposes; a Roman forum is laid out in the southern part of the old agora, and traditional Greek/juridical structures in the agora are demolished or replaced. Sanctuaries remain in use (intramural and extramural) and continue to be objects of worship, preserving religious continuity.\\n- Political and material continuity with change: The city retains much of its sacred layout, while new political buildings cluster around the forum. A Temple of Peace begins in the 2nd century BCE, and Paestum maintains strong ties with Rome, including a degree of autonomy and the right to mint coins.\\n- Diplomatic and military alignment: Paestum demonstrates loyalty to Rome during crises (e.g., Hannibal’s campaigns in the Second Punic War) and aligns politically and diplomatically with Rome, illustrating a hybrid identity that preserves Greek/Lucanian roots within a Roman framework.\\n- River-route disruption: In 133 BCE, the via Popilia to the east of Paestum alters connectivity by cutting off principal routes to the peninsula, reshaping its regional integration and communications.\\n\\n4) Decline, landscape, and modern rediscovery\\n- Environmental and imperial pressures: Siltation of the Silarus River leading to malarial swamps contributes to long-term decline, even as settlement persists under successive rulers.\\n- Post-antique trajectory: The site experiences sackings (notably by Muslim forces in AD 871) and enters a long period of obscurity before modern rediscovery and archaeology.\\n- Archaeology, landscape, and museums: The ancient city covered roughly 120 hectares, with about 25 hectares excavated; walls extend ~5 km with multiple gates and towers. A national archaeological museum at the site houses finds from Foce del Sele, including Lucanian frescoes illuminating a hybrid cultural milieu. Paestum today lies to the east of the ancient walls, with accessible road, rail, and a nearby airport (Salerno–Pontecagnano).\\n\\nIntegrated nuance from the additional document\\n- Naming and continuity: The Lucanian-period city is treated as Poseidonia, reinforcing cultural continuity rather than a sharp Greek-to-Lucanian rupture.\\n- Lucanian impact: Lucanian influence appears in demographic and settlement dynamics and burial practices, rather than through wholesale architectural overhauls or replacement of Greek religious life.\\n- Latin colonization ritual: The colonia’s founding follows a ritualized pattern (deductio, ploughing of the sulcus primigenius, delineation of the pomoerium) that underpins Roman expansion into existing urban networks, including Poseidonia.\\n\\nIn short, Poseidonia/Paestum begins as a prominent Greek polis with a defined architectural core, sustains intercultural exchange into the Lucanian era, undergoes gradual Lucanian integration without wholesale cultural collapse, and is transformed under Roman colonial patterns while retaining essential Greek and Lucanian sacred and urban features. The combination of continuity in religious life with a clear Roman urban remodeling—coupled with environmental decline and eventual modern rediscovery—frames the city’s resilient yet evolving urban character across centuries.', 'text': 'Paestum. Greek colony in Italy, south of Naples, of which a group of ruined Doric temples survives (c.530bcâ€“c.460 bc). This Doric Order has the most exaggerated entasis of any Antique example, and the very wide squat capitals on top of the shafts emphasize the primitive effect. The Paestum Order was much admired by Neo-Classical architects in C18 and C19, and was used where powerful effects were sought.\\n\\nBibliography\\n\\nJ. Curl (2001);\\nDinsmoor (1950);\\nC. Normand (1852);'}]}\n"
     ]
    }
   ],
   "source": [
    "full_summary = refine_summary(all_docs)\n",
    "print(full_summary)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
