Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Coding Assistant — Hybrid RAG Chatbot

Offline programming assistant that retrieves known answers and generates new ones

Python Transformers Sentence-Transformers License: MIT

A hybrid Retrieval-Augmented Generation chatbot that answers coding questions — instantly retrieving high-quality pre-written answers for known topics, and generating fresh answers for novel ones. Runs fully offline after the initial model download.


Two-Path Logic

flowchart TD
    Q["User question"] --> EMB["Embed with multi-qa-mpnet-base-dot-v1"]
    EMB --> SIM{"Similarity vs vector DB<br/>above confidence threshold?"}
    SIM -- "yes (known topic)" --> RET["Return pre-written answer<br/>(instant, high quality)"]
    SIM -- "no (novel question)" --> GEN["Generate with microsoft/phi-2"]
    GEN --> LEARN["Optionally add Q→A pair<br/>back into the vector DB<br/>(self-improving)"]
    RET --> OUT["Answer"]
    LEARN --> OUT
Loading
  • Retriever: sentence-transformers/multi-qa-mpnet-base-dot-v1 for high-precision semantic search
  • Generator: microsoft/phi-2 for coherent novel answers
  • Self-improving knowledge base: newly generated Q→A pairs can be folded back into the vector DB, so the assistant gets smarter over time
  • Fully offline after initial model download

Setup

git clone https://github.com/YazanAi-Dev3/AI-Coding-Assistant.git
cd AI-Coding-Assistant

# Download both models into model_cache/{multi-qa-mpnet-base-dot-v1, phi-2}
python -m venv venv   # activate, then:
pip install -r requirements.txt

python src/build_vector_db.py   # builds database/vector_database.pkl from data/questions_answers.json

Then run the interactive demo in Demo.ipynb.

Structure

AI-Coding-Assistant/
├── src/
│   ├── model_loader.py         # loads retriever + generator
│   ├── build_vector_db.py      # constructs the vector DB
│   └── chatbot_logic.py        # two-path retrieval/generation logic
├── data/questions_answers.json # curated Q→A knowledge base
├── database/vector_database.pkl# prebuilt embeddings
└── Demo.ipynb

Tech Stack

Python · sentence-transformers (MPNet) · microsoft/phi-2 · offline vector database

License

MIT — see LICENSE.

About

Offline hybrid RAG coding chatbot — MPNet semantic retrieval returns vetted answers above a confidence threshold, phi-2 generates the rest, and new Q→A pairs fold back into the vector DB.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages