ginnigarg's picture
Update app.py
6a0cd2b verified
raw
history blame
5.1 kB
import streamlit as st
from transformers import pipeline
from sentence_transformers import SentenceTransformer
import faiss
import numpy as np
# Sample knowledge base (documents)
documents = [
"""
Biodata or about ginni as name : GINNI GARG, email : gargginni01@gmail.com, phone : +91-8295954475, Date of Birth - 1st January 1998, linkedin : www.linkedin.com/in/ginni-garg, github : https://github.com/GinniIndia
""",
"""
Ginni hobbies are "reading books, Badminton, Yoga, Running, Walking, Exercies, GYM" etc.
""",
"""
Ginni Favourite Books are "Atomic Habits, IKigai, Biography of Swami Viveknand, Jeevan Amrit by OSHO" etc.
""",
"""
Ginni completed his Graduation B.Tech in Computer Engineering from National Institute of Technology, Kurukshetra in between 2016 -2020 with cgpa 9.65
""",
"""
ginni completed Schooling both 10th (2012-2013) with cgpa 10, and 12th (2014-2015) with 91% from D.A.V. Public School, Kalanwali.
""",
"""
List of all companies where ginni worked or have experience till date ??
1. Scientist 'B' @ CDOT
(April 2024 - Present)
Working on Software Security and Backend Engineering.
2.Software Engineer – Machine Learning @ SirionLabs (Location – Gurugram/Remote)
(Dec 2022 – March 2023)
Working in Client Legal Management (CLM) company, Tech used :-
Flask, Pulsar, Debugging, GCP buckets, YAML, Debugging, Python Scripting, Docanno, Model
Training/Validation, API formation, Postman.
3.Software Development Engineer – 2 @ Otipy (Crofarm) (Location – Gurugram)
(May 2022 – November 2022)
Working in E-commerce Company in Warehouse Team, Tech used :-
Django, SQL, Redis, Celery, Kafka, Pagination
4.Software Engineer (Full Time) @ Arcesium India Private Ltd (Location – Gurugram)
(August 2020 – May 2022)
Working in Fintech Company for specific clients on various Technologies :
ETL Framework, Flask Framework, Async Await Python, Python Scripting, Sqlite3 in-memory db, Postgres SQL, YAML, Gunicorn Server, Unit Test Cases (For Sync and Async Python), Git, Gitlab, S3
Buckets, Authentication – Kerberos and JWT, JIRA, Debugging, Threading and Multi-processing.
""",
"""
JEE and GATE Scores of Ginni:
Gate – 2020 | AIR or GATE rank - 2562 | Gate Score – 562 | GATE Marks – 46.67/100 |
JEE Main – 2016 | AIR or GATE rank – 8123 | JEE Marks – 231/360 | JEE Percentile – 99.3% |
""",
"""
All academic Achievements of ginni:
1.Received Award of Academic Excellence for Department Topper in First year.
2.Received Award of Academic Excellence for Securing Third Rank among all Departments in First Year.
3. Member of Institution Innovation Council under the ageis of MHRD’s Innovation Cell established at NIT, Kurukshetra for academic year 2018-2019.
4. Department Rank 4 (Computer Engineering Graduation) and University Rank 5.
5. In National Level Science Talent Search Examination and secured 252 rank at National Level.
""",
"""
List of all Publications or research papers of ginni ??
1. Ginni Garg and Ritu Garg. “Brain Tumor Detection and Classification using Hybrid Ensemble Classifier”.
International Journal of Healthcare Information Systems and Informatics (IJHISI), IGI Global, Clarivate Analytics
indexed, scopus indexed.
arxiv Link: https://arxiv.org/abs/2101.00216
2. Ginni Garg and Mantosh Biswas. “Improved Neural Network Based Plant Disease Identification” in First
International Conference on Advanced Communication & Computational Technology (ICACCT) 2019, Scopus
Index, LNEE Format.
arxiv Link: https://arxiv.org/abs/2101.00215
3. Ginni Garg and Ritu Garg. “A Hybrid MLP-SVM based classification using spatial-spectral features on Hyper-
spectral Images”. International Conference Futuristic Trends in Networks and Computing Technologies, FTNCT-
2020 Approved by CCIS, Springer (Indexed by Scopus and DBLP), Southern Federal University, Russia.
arxiv Link: https://arxiv.org/abs/2101.00214
""",
"""
If you are not confident, just answer "I donot know"
"""
]
# Step 1: Embed documents using a transformer model
model = SentenceTransformer("all-MiniLM-L6-v2")
doc_embeddings = model.encode(documents)
# Step 2: Create FAISS index for efficient retrieval
index = faiss.IndexFlatL2(doc_embeddings.shape[1])
index.add(np.array(doc_embeddings).astype("float32"))
# Step 3: Define the RAG pipeline
def rag_qa(question):
question_embedding = model.encode([question])
_, retrieved_indices = index.search(np.array(question_embedding).astype("float32"), k=3)
retrieved_doc = documents[retrieved_indices[0][0]]
qa_pipeline = pipeline("text2text-generation", model="google/flan-t5-large")
prompt = f"Context: {retrieved_doc}\n\nQ: {question}\nA:"
response = qa_pipeline(prompt, max_length=1000)
return response[0]['generated_text']
# Step 4: Streamlit UI Implementation
st.title("🧠 Ask anything about Ginni !")
question = st.text_input("Ask your question:")
if st.button("Get Answer"):
if question.strip():
answer = rag_qa(question)
st.success(f"**Answer:** {answer}")
else:
st.warning("Please enter a valid question.")