Spaces:
Sleeping
Sleeping
Commit
·
88abdea
1
Parent(s):
3072ee1
Upload language_model.py
Browse files- language_model.py +29 -0
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,
|