Spaces:
Sleeping
Sleeping
Pratik Dwivedi
commited on
Commit
·
f3ffdfc
1
Parent(s):
a00f355
wow
Browse files- .gitignore +2 -0
- app.py +3 -3
- secrets.toml +1 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
.env
|
2 |
+
.gitattributes
|
app.py
CHANGED
@@ -4,7 +4,7 @@ from langchain.text_splitter import CharacterTextSplitter
|
|
4 |
from langchain_community.embeddings import HuggingFaceInstructEmbeddings
|
5 |
from langchain_community.vectorstores import FAISS
|
6 |
from langchain.chains import ConversationalRetrievalChain
|
7 |
-
from
|
8 |
from langchain.memory import ConversationBufferMemory
|
9 |
|
10 |
def make_vectorstore(embeddings):
|
@@ -31,7 +31,7 @@ def get_conversation(vectorstore):
|
|
31 |
memory = ConversationBufferMemory(memory_key="chat_history",return_messages=True,)
|
32 |
|
33 |
conversation_chain = ConversationalRetrievalChain.from_chain_type(
|
34 |
-
|
35 |
chain_type="stuff",
|
36 |
retriever=vectorstore.as_retriever(),
|
37 |
memory=memory)
|
@@ -45,7 +45,7 @@ def get_response(conversation_chain, query):
|
|
45 |
|
46 |
def main():
|
47 |
st.title("BetterZila RAG Enabled LLM")
|
48 |
-
embeddings = HuggingFaceInstructEmbeddings(
|
49 |
vectorstore = make_vectorstore(embeddings)
|
50 |
conversation_chain = get_conversation(vectorstore)
|
51 |
queries = ["Can you give me an example from history where the enemy was crushed totally from the book?", "What's the point of making myself less accessible?", "Can you tell me the story of Queen Elizabeth I from this 48 laws of power book?"]
|
|
|
4 |
from langchain_community.embeddings import HuggingFaceInstructEmbeddings
|
5 |
from langchain_community.vectorstores import FAISS
|
6 |
from langchain.chains import ConversationalRetrievalChain
|
7 |
+
from langchain_community.llms import HuggingFaceHub
|
8 |
from langchain.memory import ConversationBufferMemory
|
9 |
|
10 |
def make_vectorstore(embeddings):
|
|
|
31 |
memory = ConversationBufferMemory(memory_key="chat_history",return_messages=True,)
|
32 |
|
33 |
conversation_chain = ConversationalRetrievalChain.from_chain_type(
|
34 |
+
llm=HuggingFaceHub(repo_id="google/flan-t5-xxl", model_kwargs={"temperature":0.5, "max_length":512}, huggingfacehub_api_token = st.secrets["hf_token"]),
|
35 |
chain_type="stuff",
|
36 |
retriever=vectorstore.as_retriever(),
|
37 |
memory=memory)
|
|
|
45 |
|
46 |
def main():
|
47 |
st.title("BetterZila RAG Enabled LLM")
|
48 |
+
embeddings = HuggingFaceInstructEmbeddings(model_name="google/t5-v1_1-xl", model_kwargs = {'device': 'cpu'})
|
49 |
vectorstore = make_vectorstore(embeddings)
|
50 |
conversation_chain = get_conversation(vectorstore)
|
51 |
queries = ["Can you give me an example from history where the enemy was crushed totally from the book?", "What's the point of making myself less accessible?", "Can you tell me the story of Queen Elizabeth I from this 48 laws of power book?"]
|
secrets.toml
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
hf_token="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"
|