Machine Learning Research Literature Intelligence
- Live Application: https://neuralscholar-vapssaw6clm9s7jkzpwgjh.streamlit.app/
- API Docs: https://neuralscholar-api.onrender.com/docs
NeuralScholar is an advanced, end-to-end Retrieval-Augmented Generation (RAG) engine designed specifically for navigating dense Machine Learning research literature. It bridges the gap between semantic understanding and exact keyword matching by leveraging a sophisticated hybrid-retrieval pipeline, local embeddings, cross-encoder reranking, and large language model generation.
- Hybrid Search Retrieval: Combines the semantic depth of dense vector search (Pinecone & FAISS) with the exact-keyword precision of sparse retrieval (BM25Okapi).
- Cross-Encoder Reranking: Implements a two-stage retrieval pipeline, refining initial candidate documents using a
ms-marco-MiniLM-L-6-v2cross-encoder for maximal contextual relevance. - Hypothetical Document Embeddings (HyDE): Optionally generates hallucinated answers to map queries closer to target document embeddings in latent space.
- Automated Data Ingestion: Natively integrates with the ArXiv API to dynamically fetch, chunk, embed, and index research papers on the fly.
- Streaming Generation: Real-time token streaming to the frontend using OpenAI's GPT-4o.
- Extraction: Papers are fetched via the ArXiv API matching specific IDs or ML queries.
- Chunking: Documents are parsed and split using LangChain's
RecursiveCharacterTextSplitter(Size: 1000, Overlap: 150) to preserve paragraph contexts. - Embedding: Chunks are embedded locally using
all-MiniLM-L6-v2(384 dimensions) for optimal memory usage and speed. - Indexing: Vectors are concurrently upserted to a cloud Pinecone index, a local FAISS index, and a BM25 sparse index.
- HyDE Generation (Optional): The user query is expanded into a hypothetical ideal document.
- Hybrid Search: The query/HyDE text is embedded and searched against Pinecone/FAISS (Cosine Similarity via Inner Product) and BM25 (TF-IDF probabilistic scoring).
- Reciprocal Rank Fusion (RRF): Results from dense and sparse retrievers are mathematically fused to mitigate distinct retrieval biases.
- Reranking: The top fused candidates are paired with the user query and scored by a local Cross-Encoder to guarantee semantic alignment.
- The highest-ranked context chunks are injected into a strict, anti-hallucination system prompt.
- The payload is sent to the LLM (GPT-4o) which synthesizes a grounded answer and streams the response back to the Streamlit UI.
| Component | Technology | Cloud Host |
|---|---|---|
| Frontend UI | Streamlit | Streamlit Community Cloud |
| Backend API | FastAPI, Uvicorn | Render |
| Vector Databases | Pinecone (Cloud), FAISS (Local) | Pinecone |
| Sparse Retrieval | rank_bm25 (Okapi) | Render |
| Embedding Model | SentenceTransformers (all-MiniLM-L6-v2) |
Render |
| Reranker | Cross-Encoder (ms-marco-MiniLM-L-6-v2) |
Render |
| LLM / Generation | OpenAI API (GPT-4o) | OpenAI |
- Python 3.11+
- An active OpenAI API Key
- An active Pinecone API Key & Index (Dimension: 384, Metric: cosine)
Clone the repository and spin up a virtual environment:
git clone [https://github.com/Sahilll10/NeuralScholar.git](https://github.com/Sahilll10/NeuralScholar.git)
cd NeuralScholar
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements-backend.txt