CoolFace
Apppublic

Rasheedj/mtech-chatbot

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

README.md

MTech.ai Chatbot

A conversational AI assistant for MTech.ai that answers questions about the company's projects and services using vector search and LLM technology.

Features

  • —Answers questions about company projects and services
  • —Utilizes vector search for relevant information retrieval
  • —Powered by Hugging Face models for embeddings and text generation
  • —FastAPI backend for efficient request handling
  • —Automatic document processing and indexing

Architecture

The application follows a modular architecture:

  • —app.py: Main FastAPI application
  • —config.py: Configuration settings
  • —llm.py: LLM integration for response generation
  • —loader.py: Document loading and chunking
  • —vector_db.py: Vector database management
  • —utils.py: Utility functions

Technical Stack

  • —FastAPI: Web framework
  • —Sentence Transformers: Embedding generation
  • —TinyLlama/Hugging Face: Text generation
  • —FAISS: Vector similarity search
  • —PyTorch: Deep learning framework

Setup Instructions

1. Install Dependencies

bash
pip install -r requirements.txt

2. Prepare Project Documents

Add markdown files with project information to the data/projects/ directory.

3. Run the Application

bash
python -m app

The server will start on http://localhost:8000 by default.

API Endpoints

  • —POST /query: Process a user query and return a response
  • —POST /rebuild_index: Rebuild the vector index from scratch
  • —GET /health: Check the health of the application

Deployment to Hugging Face Spaces

Prerequisites

Deployment Steps

  1. 1.Create a new Hugging Face Space:
  2. 2.Go to Hugging Face Spaces
  3. 3.Click "Create a new Space"
  4. 4.Select "FastAPI" as the SDK
  5. 5.Name your space and set it to public or private
  1. 1.Clone the space repository:
bash
   git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
  1. 1.Copy your application files to the cloned repository:
bash
   cp -r app.py config.py llm.py loader.py vector_db.py utils.py requirements.txt README.md /path/to/cloned/repo/
  1. 1.Create the data directory and add project files:
bash
   mkdir -p /path/to/cloned/repo/data/projects
   cp -r data/projects/* /path/to/cloned/repo/data/projects/
  1. 1.Commit and push your changes:
bash
   cd /path/to/cloned/repo
   git add .
   git commit -m "Initial application deployment"
   git push

The Hugging Face platform will automatically build and deploy your application when you push to the repository.

Notes on Initialization

When deployed to Hugging Face Spaces, the application will automatically:

  1. 1.Load and process all project documents
  2. 2.Build a vector index for efficient retrieval
  3. 3.Initialize the LLM for response generation

This happens during the first startup and may take a few minutes. Subsequent restarts will load the saved index for faster initialization.

Customization

  • —Adjust model settings in config.py to use different embedding or LLM models
  • —Modify chunking parameters to optimize retrieval performance
  • —Add new project documents to expand the knowledge base

Troubleshooting

If the application fails to retrieve relevant information:

  1. 1.Check if the vector index was properly built
  2. 2.Verify that project documents contain the necessary information
  3. 3.Adjust the similarity threshold in config.py
  4. 4.Rebuild the index using the /rebuild_index endpoint

License

MIT