NLP-KG Search is a search and question-answering system for NLP/ML papers. The project combines lexical search, semantic search, and a RAG agent to help users retrieve papers, inspect paper details, and ask questions through a web interface.
The system includes the following main components:
BM25: performs lexical keyword search over paper titles and abstracts.ChromaDB: stores vector embeddings for semantic search.Sentence Transformers: generates embeddings for paper abstracts and full texts.FlashRank: reranks semantic search results.RRF: combines lexical and semantic results for hybrid search.LangGraph: orchestrates the RAG agent workflow.Gemini: classifies intent, generates answers, and evaluates answer quality.arXiv API: retrieves external papers when the internal corpus is insufficient.Streamlit: provides the web interface for search, paper details, and RAG chat.Important project structure:
.
|-- run_agent.py # CLI entry point for the RAG agent
|-- requirements.txt # Main dependencies
|-- .env.example # Environment configuration template
|-- data/
| |-- data_processed/ # Processed paper data
| `-- src/ # Data processing scripts
|-- src/
| |-- agent/ # LangGraph agent and RAG nodes
| |-- bm25/ # BM25 search
| |-- chromadb/ # Abstract vector store and semantic search
| |-- chroma_fulltext/ # Full-text vector store for RAG chat
| |-- web/ # Streamlit web app
| `-- search_engine_for_rag.py # Hybrid search / RRF
`-- md/ # System flow documentation
Environment requirements:
Create a virtual environment:
python -m venv .venv
Activate it on Windows PowerShell:
.venv\Scripts\Activate.ps1
Activate it on macOS/Linux:
source .venv/bin/activate
Create the environment configuration file:
copy .env.example .env
On macOS/Linux:
cp .env.example .env
Open .env and configure the important variables:
GOOGLE_API_KEY=./Google_api_key.txt
GEMINI_MODEL=gemini-2.5-flash
MAX_CONTEXT_TOKENS=2000
LLM_TEMPERATURE=0.2
LLM_MAX_TOKENS=2000
STREAMLIT_PORT=8501
There are two ways to provide the Gemini key:
GOOGLE_API_KEY variable.Google_api_key.txt in the project root and keep GOOGLE_API_KEY=./Google_api_key.txt.If you run the data pipeline with Semantic Scholar, create this file:
data/src/api.txt
Then place the Semantic Scholar API key inside that file.
Install all required dependencies:
pip install -r requirements.txt
This project does not train a supervised neural model from scratch. In this project, "training" means processing the paper data, generating embeddings, and rebuilding the search indexes.
Run the scripts in data/src/ in order if you need to rebuild the dataset:
python data/src/1_loose_filter.py
python data/src/2_map.py
python data/src/3_strict_filter.py
python data/src/4_clean_and_merge.py
python data/src/5_check_is_survey.py
After the pipeline finishes, the cleaned data is stored in data/data_processed/.
This vector store is used for semantic search over paper titles and abstracts:
python src/chromadb/ingest.py
Default output:
src/chromadb/chroma_store_abstracts/
This vector store is used for RAG chat over full-text papers:
python src/chroma_fulltext/ingest.py
Default output:
data/chroma_store_fulltext/
python src/search_engine_for_rag.py
This pipeline combines BM25, ChromaDB, and RRF to produce hybrid search results.
Run a single query:
python run_agent.py --query "What is BERT pretraining?"
Run interactive question answering:
python run_agent.py --interactive
Run built-in examples:
python run_agent.py --examples
Run batch queries from a JSON file:
python run_agent.py --batch queries.json --output results.json
streamlit run src/web/app.py
After the app starts, open:
http://localhost:8501
The web app supports:
If the app reports that ChromaDB cannot be found, rebuild the indexes:
python src/chromadb/ingest.py
python src/chroma_fulltext/ingest.py
Docker is the easiest way to run the deployed Streamlit application. A ready-built image is available on Docker Hub:
nguyennhattk19/nlp-kg-search:latest
Pull the image:
docker pull nguyennhattk19/nlp-kg-search:latest
Run the container:
docker run -p 8501:8501 -e GOOGLE_API_KEY="your_google_api_key" nguyennhattk19/nlp-kg-search:latest
Replace your_google_api_key with your real Google Gemini API key.
After the container starts, open:
http://localhost:8501
To stop the app, press Ctrl+C in the terminal running the container.
If you want to run the container in the background:
docker run -d --name nlp-kg-search -p 8501:8501 -e GOOGLE_API_KEY="your_google_api_key" nguyennhattk19/nlp-kg-search:latest
Then stop and remove it with:
docker stop nlp-kg-search
docker rm nlp-kg-search
If you want to build the image locally instead of pulling it from Docker Hub:
docker compose build
Then run the local image:
docker run -p 8501:8501 -e GOOGLE_API_KEY="your_google_api_key" nlp-kg-search:latest
Notes:
.env, Google_api_key.txt, or API tokens into the image.-e GOOGLE_API_KEY="...".The deployment method is a Streamlit application running in a Python environment with the required data files and vector stores available locally.
Deployment steps:
.env and the required API keys.Local deployment command:
streamlit run src/web/app.py
Deployment architecture:
User Browser
|
v
Streamlit Web App
|
|-- BM25 lexical search
|-- ChromaDB semantic search
|-- FlashRank reranker
|-- LangGraph RAG agent
|-- Gemini API
`-- arXiv API fallback
The application does not require a separate model server. Embedding and reranker models are loaded directly inside the Python process, ChromaDB is stored locally on disk, and the LLM is accessed through the Gemini API.
NLP-KG Search is a search and question-answering system for NLP/ML papers. The project combines lexical search, semantic search, and a RAG agent to help users retrieve papers, inspect paper details, and ask questions through a web interface.
The system includes the following main components:
BM25: performs lexical keyword search over paper titles and abstracts.ChromaDB: stores vector embeddings for semantic search.Sentence Transformers: generates embeddings for paper abstracts and full texts.FlashRank: reranks semantic search results.RRF: combines lexical and semantic results for hybrid search.LangGraph: orchestrates the RAG agent workflow.Gemini: classifies intent, generates answers, and evaluates answer quality.arXiv API: retrieves external papers when the internal corpus is insufficient.Streamlit: provides the web interface for search, paper details, and RAG chat.Important project structure:
.
|-- run_agent.py # CLI entry point for the RAG agent
|-- requirements.txt # Main dependencies
|-- .env.example # Environment configuration template
|-- data/
| |-- data_processed/ # Processed paper data
| `-- src/ # Data processing scripts
|-- src/
| |-- agent/ # LangGraph agent and RAG nodes
| |-- bm25/ # BM25 search
| |-- chromadb/ # Abstract vector store and semantic search
| |-- chroma_fulltext/ # Full-text vector store for RAG chat
| |-- web/ # Streamlit web app
| `-- search_engine_for_rag.py # Hybrid search / RRF
`-- md/ # System flow documentation
Environment requirements:
Create a virtual environment:
python -m venv .venv
Activate it on Windows PowerShell:
.venv\Scripts\Activate.ps1
Activate it on macOS/Linux:
source .venv/bin/activate
Create the environment configuration file:
copy .env.example .env
On macOS/Linux:
cp .env.example .env
Open .env and configure the important variables:
GOOGLE_API_KEY=./Google_api_key.txt
GEMINI_MODEL=gemini-2.5-flash
MAX_CONTEXT_TOKENS=2000
LLM_TEMPERATURE=0.2
LLM_MAX_TOKENS=2000
STREAMLIT_PORT=8501
There are two ways to provide the Gemini key:
GOOGLE_API_KEY variable.Google_api_key.txt in the project root and keep GOOGLE_API_KEY=./Google_api_key.txt.If you run the data pipeline with Semantic Scholar, create this file:
data/src/api.txt
Then place the Semantic Scholar API key inside that file.
Install all required dependencies:
pip install -r requirements.txt
This project does not train a supervised neural model from scratch. In this project, "training" means processing the paper data, generating embeddings, and rebuilding the search indexes.
Run the scripts in data/src/ in order if you need to rebuild the dataset:
python data/src/1_loose_filter.py
python data/src/2_map.py
python data/src/3_strict_filter.py
python data/src/4_clean_and_merge.py
python data/src/5_check_is_survey.py
After the pipeline finishes, the cleaned data is stored in data/data_processed/.
This vector store is used for semantic search over paper titles and abstracts:
python src/chromadb/ingest.py
Default output:
src/chromadb/chroma_store_abstracts/
This vector store is used for RAG chat over full-text papers:
python src/chroma_fulltext/ingest.py
Default output:
data/chroma_store_fulltext/
python src/search_engine_for_rag.py
This pipeline combines BM25, ChromaDB, and RRF to produce hybrid search results.
Run a single query:
python run_agent.py --query "What is BERT pretraining?"
Run interactive question answering:
python run_agent.py --interactive
Run built-in examples:
python run_agent.py --examples
Run batch queries from a JSON file:
python run_agent.py --batch queries.json --output results.json
streamlit run src/web/app.py
After the app starts, open:
http://localhost:8501
The web app supports:
If the app reports that ChromaDB cannot be found, rebuild the indexes:
python src/chromadb/ingest.py
python src/chroma_fulltext/ingest.py
Docker is the easiest way to run the deployed Streamlit application. A ready-built image is available on Docker Hub:
nguyennhattk19/nlp-kg-search:latest
Pull the image:
docker pull nguyennhattk19/nlp-kg-search:latest
Run the container:
docker run -p 8501:8501 -e GOOGLE_API_KEY="your_google_api_key" nguyennhattk19/nlp-kg-search:latest
Replace your_google_api_key with your real Google Gemini API key.
After the container starts, open:
http://localhost:8501
To stop the app, press Ctrl+C in the terminal running the container.
If you want to run the container in the background:
docker run -d --name nlp-kg-search -p 8501:8501 -e GOOGLE_API_KEY="your_google_api_key" nguyennhattk19/nlp-kg-search:latest
Then stop and remove it with:
docker stop nlp-kg-search
docker rm nlp-kg-search
If you want to build the image locally instead of pulling it from Docker Hub:
docker compose build
Then run the local image:
docker run -p 8501:8501 -e GOOGLE_API_KEY="your_google_api_key" nlp-kg-search:latest
Notes:
.env, Google_api_key.txt, or API tokens into the image.-e GOOGLE_API_KEY="...".The deployment method is a Streamlit application running in a Python environment with the required data files and vector stores available locally.
Deployment steps:
.env and the required API keys.Local deployment command:
streamlit run src/web/app.py
Deployment architecture:
User Browser
|
v
Streamlit Web App
|
|-- BM25 lexical search
|-- ChromaDB semantic search
|-- FlashRank reranker
|-- LangGraph RAG agent
|-- Gemini API
`-- arXiv API fallback
The application does not require a separate model server. Embedding and reranker models are loaded directly inside the Python process, ChromaDB is stored locally on disk, and the LLM is accessed through the Gemini API.