Spaces:
Sleeping
Sleeping
requirements.txt
Browse filestransformers
sentence-transformers
faiss-cpu
streamlit
numpy
app.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
# Required Libraries Installation
|
2 |
-
|
3 |
# Import necessary modules
|
4 |
from transformers import pipeline
|
5 |
from sentence_transformers import SentenceTransformer
|
@@ -33,19 +31,4 @@ def retrieve_documents(query, top_k=3):
|
|
33 |
distances, indices = index.search(query_embedding, top_k)
|
34 |
return [documents[i]['text'] for i in indices[0]]
|
35 |
|
36 |
-
# Function to generate an answer using the
|
37 |
-
def ask_question(question):
|
38 |
-
retrieved_docs = retrieve_documents(question)
|
39 |
-
context = " ".join(retrieved_docs)
|
40 |
-
answer = question_answerer(question=question, context=context)
|
41 |
-
return answer['answer']
|
42 |
-
|
43 |
-
# Streamlit Interface for the RAG App
|
44 |
-
st.title("Economic and Population Growth Advisor")
|
45 |
-
st.write("Ask questions related to economic and population growth. This app uses retrieval-augmented generation to provide answers based on relevant documents.")
|
46 |
-
|
47 |
-
# Input for the question
|
48 |
-
question = st.text_input("Enter your question:")
|
49 |
-
if question:
|
50 |
-
answer = ask_question(question)
|
51 |
-
st.write("Answer:", answer)
|
|
|
|
|
|
|
1 |
# Import necessary modules
|
2 |
from transformers import pipeline
|
3 |
from sentence_transformers import SentenceTransformer
|
|
|
31 |
distances, indices = index.search(query_embedding, top_k)
|
32 |
return [documents[i]['text'] for i in indices[0]]
|
33 |
|
34 |
+
# Function to generate an answer using the ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|