PitchHut logo
django-neural-feed
Personalized content recommendations made easy with Django.
Pitch

Django Neural Feed (DNF) is an advanced Django app for creating tailored content feeds using semantic vector embeddings. By utilizing PostgreSQL's pgvector, it computes similarity seamlessly while offering customizable metrics for user engagement. DNF’s object-oriented architecture simplifies feed configurations and ensures robust performance whether in asynchronous or synchronous setups.

Description

Django Neural Feed (DNF) is an innovative Django application that creates personalized content recommendation feeds utilizing advanced AI technology. By harnessing the power of PostgreSQL’s pgvector extension, DNF computes vector similarity directly within the database, integrating customizable metrics for content freshness and popularity into a streamlined SQL query.

With its object-oriented design, DNF allows for easy configuration through specialized Feed classes that maintain separation of logic and enhance maintainability. The framework monitors user interactions discreetly via Django signals while providing flexible deployment options, accommodating both asynchronous and synchronous execution to ensure robust performance under varying conditions.

Key Features

  • Object-Oriented Feed Configuration: Create isolated, multi-tenant recommendation feeds by subclassing the BaseNeuralFeed class for clear organization and flexibility.
  • Asynchronous Processing: Efficiently manage embedding generation and vector aggregation with Celery, complete with a fallback system to synchronous threads to maintain continuity when necessary.
  • Dedicated User Profiles: Maintain vector profiles in an isolated UserFeedProfile model, enabling organized and scalable user interaction processing without cluttering the core Auth User table.
  • Hybrid Scoring Mechanism: Combine pgvector's cosine distance, content recency, and user-driven popularity metrics into a single, optimized database-level scoring annotation.
  • Non-Invasive Integration: Easily enhance existing content models with recommendation functionalities, requiring minimal changes to database migrations while keeping interaction tables intact.

Quick Start

Setup involves three simple steps to enable DNF in a Django project:

  1. Configure Your Content Model: Utilize the NeuralRecommendMixin to embed vector representation in content models.
    from django.db import models  
    from django_neural_feed.mixins import NeuralRecommendMixin  
    class Post(NeuralRecommendMixin, models.Model):  
        title = models.CharField(max_length=255)  
        content = models.TextField()  
    
  2. Define a Custom Feed Class: Create a robust feed system encapsulating thresholds, scoring, and logic for interactive enhancements.
    from django_neural_feed.feeds import BaseNeuralFeed  
    class PostFeed(BaseNeuralFeed):  
        feed_id = "posts_main"  
        content_django_model = Post  
    
  3. Fetch Personalized Feed Results: Leverage the .get_feed() method to retrieve curated recommendations.
    feed_queryset = PostFeed.get_feed(user=request.user, queryset=Post.objects.all())  
    

Advanced Features

Django Neural Feed also includes capabilities for custom vector embeddings, allowing users to define their own text-to-vector encoders, adding flexibility for integrating with third-party APIs or cloud services. By default, it employs local embeddings via sentence-transformers, but can easily be adapted for various other implementations.

Get Started Today

Django Neural Feed provides a comprehensive, powerful solution for personalizing content recommendations, making it an ideal addition to any Django application focused on enhancing user engagement through intelligent content delivery.

0 comments

No comments yet.

Sign in to be the first to comment.