nazneen commited on
Commit
176a8a6
·
1 Parent(s): 595a64b

rlhf with langchain

Browse files
Files changed (3) hide show
  1. __pycache__/utils.cpython-310.pyc +0 -0
  2. app.py +15 -10
  3. data +1 -0
__pycache__/utils.cpython-310.pyc ADDED
Binary file (977 Bytes). View file
 
app.py CHANGED
@@ -14,6 +14,10 @@ import json
14
  from utils import force_git_push
15
  import threading
16
 
 
 
 
 
17
  # These variables are for storing the mturk HITs in a Hugging Face dataset.
18
  if Path(".env").is_file():
19
  load_dotenv(".env")
@@ -49,7 +53,8 @@ f_stop = threading.Event()
49
  asynchronous_push(f_stop)
50
 
51
  # Now let's run the app!
52
- chatbot = pipeline(model="microsoft/DialoGPT-medium")
 
53
 
54
  demo = gr.Blocks()
55
 
@@ -76,14 +81,14 @@ with demo:
76
  # Generate model prediction
77
  # Default model: distilbert-base-uncased-finetuned-sst-2-english
78
  def _predict(txt, state):
79
- conversation_1 = Conversation(past_user_inputs=state["past_user_inputs"].copy(), generated_responses=state["generated_responses"].copy())
80
- conversation_2 = Conversation(past_user_inputs=state["past_user_inputs"].copy(), generated_responses=state["generated_responses"].copy())
81
- conversation_1.add_user_input(txt)
82
- conversation_2.add_user_input(txt)
83
- conversation_1 = chatbot(conversation_1, do_sample=True, seed=420)
84
- conversation_2 = chatbot(conversation_2, do_sample=True, seed=69)
85
- response_1 = conversation_1.generated_responses[-1]
86
- response_2 = conversation_2.generated_responses[-1]
87
 
88
  state["cnt"] += 1
89
 
@@ -199,4 +204,4 @@ with demo:
199
  _js=refresh_app_js,
200
  )
201
 
202
- demo.launch()
 
14
  from utils import force_git_push
15
  import threading
16
 
17
+ #langchain imports
18
+ from langchain import HuggingFacePipeline, LLMChain, PromptTemplate
19
+ from langchain.chains.conversation.memory import ConversationalBufferWindowMemory
20
+
21
  # These variables are for storing the mturk HITs in a Hugging Face dataset.
22
  if Path(".env").is_file():
23
  load_dotenv(".env")
 
53
  asynchronous_push(f_stop)
54
 
55
  # Now let's run the app!
56
+ pipe = pipeline(model="google/flan-t5-xl-qa", tokenizer="google/flan-t5-xl", task="text2text-generation")
57
+ chatbot = HuggingFacePipeline(pipeline=pipe)
58
 
59
  demo = gr.Blocks()
60
 
 
81
  # Generate model prediction
82
  # Default model: distilbert-base-uncased-finetuned-sst-2-english
83
  def _predict(txt, state):
84
+ # conversation_1 = Conversation(past_user_inputs=state["past_user_inputs"].copy(), generated_responses=state["generated_responses"].copy())
85
+ # conversation_2 = Conversation(past_user_inputs=state["past_user_inputs"].copy(), generated_responses=state["generated_responses"].copy())
86
+ # conversation_1.add_user_input(txt)
87
+ # conversation_2.add_user_input(txt)
88
+ conversation_1 = chatbot(txt, do_sample=True, seed=420)
89
+ conversation_2 = chatbot(txt, do_sample=True, seed=69)
90
+ response_1 = conversation_1.generated_text[-1]
91
+ response_2 = conversation_2.generated_text[-1]
92
 
93
  state["cnt"] += 1
94
 
 
204
  _js=refresh_app_js,
205
  )
206
 
207
+ demo.launch(share=True)
data ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit b539037325ecb230f37bda2d9f8daad6c23db37c