ishaan-mital commited on
Commit
1716bb2
·
1 Parent(s): 2b2d082
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -6,7 +6,7 @@ from langchain.embeddings.huggingface import HuggingFaceEmbeddings
6
  import torch
7
  import sentence_transformers
8
  from langchain.vectorstores import Pinecone
9
- from langchain import HuggingFaceHub
10
  from langchain.prompts import PromptTemplate
11
  from langchain.chains import RetrievalQA
12
 
@@ -55,15 +55,19 @@ vectorstore = Pinecone(
55
  )
56
 
57
 
58
- hub = HuggingFaceHub(repo_id = "HuggingFaceH4/zephyr-7b-beta",huggingfacehub_api_token={os.environ.get('API_KEY')})
59
- print(hub)
60
- prompt = PromptTemplate(
61
- input_variables=["question"],
62
- template="Question: {question}\nAnswer:",
 
 
 
 
63
  )
64
 
65
  rag_pipeline = RetrievalQA.from_chain_type(
66
- llm=hub, chain_type='stuff',
67
  retriever=vectorstore.as_retriever()
68
  )
69
 
 
6
  import torch
7
  import sentence_transformers
8
  from langchain.vectorstores import Pinecone
9
+ from langchain.llms.huggingface_text_gen_inference import HuggingFaceTextGenInference
10
  from langchain.prompts import PromptTemplate
11
  from langchain.chains import RetrievalQA
12
 
 
55
  )
56
 
57
 
58
+ API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
59
+ llm = HuggingFaceTextGenInference(
60
+ inference_server_url=API_URL,
61
+ max_new_tokens=512,
62
+ top_k=10,
63
+ top_p=0.95,
64
+ typical_p=0.95,
65
+ temperature=0.01,
66
+ repetition_penalty=1.03,
67
  )
68
 
69
  rag_pipeline = RetrievalQA.from_chain_type(
70
+ llm=llm, chain_type='stuff',
71
  retriever=vectorstore.as_retriever()
72
  )
73