This guide explains how to enable and configure the Related Topics feature, which is part of the Embeddings module in the Discourse AI plugin.
Required user level: Administrator
The Related Topics feature helps users discover relevant content by suggesting semantically similar topics based on the one they’re currently reading. This enhances content exploration and increases user engagement.
Summary
- Enable the Related Topics feature in your Discourse site settings
- Configure the feature based on your hosting setup (Discourse-hosted or self-hosted)
- Understand how the feature works and its benefits for your community
Prerequisites
For Discourse-hosted customers
If your site is hosted by Discourse, the Embeddings feature is provided for you using an open-source model. No additional setup is required.
For self-hosted instances
Self-hosted Discourse instances need to provide their own Embeddings through a third-party API key. You can choose from the following options:
- OpenAI
- Azure OpenAI
- Self-hosted Embeddings
- Cloudflare Workers AI
- Google Gemini
For detailed instructions on setting up these services, refer to their respective configuration guides.
Enabling and configuring related topics
- Go to Admin → Settings → Plugins
- Search for “discourse-ai” and ensure it’s enabled
- Enable
ai_embeddings_enabled
to activate the Embeddings module - Enable
ai_embeddings_semantic_related_topics_enabled
to activate the Related Topics feature
Additional configuration
Depending on your setup, you may need to adjust the following settings:
- For non-English sites (Discourse-hosted or self-hosted with own model):
Setai embeddings model
tomultilingual-e5-large
- For Cloudflare Workers AI:
Setai embeddings model
tobge-large-en
- For OpenAI or Azure OpenAI:
Setai embeddings model
totext-embedding-ada-002
How related topics work
When a user visits a topic, Discourse queries the database for the most semantically similar topics based on their embedded representations. These related topics are then presented to the user, encouraging further exploration of the community’s content.
Related topics example
Features
- Semantic textual similarity: Goes beyond keyword matching to find truly related content
- Toggle between “Suggested” and “Related” topics
- Available for both anonymous and logged-in users
FAQs
Expand to view a diagram of the related topics architecture
The overview is, that when a topic is created / updated this happens:
sequenceDiagram
User->>Discourse: Creates topic
Discourse-->>Embedding Microservice: Generates embeddings
Embedding Microservice-->>Discourse:
Discourse-->>PostgreSQL:Store Embeddings
And during topic visit:
sequenceDiagram
User->>Discourse: Visits topic
Discourse-->>PostgreSQL: Query closest topics
PostgreSQL-->>Discourse:
Discourse->>User: Presents related topics
Q: How is topic/post data processed?
A: For Discourse-hosted sites, data is processed within our secure virtual private datacenter. For self-hosted sites, data processing depends on your chosen third-party provider.
Q: Where is the embeddings data stored?
A: Embeddings data is stored in your Discourse database, alongside other forum data like topics, posts, and users.
Q: What semantic model is used, and how was it trained?
A: Discourse-hosted sites use the all-mpnet-base-v2 model by default. This model performs well for both niche and general communities. Self-hosted sites may use different models depending on their chosen provider.
Additional resources
- Discourse AI
- Discourse AI - Embeddings
- Install plugins on a self-hosted site
- Configure API Keys for OpenAI
- Configure API Keys for Azure OpenAI
- Self-Hosting Embeddings for DiscourseAI
- Configure API Keys for Cloudflare Workers AI
- Configure API Keys for Google Gemini
Last edited by @hugh 2024-08-06T04:30:54Z
Last checked by @hugh 2024-08-06T04:30:59Z
Check document
Perform check on document: