CogwiseAI commited on
Commit
1dbac02
·
1 Parent(s): 3009e98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -78,6 +78,9 @@ model_name = "tiiuae/falcon-7b-instruct"
78
  model = AutoModelForCausalLM.from_pretrained(model_name)
79
  tokenizer = AutoTokenizer.from_pretrained(model_name)
80
 
 
 
 
81
  def write_top_bar():
82
  col1, col2, col3 = st.columns([1,10,2])
83
  with col1:
@@ -109,8 +112,11 @@ def handle_input():
109
  if len(chat_history) == MAX_HISTORY_LENGTH:
110
  chat_history = chat_history[:-1]
111
 
 
 
 
112
  # Generate response using the model
113
- inputs = tokenizer.encode(input, return_tensors="pt")
114
  outputs = model.generate(inputs)
115
  answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
116
 
@@ -122,6 +128,12 @@ def handle_input():
122
  })
123
  st.session_state.input = ""
124
 
 
 
 
 
 
 
125
  def write_user_message(md):
126
  col1, col2 = st.columns([1,12])
127
 
 
78
  model = AutoModelForCausalLM.from_pretrained(model_name)
79
  tokenizer = AutoTokenizer.from_pretrained(model_name)
80
 
81
+ # Load the dataset
82
+ dataset = load_dataset("nisaar/Lawyer_GPT_India")
83
+
84
  def write_top_bar():
85
  col1, col2, col3 = st.columns([1,10,2])
86
  with col1:
 
112
  if len(chat_history) == MAX_HISTORY_LENGTH:
113
  chat_history = chat_history[:-1]
114
 
115
+ # Find the most similar example in the dataset
116
+ closest_example = find_closest_example(input, dataset) # Implement your own logic to find the closest example
117
+
118
  # Generate response using the model
119
+ inputs = tokenizer.encode(closest_example, return_tensors="pt")
120
  outputs = model.generate(inputs)
121
  answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
122
 
 
128
  })
129
  st.session_state.input = ""
130
 
131
+ def find_closest_example(input, dataset):
132
+ # Implement your own logic to find the closest example in the dataset based on the user input
133
+ # You can use techniques like cosine similarity, semantic similarity, or any other approach that fits your dataset and requirements
134
+ # Return the closest example as a string
135
+ pass
136
+
137
  def write_user_message(md):
138
  col1, col2 = st.columns([1,12])
139