Spaces:
Runtime error
Runtime error
RajatChaudhari
commited on
Commit
•
eed549e
1
Parent(s):
a4f89e5
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from operator import itemgetter
|
3 |
import os
|
|
|
4 |
|
5 |
from langchain_community.vectorstores import FAISS
|
6 |
from langchain_core.output_parsers import StrOutputParser
|
@@ -52,12 +53,15 @@ retriever = vectorstore.as_retriever()
|
|
52 |
|
53 |
qa = RetrievalQA.from_chain_type(
|
54 |
llm=hf, chain_type="stuff", retriever=retriever, return_source_documents=False)
|
|
|
55 |
|
56 |
def greet(Question):
|
57 |
answer = qa({"query": Question})
|
58 |
|
59 |
pa=[a.split("Helpful Answer: ") for a in answer.get('result').split('\n') if "Helpful Answer" in a]
|
60 |
-
|
|
|
|
|
61 |
return pa[0][-1]
|
62 |
|
63 |
if __name__ == "__main__":
|
@@ -67,8 +71,11 @@ if __name__ == "__main__":
|
|
67 |
description = """
|
68 |
<img src="https://superagi.com/wp-content/uploads/2023/10/Introduction-to-RAGA-Retrieval-Augmented-Generation-and-Actions-1200x600.png.webp" width=100%>
|
69 |
<br>
|
70 |
-
Demo using
|
71 |
<ul>
|
|
|
|
|
|
|
72 |
<li>update1: This space now does not create a faiss index on build, it uses a locally saved faiss index</li>
|
73 |
<li>update2: This space now uses google/gemma-1.1-2b-it model to generate output, reduces the response time to 1/3rd</li>
|
74 |
</ul>
|
@@ -77,6 +84,8 @@ if __name__ == "__main__":
|
|
77 |
<ul>You can ask questions like -
|
78 |
<li>What is langchain framework?</li>
|
79 |
<li>What is Action Agent?</li>
|
|
|
|
|
80 |
</ul>
|
81 |
Go through this paper here to find more about langchain and then test how this solution performs. <a href='https://www.researchgate.net/publication/372669736_Creating_Large_Language_Model_Applications_Utilizing_LangChain_A_Primer_on_Developing_LLM_Apps_Fast' target='_blank'>This paper is the data source for this solution</a>
|
82 |
Have you already used RAG? feel free to suggest improvements
|
|
|
1 |
import gradio as gr
|
2 |
from operator import itemgetter
|
3 |
import os
|
4 |
+
import pandas as pd
|
5 |
|
6 |
from langchain_community.vectorstores import FAISS
|
7 |
from langchain_core.output_parsers import StrOutputParser
|
|
|
53 |
|
54 |
qa = RetrievalQA.from_chain_type(
|
55 |
llm=hf, chain_type="stuff", retriever=retriever, return_source_documents=False)
|
56 |
+
queries=pd.read_csv('./interactions/queries.csv')
|
57 |
|
58 |
def greet(Question):
|
59 |
answer = qa({"query": Question})
|
60 |
|
61 |
pa=[a.split("Helpful Answer: ") for a in answer.get('result').split('\n') if "Helpful Answer" in a]
|
62 |
+
new=pd.DataFrame({'query':Question,'response':pa[0][-1]})
|
63 |
+
queries.append(new)
|
64 |
+
queries.to_csv('./interactions/queries.csv')
|
65 |
return pa[0][-1]
|
66 |
|
67 |
if __name__ == "__main__":
|
|
|
71 |
description = """
|
72 |
<img src="https://superagi.com/wp-content/uploads/2023/10/Introduction-to-RAGA-Retrieval-Augmented-Generation-and-Actions-1200x600.png.webp" width=100%>
|
73 |
<br>
|
74 |
+
Demo using Vector store-backed retriever. This space demonstrate application of RAG on a small model and its effectiveness, I used small model because of the space constraint. The current space runs on mere <b>2GB of RAM</b>, hence there is some delay in generating output. Test this to your hearts content and let me know your thoughts, I will keep updating this space with tiny improvements on architecture and design
|
75 |
<ul>
|
76 |
+
<li>model: TinyLlama/TinyLlama-1.1B-Chat-v1.0</li>
|
77 |
+
<li></li>
|
78 |
+
|
79 |
<li>update1: This space now does not create a faiss index on build, it uses a locally saved faiss index</li>
|
80 |
<li>update2: This space now uses google/gemma-1.1-2b-it model to generate output, reduces the response time to 1/3rd</li>
|
81 |
</ul>
|
|
|
84 |
<ul>You can ask questions like -
|
85 |
<li>What is langchain framework?</li>
|
86 |
<li>What is Action Agent?</li>
|
87 |
+
<li>What are forms of memory implementation in langchain</li>
|
88 |
+
<li>What is question answering from documents</li>
|
89 |
</ul>
|
90 |
Go through this paper here to find more about langchain and then test how this solution performs. <a href='https://www.researchgate.net/publication/372669736_Creating_Large_Language_Model_Applications_Utilizing_LangChain_A_Primer_on_Developing_LLM_Apps_Fast' target='_blank'>This paper is the data source for this solution</a>
|
91 |
Have you already used RAG? feel free to suggest improvements
|