DARPG

  1. DARPG

    1. Problem Statement

    2. Approach

  2. Creating Embeddings

  3. Demo

    1. API

    2. Chat bot demo

    3. Reproducing

  4. Future Improvements

1 / 18

DARPG

1
  1. DARPG

    1. Problem Statement

    2. Approach

  2. Creating Embeddings

  3. Demo

    1. API

    2. Chat bot demo

    3. Reproducing

  4. Future Improvements

2

Problem Statement

Develop an AI/ML-driven Chatbot which is Ministry Specific to help the Citizens to resolve their common queries related to filing a Grievance in the CPGRAMS portal (https://pgportal.gov.in) and expedite smooth submission of grievances.[1]


  1. https://event.data.gov.in/challenge/darpg-challenge-2024/ ↩︎

3

Approach

  • Creating a embeddings
  • Storing it in Vector Store
  • Open Source Model for answering queries
  • Creating a protected inference endpoint for it
  • Not relying on any propriety solutions (Making it fully self hostable)
4

Creating Embeddings

5

Embeddings are created using langchain and CSVLoader

loader = CSVLoader(file_path='darpg.csv',  source_column="Code")
documents  = loader.load()
6
ColumnNon-Null CountDtype
Code18246int64
Description18246object
OrgCode18246object
Parent18155float64
Stage18246int64
Destination10067object
7
from langchain_community.embeddings import HuggingFaceBgeEmbeddings

model_name = "mixedbread-ai/mxbai-embed-large-v1"
model_kwargs = {"device": "cuda"}
encode_kwargs = {"normalize_embeddings": True}
hf = HuggingFaceBgeEmbeddings(
    model_name=model_name, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs
)
8
url = "<URL>"
api_key = "<API"
qdrant = Qdrant.from_documents(
    docs,
    hf,
    url=url,
    prefer_grpc=True,
    api_key=api_key,
    collection_name="darpg-knowledge-base",
)
9

Demo

10

API

The entire code is shared on github at https://github.com/kokamkarsahil/darpg/tree/main/Problem Statement 2 and the API is complaint with OpenAPI

11
12

The demo uses phi-2 which can be easily interchanged with different model or a hosted infernce endpoint

13
14

Chat bot demo

15

Reproducing

FROM python:3.11-slim

RUN pip install poetry==1.6.1

RUN poetry config virtualenvs.create false

WORKDIR /code

COPY ./pyproject.toml ./README.md ./poetry.lock* ./

COPY ./package[s] ./packages

RUN poetry install  --no-interaction --no-ansi --no-root

COPY ./app ./app

RUN poetry install --no-interaction --no-ansi

EXPOSE 8080

CMD exec uvicorn app.server:app --host 0.0.0.0 --port 8080
16

Future Improvements

  • Expanding knowledge base realated
  • Creating a fine tunned LLM
17

Thank You

18