kleinhoellental commited on
Commit
01af525
·
1 Parent(s): 88abdea

Upload language_model.py

Browse files
Files changed (1) hide show
  1. modules/language_model.py +29 -0
modules/language_model.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #######################################################################################################
3
+ # IMPORT
4
+ #######################################################################################################
5
+
6
+ from transformers import pipeline
7
+ import pandas as pd
8
+
9
+ #######################################################################################################
10
+ # Function
11
+ #######################################################################################################
12
+
13
+ def TAPAS(question, table_main):
14
+ """
15
+ Processing the question using an expression and the main and geom table.
16
+
17
+ Args:
18
+ question (str): the question.
19
+ table_main (df): main table
20
+
21
+ Returns:
22
+ answer (str): answer to the question
23
+ """
24
+
25
+ # set up a TAPAS pipeline for table-based question answering
26
+ tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
27
+
28
+ answer = tqa(table=table_main, query=question)
29
+ return answer,