When our team set out to map 75 years of Italian literary excellence into a digital recommendation engine, we didn't expect the Premio Strega dataset to become a crash course in multilingual NLP resilience, stale cache invalidation. And the surprising brittleness of sentiment models trained on Twitter.

The Premio Strega is Italy's most prestigious literary prize, awarded annually since 1947. To a technologist, its archive-winners, shortlists, author biographical notes, critical judgments-represents a high-value, semi-structured textual corpus. For our client, a European media group launching a "books you might love" feature, building a pipeline that could parse and recommend from this corpus meant confronting messy real-world data: OCR artifacts from 1950s press clippings, inconsistent metadata schemas. And domain-specific italian prose that standard off-the-shelf NLP models handled poorly. This article walks through the full-stack engineering decisions we made, the open-source tools we leaned on. And the architectural trade-offs that turned a literary prize into a production-grade recommendation system.

We'll cover data ingestion with Apache Airflow, constructing a custom spaCy pipeline for Italian literary text, fine-tuning a Hugging Face model for literary sentiment. And serving low-latency recommendations via FastAPI and Redis. Along the way, we'll share monitoring strategies, evaluation metrics like perplexity and BLEU for generation tasks. And hard-won lessons about drift in cultural data.

Why the Premio Strega Became the Ideal NLP Stress Test

The Premio Strega corpus spans seven decades, starting with Ennio Flaiano's Tempo di uccidere (1947) and continuing through recent winners like Mario Desiati's Spatriati (2022). The raw material not only includes book titles and author names but jury statements, press reviews published in national newspapers, and often full-text excerpts digitized via OCR. This temporal depth and heterogeneous quality make it an excellent testbed for real-world NLP pipelines that must handle language evolution - typographical noise. And subtle shifts in literary fashion.

In production environments, you rarely work with clean, curated datasets like IMDb reviews. The Premio Strega dataset, gleaned from public cultural archives and the official Fondazione Bellonci website, forced us to confront tokenization edge cases (pre-1970s orthographic conventions, regional diacritics), entity disambiguation (the author Luigi Pirandello appears in jury discussions but never won). And the absence of explicit user-rating signals. Instead of collaborative filtering, we had to build a content-based recommender anchored in semantic embeddings derived from literary prose-a task far more nuanced than clustering Amazon product descriptions.

Old Italian library shelves filled with literary classics

Data Acquisition and Ingestion: From Web Scraping to Airflow DAGs

Our first challenge was assembling a clean, versioned dataset. The Fondazione Bellonci pages provide HTML tables of winners. But shortlist and jury commentary data is scattered across news portals. We wrote Scrapy spiders that respected robots txt, crawling archival pages with polite delays and extracting structured fields via XPath selectors. To handle the frequent layout changes, we used item loaders with fallback selectors and validated output schemas with Pydantic models.

Ingestion runs were orchestrated through an Apache Airflow 2. 7 Directed Acyclic Graph (DAG) running on a managed Kubernetes cluster. The DAG was split into four stages: scrape raw HTML and store in an S3-compatible bucket, parse and clean text using a PythonOperator that normalized Unicode (NFKC normalization via the unicodedata module) and stripped OCR artifacts, transform into a relational schema for author/work/book entities. And finally emit events into a Kafka topic for downstream processing. Each stage used Airflow's ShortCircuitOperator to abort early if upstream tasks returned zero records, preventing empty data from poisoning our models. You can see similar patterns in our guide to building resilient data pipelines with Airflow.

We scheduled the DAG to run weekly, incrementally ingesting new content around the annual Premio Strega announcement in July. The raw corpus grew to roughly 1. 2 million tokens after cleaning, spanning 75 winning novels and over 300 shortlisted works with metadata.

Normalizing Italian Literary Language with a Custom spaCy Pipeline

Generic NLP models struggle with literary text: long sentences, poetic inversions. And archaic vocabulary. The spaCy Italian model it_core_news_lg (trained on news and web text) frequently mis-tagged named entities in post-war novels. For example, the word "Resistenza" (Resistance) was labeled as an organization when used metaphorically. We needed a pipeline that understood 20th-century Italian prose.

We built a custom spaCy pipeline by adding a rule-based entity ruler on top of the transformer-based model it_core_news_trf. The entity ruler used a gazetteer of Premio Strega-related entities: all winning authors, recurring jury members. And literary movements like "Neorealismo. " We also integrated a custom attribute ruler that normalized lemma forms for archaic verb conjugations, preventing embedding distortions. The pipeline was packaged as a wheel and versioned in a private PyPI repository, enabling reproducible builds in CI/CD.

To validate tokenization, we manually annotated a small gold standard of 5,000 tokens from five decades of text. Our pipeline achieved 96. 3% token accuracy and 89% named entity F1 on literary NER-an improvement of 12 points over the out-of-the-box model. These metrics were tracked via an MLflow experiment dashboard, ensuring we could quickly detect regressions when updating the base model.

Fine-Tuning a BERT-Based Sentiment Model for Literary Prose

Off-the-shelf sentiment analyzers, trained on product reviews and social media, catastrophically misinterpret literary affect. A sentence like "La guerra aveva reso l'amore un ricordo sbiadito" ("The war had made love a faded memory") was labeled 72% positive by a popular Hugging Face model, because "amore" (love) carries positive valence in short-text corpora. We needed a model that understood nuanced emotional arcs in narrative prose.

We curated a fine-tuning dataset of 8,000 sentence-level annotations drawn from Premio Strega winners and shortlisted works. Annotators-bilingual Italian literature graduates-labeled each sentence with a 5-point scale from strongly negative to strongly positive, plus a "literary irony" flag. We then fine-tuned xlm-roberta-base (chosen for its multilingual pre-training) using the Hugging Face Trainer API with a regression head, optimizing mean squared error. Training ran on a single A10G GPU for 3 epochs, with a learning rate of 2e-5 and linear warmup.

We evaluated the model on a held-out test set of 1,200 sentences, achieving a Spearman correlation of 0. 81 with human ratings, versus 0. 43 for the baseline model. Importantly, we stored the model in the Hugging Face Hub under a private organization and served it via a FastAPI microservice, with ONNX runtime acceleration to keep p99 latency under 120ms. This microservice became a core component of our recommendation engine, aware that a book's emotional trajectory (e g., from despair to hope) mattered more than an average sentiment score.

Topic Modeling Across Decades to Capture Literary Evolution

To allow users to explore the Premio Strega corpus by theme-say, "post-war existentialism" or "migration narratives"-we trained a contextual topic model using BERTopic. By embedding each novel's chapters (or substantial excerpts) with sentence-transformers and clustering with HDBSCAN, we induced topics that corresponded remarkably well to literary movements identified by scholars.

We validated the topics by computing coherence scores (c_v metric) and manually inspecting the top 20 terms. Topics like "famiglia e provincia" (family and small-town life) surfaced prominently in the 1960s. While "identitΓ  e migrazione" (identity and migration) grew from the 1990s onward. To make these trends explorable, we built a Streamlit-based internal dashboard that plotted topic prevalence over time, enabling editors to curate thematic collections. The dashboard hooked Directly into our PostgreSQL database. Where we stored per-book topic vectors and associated term scores.

One surprise: the model struggled with highly poetic works that lacked conventional sentence breaks. We remedied this by pre-segmenting texts into sliding windows of 128 tokens with 50% overlap before embedding, ensuring enough context for the clustering algorithm to latch onto coherent themes.

Engineering the Recommendation Engine: Embeddings, Redis. And Real-Time Scoring

With rich features-NER entities, sentiment arcs. And topic vectors-we built a content-based recommendation system. For each book, we computed a 768-dimensional embedding by concatenating several derived vectors: a mean-pooled transformer encoding from distiluse-base-multilingual-cased, normalized topic distribution. And aggregated sentiment trajectory features. We then indexed all books into a FAISS index for approximate nearest neighbor search, using inner product similarity after L2 normalization.

The serving layer used a FastAPI application fronted by Nginx. On receiving a user request with a book ID, the API fetched the query embedding from Redis (cached with a 1-hour TTL), performed FAISS lookup. And applied a diversity re-ranking algorithm to avoid returning six novels by the same author. Redis caching was critical: recalculating embeddings on the fly added 180ms latency, while the cached path kept p95 under 40ms. We instrumented the service with Prometheus metrics and Grafana dashboards, monitoring cache-hit ratios and FAISS query latencies. For more on caching patterns, see our caching strategies for ML-backed APIs article,

Code editor showing Python script for recommendation algorithm

Frontend Architecture: Surfacing Literary Data with Next js and React

The consumer-facing side was a Next, and js 14 application using the App RouterWe built server-side rendered pages for each Premio Strega winner, complete with an interactive sentiment timeline generated by re-rendering our model's sentence-level predictions with D3. js. The recommendation carousel used React Query for data fetching and stale-while-revalidate strategies to keep the UI snappy.

We placed a strong emphasis on progressive enhancement: the core content (book summaries, author bios) was rendered as static HTML at build time via Incremental Static Regeneration, ensuring accessibility and SEO even if JavaScript failed. The interactive charts and recommendation widgets were hydrated on the client only after the main content was ready. This architecture also simplified CDN caching; we used Cloudflare's edge cache with a custom cache key that included the user's locale. Since the platform supported Italian and English.

User behavioral events-clicks on recommendations-were streamed via a lightweight endpoint to a Kafka topic, then processed by a Flink job that updated implicit feedback scores, used to refine the recommendation model monthly. This closed feedback loop allowed the system to gradually align with actual user preferences while still respecting the editorial weight of the Premio Strega selections.

Observability and Data Drift: Why Literary Time Series Are Tricky

Our team implemented a full observability stack using OpenTelemetry traces, structured logging with Loguru and a custom data drift detector built on Alibi Detect. The drift detector compared weekly embedding distributions against a baseline corpus from initial ingestion. During the annual Premio Strega award week, traffic spiked 500%. And newly ingested jury statements from contemporary critics showed a markedly different vocabulary distribution, triggering a drift alert.

Initially, we panicked and rolled back the model. After analysis, we realized the shift was legitimate-literary criticism language evolves. And our model needed to adapt. We adjusted the drift threshold

.

Need a Custom App Built?

Let's discuss your project and bring your ideas to life.

Contact Me Today β†’

Back to Online Trends