使用说明
AI文档机器人
一个聪明的 RAG机器人 它回答了各种自然语言问题 熊猫, 数值Python,以及 Scikit学习 文档,使用 MLP分类器 根据源可靠性对检索到的片段进行排名。 答案相关性提高了20% 通过将官方API引用优先于Stack Overflow等社区内容。
亮点
- 相关性提高20% 将官方文档置于社区答案之上
- 3个大型技术语料库 索引(Pandas、NumPy、Scikit-learn)
- 基于MLP的源分类器 接受TF-IDF功能方面的培训,以对API-spec与教程与社区进行评分
- LLM灵活性:OpenAI(GPT-4o/GPT-3.5-Turbo)或当地Ollama(Llama 3.1)
- 流线型UI 用于快速原型制作
建筑学
┌──────────────┐ ┌──────────────┐ ┌────────────────┐
│ Scraper │──▶│ corpus.json │──▶│ Sentence-BERT │
│(BeautifulSoup)│ │ │ │ Embeddings │
└──────────────┘ └──────────────┘ └────────┬───────┘
│
▼
┌──────────────┐
│ Pinecone │
│ Vector Store │
└──────┬───────┘
│
User Query ──▶ Streamlit ──▶ Retrieval ───────┘
│
▼
┌────────────────────┐
│ MLP Source │ ← ranks snippets by
│ Classifier │ API-spec / tutorial /
│ (TF-IDF + MLP) │ community reliability
└──────────┬─────────┘
▼
┌────────────────────┐
│ Prompt Assembler │ ← prioritizes official
│ (LangChain) │ sources in context
└──────────┬─────────┘
▼
┌────────────────────┐
│ LLM (OpenAI / │
│ local Ollama) │
└──────────┬─────────┘
▼
Grounded Answer
一切: 有时间后,用渲染图替换。此草图显示了流程。
技术栈
后端和机器学习 Python 3.9+·Scikit-learn(MLPC分类器,TF-IDF)·句子转换器
向量数据库 松果
LLM OpenAI(GPT-4o/GPT-3.5-Turbo)或当地Ollama(Llama 3.1 8B)
编排 LangChain
抓取 请求·BeautifulSoup4
用户界面 溪流
快速开始
git clone https://github.com/gauravch-code/AI-doc-bot.git
cd AI-doc-bot
python -m venv venv
source venv/bin/activate # macOS / Linux
# venv\Scripts\activate # Windows
pip install -r requirements.txt
创建一个 .env 根:
PINECONE_API_KEY=your-pinecone-key
OPENAI_API_KEY=your-openai-key # Omit if using Ollama exclusively
首次设置(三个准备步骤)
python scraper.py # collect docs → corpus.json
python train_classifier.py # train MLP classifier → .pkl files
python build_vectordb.py # populate Pinecone index
运行应用程序
streamlit run streamlit_app.py
开放时间: http://localhost:8501.
可选:通过Ollama使用本地LLM
# install Ollama from https://ollama.com/download
ollama pull llama3.1:8b
# swap ChatOpenAI for ChatOllama inside streamlit_app.py
测试
一个涵盖scraper HTML解析、模拟Pinecone/OpenAI响应和分类器加载的测试套件正在进行中。通过Streamlit UI在Pandas、NumPy和Scikit-learn查询中运行手动烟雾测试,以验证引用质量和源优先级。
路线图
- 扩展到Matplotlib、TensorFlow、PyTorch文档
- 查询时库检测(自动路由到正确的索引命名空间)
- 将TF-IDF替换为分类器中的句子嵌入
- Docker化并部署到Streamlit社区云
- 使用mocking添加正式的单元和集成测试
联系
高拉夫·钦塔昆塔 · 领英 · 投资组合 · gaurav.pvt25@gmail.com