Discover your next favorite book with AI-powered semantic search and intelligent analysis
β¨ Features β’ π Quick Start β’ π‘ How It Works β’ π Usage β’ π οΈ Tech Stack
AI Book Discovery Platform is an intelligent book recommendation system that understands natural language queries and provides deep, contextual book recommendations. Unlike traditional search systems that rely on keyword matching, this platform uses cutting-edge AI to understand the semantic meaning of your search and provides expert-level analysis for each recommendation.
Traditional Search: "science fiction AI"
β Returns books with those exact keywords
AI Search: "I'm looking for a sci-fi novel that explores AI consciousness"
β Understands themes, context, and intent
β Finds books about AI ethics, sentience, and philosophical questions
β Provides expert analysis of why each book matches your needs
- Natural language understanding powered by
nomic-embed-text - No need for exact keyword matching
- Searches by meaning, theme, and context
- Query Analysis: Understand your reading preferences and search intent
- Expert Book Reviews: Get AI-generated summaries, themes, and audience insights
- Reader Profiling: Discover what type of reader you are based on your searches
- Default curated book dataset included
- Upload your own custom CSV datasets
- Support for any book collection with titles and descriptions
- Runs entirely on your machine using Ollama
- No data sent to external APIs
- Complete privacy and control
- Instant semantic search results
- Dynamic AI analysis generation
- Responsive Streamlit interface
Before you begin, ensure you have:
- Python 3.8+ installed
- Ollama running locally (Install Ollama)
- Required AI models pulled
# Install Ollama (if not already installed)
# Visit https://ollama.ai for installation instructions
# Pull required models
ollama pull nomic-embed-text
ollama pull llama3.2:1b# Clone the repository
git clone https://github.com/yourusername/ai-book-discovery.git
cd ai-book-discovery
# Install dependencies
pip install -r requirements.txtstreamlit run OllamaLLM.pyThe app will open in your browser at http://localhost:8501 π
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Query Input β
β "I want a fantasy book about dragons" β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Embedding Generation β
β (nomic-embed-text via Ollama) β
β Query β [0.234, -0.891, 0.456, ...] (vector) β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Semantic Similarity Search β
β Compare query vector with all books β
β Using Cosine Similarity Algorithm β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Top Matches Retrieved β
β Books ranked by semantic relevance score β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Analysis Generation β
β (llama3.2:1b via Ollama) β
β β’ Reader Profile β’ Search Intent β
β β’ Collection Themes β’ Individual Book Analysis β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Traditional Keyword Search:
if "dragon" in book_description:
return book # Simple string matchingAI Semantic Search:
# Understands meaning and context
query_embedding = embed("I want a fantasy book about dragons")
book_embedding = embed("Epic tale featuring mythical creatures and fire-breathing beasts")
similarity = cosine_similarity(query_embedding, book_embedding)
# High similarity even without exact word "dragon"!- Enter Your Query: Type a natural language description of what you're looking for
Examples:
- "A thriller that keeps me on the edge of my seat"
- "Books about personal growth and mindfulness"
- "Historical fiction set during World War II"
- "Funny books that will make me laugh out loud"
-
Get Recommendations: View semantically matched books with relevance scores
-
Explore AI Analysis:
- Read the comprehensive query analysis
- Expand individual books for expert insights
-
Prepare Your CSV: Ensure it has at least these columns:
Title(required)Description(required)- Optional:
Authors,Category,Price, etc.
-
Upload: Use the sidebar file uploader
-
Search: Your custom books are now searchable!
π User Query:
"I need a book that helps me understand human psychology"
π€ AI Understanding:
- Intent: Educational self-improvement
- Themes: Psychology, human behavior, mental processes
- Reader Profile: Curious learner seeking knowledge
π Top Recommendations:
1. "Thinking, Fast and Slow" (95% match)
Expert Analysis:
β’ Summary: Explores dual-process theory of mind
β’ Themes: Cognitive biases, decision-making, rationality
β’ Audience: Psychology enthusiasts, professionals
2. "The Power of Habit" (92% match)
Expert Analysis:
β’ Summary: Examines habit formation and behavioral change
β’ Themes: Neuroscience, productivity, self-improvement
β’ Audience: Self-help readers, behavioral scientists
| Component | Technology | Purpose |
|---|---|---|
| Frontend | Streamlit | Interactive web interface |
| LLM Runtime | Ollama | Local AI model execution |
| Embedding Model | nomic-embed-text | Semantic understanding |
| Generative Model | llama3.2:1b | Text analysis & insights |
| Data Processing | Pandas | Dataset manipulation |
| ML Algorithms | Scikit-learn | Similarity calculations |
- Purpose: Convert text into numerical vectors (embeddings)
- Size: ~274MB
- Use Case: Semantic search and similarity matching
- Speed: Fast inference (~50ms per query)
- Purpose: Generate human-like analytical text
- Size: ~1.3GB
- Use Case: Query analysis and book insights
- Speed: Moderate (~2-3s per analysis)
ai-book-discovery/
βββ OllamaLLM.py # Main application file
βββ BooksDataset.csv # Default book dataset
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ assets/ # Images and demos
β βββ demo.gif
βββ .gitignore
How traditional search fails:
Query: "Books about overcoming adversity"
Traditional: Searches for exact words "overcoming" AND "adversity"
Result: Misses books about "triumph", "resilience", "perseverance"
How AI search succeeds:
Query: "Books about overcoming adversity"
AI Understanding: Concepts of struggle, growth, resilience, triumph
Result: Finds all thematically related books, regardless of exact wording
After each search, get insights into:
-
π Reader Profile: What your search says about you
"You appear to be seeking intellectually stimulating content with practical applications in daily life." -
π― Search Intent: What you're really looking for
"Intent: Self-improvement through understanding psychological principles and human behavior patterns." -
π Collection Themes: Common threads in recommendations
"This collection emphasizes cognitive science, behavioral psychology, and evidence-based self-development."
Click on any recommended book to reveal:
- βοΈ Executive Summary: Concise overview of the book's content
- π Key Themes: Main topics and concepts explored
- π₯ Target Audience: Who will benefit most from this book
Edit the model names in OllamaLLM.py:
# For embedding (search)
EMBEDDING_MODEL = "nomic-embed-text" # Change to your preferred embedding model
# For text generation (analysis)
LLM_MODEL = "llama3.2:1b" # Options: llama3.2:3b, mistral, etc.# Number of recommendations to show
TOP_K = 5 # Change to show more or fewer results
# Minimum similarity threshold
MIN_SIMILARITY = 0.3 # Range: 0.0 to 1.0Problem: Connection refused error
# Solution: Ensure Ollama is running
ollama serveProblem: Models not found
# Solution: Pull the required models
ollama pull nomic-embed-text
ollama pull llama3.2:1bProblem: Slow performance
# Solution: Use a smaller LLM model
# In OllamaLLM.py, change to:
LLM_MODEL = "llama3.2:1b" # Instead of larger modelsProblem: Out of memory
# Solution: Close other applications or use quantized models
ollama pull llama3.2:1b-q4_0 # Quantized version uses less RAM| Operation | Time (avg) | Notes |
|---|---|---|
| Initial embedding generation | 2-5 min | One-time per dataset |
| Query embedding | ~50ms | Per search |
| Similarity search | ~100ms | For 10K books |
| AI analysis generation | 2-3s | Per query |
| Individual book analysis | 1-2s | On-demand |
System Requirements:
- RAM: 8GB minimum (16GB recommended)
- CPU: Modern multi-core processor
- Storage: ~2GB for models
- Discover books based on mood or current interests
- Find books similar to ones you've enjoyed
- Explore new genres with AI guidance
- Help patrons find books more effectively
- Manage and search large catalogs
- Provide personalized recommendations
- Find books matching group preferences
- Generate discussion themes automatically
- Analyze book connections and themes
- Search academic books by concept
- Find related literature quickly
- Analyze book themes and trends
- Ollama Team for making local LLMs accessible
- Streamlit for the amazing web framework
- Nomic AI for the excellent embedding model
- Meta AI for the Llama 3.2 model
- The open-source community for inspiration and support