jskinner215 commited on
Commit
89dd001
·
1 Parent(s): d575d33

Update tapas_utils.py

Browse files
Files changed (1) hide show
  1. tapas_utils.py +9 -0
tapas_utils.py CHANGED
@@ -2,6 +2,15 @@ from transformers import AutoTokenizer, AutoModelForTableQuestionAnswering
2
  import pandas as pd
3
  from io import StringIO
4
 
 
 
 
 
 
 
 
 
 
5
  def initialize_tapas():
6
  tokenizer = AutoTokenizer.from_pretrained("google/tapas-large-finetuned-wtq")
7
  model = AutoModelForTableQuestionAnswering.from_pretrained("google/tapas-large-finetuned-wtq")
 
2
  import pandas as pd
3
  from io import StringIO
4
 
5
+ from sentence_transformers import SentenceTransformer
6
+
7
+ retriever = SentenceTransformer("deepset/all-mpnet-base-v2-table")
8
+
9
+ def embed_table(table):
10
+ processed_table = "\n".join([table.to_csv(index=False)])
11
+ return retriever.encode(processed_table)
12
+
13
+
14
  def initialize_tapas():
15
  tokenizer = AutoTokenizer.from_pretrained("google/tapas-large-finetuned-wtq")
16
  model = AutoModelForTableQuestionAnswering.from_pretrained("google/tapas-large-finetuned-wtq")