"Related Content" Sections
A user just finished reading an insightful blog post, watching an engaging video, or browsing a compelling article on your platform. What happens next? Ideally, they seamlessly discover another piece of relevant content that captures their interest, keeping them engaged, increasing their time on site, and deepening their relationship with your platform. This is the power of an effective "Related Content" section (often labeled "You Might Also Like," "Keep Reading," or "Up Next").
However, many platforms struggle here. They rely on simplistic methods like matching basic tags, showing content from the same author/category, or resorting to generic popularity lists. These approaches often fail to capture the nuanced semantic relationships between content pieces or understand the user's underlying interests, leading to irrelevant suggestions and missed opportunities for continued engagement. Building a system that truly understands content similarity and surfaces compelling related items is a significant technical challenge.
The Shaped Approach: Simplified Content Similarity using similar_items
Building an effective related content engine often involves stitching together disparate systems for data processing, NLP, collaborative filtering, testing and iteration. Shaped offers a radically simpler solution with its dedicated similar_items
endpoint, powered by sophisticated models that automatically learn deep content relationships.
Shaped's models analyze both your content metadata (understanding semantic meaning) and user interaction patterns (understanding behavioral context) simultaneously. The similar_items
endpoint provides direct access to this unified understanding of relatedness.
How Shaped Streamlines Related Content Recommendations:
- Unified Data Integration: Connect your content metadata and user interaction data using Shaped's connectors.
- Automated Model Training: Shaped handles the training of advanced models (like Transformers) that learn nuanced semantic and behavioral similarities automatically, eliminating the need for manual NLP feature engineering or separate collaborative filtering pipelines.
- Dedicated
similar_items
API: A single API call retrieves a list of content items deemed most similar to a given content ID, based on the model's comprehensive understanding. - Contextual Similarity (Optional): Optionally include a
user_id
in the API call to allow Shaped to potentially subtly adjust the relatedness based on the specific user's profile, though item-to-item similarity remains the core driver. - Managed Infrastructure: Shaped manages all the underlying infrastructure for model training, low-latency serving, and scalability.
Building a "Related Articles" Section with Shaped
Let's illustrate using Shaped's similar_items
endpoint to populate a "Keep Reading" section on an article page.
Goal: When a user is reading ARTICLE_ID_123
, display the 5 most closely related articles.
1. Ensure Data is Connected: Assume content_metadata
(with fields like article_id
, title
, body_text
or summary
, tags
, category
) and user_interactions
(views, clicks on related items) datasets are connected to Shaped.
2. Define Your Shaped Model (YAML): A standard model definition is typically used. Ensure text fields and relevant metadata are included for the model to learn from.
model:
name: content_discovery_engine
connectors:
- type: Dataset
name: content_metadata
id: content
- type: Dataset
name: user_interactions
id: interactions
fetch:
items: |
SELECT
article_id AS item_id, -- Map your content ID to item_id
title,
body_text, -- Important for semantic understanding
tags,
category,
publish_date,
content_url
FROM content
events: |
SELECT user_id, article_id AS item_id, timestamp AS created_at, event_type
FROM interactions
3. Create the Model:
shaped create-model --file content_similarity_model.yaml
4. Monitor Training: Wait for the model content_discovery_engine
to become ACTIVE
.
shaped view-model --model-name content_discovery_engine
5. Fetch Related Content (Application Backend Logic): When rendering the page for ARTICLE_ID_123
:
- Step A (Your Backend): Identify the
item_id
('ARTICLE_ID_123'
) of the content being viewed. Optionally, get theuser_id
if available. - Step B (Your Backend): Call Shaped's
similar_items
API endpoint.
- Python
- JavaScript
const { Shaped } = require('@shaped/shaped');
const shapedClient = new Shaped();
const modelName = 'content_discovery_engine';
const currentArticleId = 'ARTICLE_ID_123';
const currentUserId = 'USER_XYZ'; // Optional: null/undefined if anonymous
const numRelatedItems = 5;
const response = await shapedClient.similarItems({
modelName: modelName,
itemId: itemId,
userId: userId,
limit: numRelatedItems,
returnMetadata: true
});
console.log(`Found ${response.metadata.length} related items for ${itemId}`);
from shaped import Shaped
shaped_client = Shaped()
model_name = 'content_discovery_engine'
current_article_id = get_item_id('ARTICLE_ID_123')
current_user_id = get_user_id('USER_XYZ') # Optional: None if anonymous
num_related_items = 5
response = shaped_client.similar_items(
model_name=model_name,
item_id=current_article_id,
user_id=current_user_id, # Provide if available for context
limit=num_related_items,
return_metadata=True # Get title, url, image etc. for display
)
print(f"Found {len(response.ids)} related items for {current_article_id}")
- Step C (Your Frontend): Use the list of related content items (containing titles, URLs, images, etc. from the metadata) to render the "Related Content" section.
Conclusion: Turn Single Views into Engaging Sessions
Providing genuinely relevant related content is key to increasing user engagement, session duration, and content discovery on any platform. Building this capability from scratch requires navigating the complexities of NLP, collaborative filtering, hybrid modeling, and low-latency serving infrastructure.
Shaped simplifies this process dramatically with the similar_items
endpoint. By leveraging powerful, automatically trained models that understand deep semantic and behavioral connections between content pieces. Shaped allows you to integrate highly relevant "Related Content" sections with a simple API call. Spend less time wrestling with ML infrastructure and more time creating the great content your users love.
Ready to boost content discovery and keep users engaged longer?
Request a demo of Shaped today to see how similar_items
can enhance your content platform. Or, start exploring immediately with our free trial sandbox.