anakin87 commited on
Commit
9abea4e
1 Parent(s): 589613f

support for different NLI models; early stopping in entailment

Browse files
Rock_fact_checker.py CHANGED
@@ -76,6 +76,7 @@ def main():
76
  with st.spinner("🧠    Performing neural search on documents..."):
77
  try:
78
  st.session_state.results = query(statement, RETRIEVER_TOP_K)
 
79
  time_end = time.time()
80
  print(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()))
81
  print(f"elapsed time: {time_end - time_start}")
 
76
  with st.spinner("🧠    Performing neural search on documents..."):
77
  try:
78
  st.session_state.results = query(statement, RETRIEVER_TOP_K)
79
+ print(query)
80
  time_end = time.time()
81
  print(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()))
82
  print(f"elapsed time: {time_end - time_start}")
app_utils/backend_utils.py CHANGED
@@ -77,9 +77,9 @@ def query(statement: str, retriever_top_k: int = 5):
77
  agg_neu += neu * doc.score
78
  agg_ent += ent * doc.score
79
 
80
- # if in the first 3 documents there is a strong evidence of entailment/contradiction,
81
- # there is non need to consider less relevant documents
82
- if i == 2 and max(agg_con, agg_ent) / scores > 0.5:
83
  results["documents"] = results["documents"][: i + 1]
84
  break
85
 
 
77
  agg_neu += neu * doc.score
78
  agg_ent += ent * doc.score
79
 
80
+ # if in the first documents there is a strong evidence of entailment/contradiction,
81
+ # there is no need to consider less relevant documents
82
+ if max(agg_con, agg_ent) / scores > 0.5:
83
  results["documents"] = results["documents"][: i + 1]
84
  break
85
 
app_utils/config.py CHANGED
@@ -1,7 +1,16 @@
 
 
 
 
1
  INDEX_DIR = "data/index"
2
  STATEMENTS_PATH = "data/statements.txt"
3
 
4
  RETRIEVER_MODEL = "sentence-transformers/msmarco-distilbert-base-tas-b"
5
  RETRIEVER_MODEL_FORMAT = "sentence_transformers"
6
  RETRIEVER_TOP_K = 5
7
- NLI_MODEL = "valhalla/distilbart-mnli-12-1"
 
 
 
 
 
 
1
+ from curses.ascii import NL
2
+ from logging import exception
3
+ import streamlit as st
4
+
5
  INDEX_DIR = "data/index"
6
  STATEMENTS_PATH = "data/statements.txt"
7
 
8
  RETRIEVER_MODEL = "sentence-transformers/msmarco-distilbert-base-tas-b"
9
  RETRIEVER_MODEL_FORMAT = "sentence_transformers"
10
  RETRIEVER_TOP_K = 5
11
+
12
+ try:
13
+ NLI_MODEL = st.secrets['NLI_MODEL']
14
+ except:
15
+ NLI_MODEL = "valhalla/distilbart-mnli-12-1"
16
+ print(f'Used NLI model: {NLI_MODEL}')
data/statements.txt CHANGED
@@ -18,7 +18,6 @@ The White Stripes were a trio
18
  The White Stripes were composed by Jack White and Meg White
19
  Scorpions is a German trap band
20
  Sepultura is a heavy metal band
21
- Toxicity is a song by System of a down
22
  System of a down is a Italian band
23
  The Cure is a pop band
24
  Mick Jagger loves pasta
@@ -36,3 +35,14 @@ Guns N' Roses formed in 1987
36
  Izzy Stradlin took part in Guns N' Roses
37
  Grunge was born in Seattle
38
  Dave Grohl played in Nirvana and Foo Fighters
 
 
 
 
 
 
 
 
 
 
 
 
18
  The White Stripes were composed by Jack White and Meg White
19
  Scorpions is a German trap band
20
  Sepultura is a heavy metal band
 
21
  System of a down is a Italian band
22
  The Cure is a pop band
23
  Mick Jagger loves pasta
 
35
  Izzy Stradlin took part in Guns N' Roses
36
  Grunge was born in Seattle
37
  Dave Grohl played in Nirvana and Foo Fighters
38
+ John Michael Stipe was part of the R.E.M.
39
+ Eric Clapton did some gigs with Dire Straits
40
+ Mark Knopfler plays drums
41
+ "La Bamba" is a hit by Ritchie Valens
42
+ Nico took part in the Velvet Underground
43
+ David Bowie appears in Twin Peaks
44
+ The Cure made dark songs
45
+ Cannibal Corpse is a pop punk band
46
+ Slipknot wear masks
47
+ Toto have sold many records
48
+ The verve were a prominent English band