tableQA
1.0.0
Tabular Data에서 자연 언어를 쿼리하기위한 AI 도구. 변압기의 QA 모델을 사용하여 빌드.
이 작업은 다음 논문에 설명되어 있습니다.
TableQuery : Abhijith Neil Abraham, Fariz Rahman 및 Damanpreet Kaur의 자연 언어로 테이블 데이터 쿼리.
TableQA를 사용하는 경우 종이를 인용하십시오.
다음은 이것이 어떻게 작동하는지 이해하는 자세한 블로그입니다.
표 형 데이터는 다음과 같습니다.
.
.
pip install tableqa
git clone https://github.com/abhijithneilabraham/tableQA
cd tableqa
python setup.py install
from tableqa.agent import Agent
agent=Agent(df) #input your dataframe
response=agent.query_db("Your question here")
print(response)
sql=agent.get_query("Your question here")
print(sql) #returns an sql query
{
"name": DATABASE NAME,
"keywords":[DATABASE KEYWORDS],
"columns":
[
{
"name": COLUMN 1 NAME,
"mapping":{
CATEGORY 1: [CATEGORY 1 KEYWORDS],
CATEGORY 2: [CATEGORY 2 KEYWORDS]
}
},
{
"name": COLUMN 2 NAME,
"keywords": [COLUMN 2 KEYWORDS]
},
{
"name": "COLUMN 3 NAME",
"keywords": [COLUMN 3 KEYWORDS],
"summable":"True"
}
]
}
summable 가능합니다. 예를 들어. Death Count,Cases 등은 이미 카운트를 나타내는 값으로 구성됩니다.예제 (수동 스키마 포함) :
from tableqa.agent import Agent
agent=Agent(df,schema) #pass the dataframe and schema objects
response=agent.query_db("how many people died of stomach cancer in 2011")
print(response)
#Response =[(22,)]
from tableqa.agent import Agent
agent = Agent(df, schema_file, 'postgres', username='username', password='password', database='DBname', host='localhost', port=5432, aws_db=False)
response=agent.query_db("how many people died of stomach cancer in 2011")
print(response)
#Response =[(22,)]
from tableqa.agent import Agent
agent = Agent(df, schema_file, 'mysql', username='username', password='password', database='DBname', host='localhost', port=5432, aws_db=False)
response=agent.query_db("how many people died of stomach cancer in 2011")
print(response)
#Response =[(22,)]
Amazon RDS에서 MySQL DB 인스턴스를 작성하려면 문서의 1 단계를 참조하십시오. 엔진 탭에서 PostgreSQL을 선택하여 PostgreSQL DB 인스턴스를 생성하기 위해 동일한 단계를 따라갈 수 있습니다. Amazon RDS의 데이터베이스 연결 세부 정보에서 사용자 이름, 비밀번호, 데이터베이스, 엔드 포인트 및 포트를 얻습니다.
from tableqa.agent import Agent
agent = Agent(df, schema_file, 'postgres', username='Master username', password='Master password', database='DB name', host='Endpoint', port='Port', aws_db=True)
response=agent.query_db("how many people died of stomach cancer in 2011")
print(response)
#Response =[(22,)]
sql=agent.get_query("How many people died of stomach cancer in 2011")
print(sql)
#sql query: SELECT SUM(Death_Count) FROM cancer_death WHERE Cancer_site = "Stomach" AND Year = "2011"
csv_path="/content/tableQA/tableqa/cleaned_data"
schema_path="/content/tableQA/tableqa/schema"
agent=Agent(csv_path,schema_path)
csv_path="s3://{bucket}/cleaned_data"
schema_path="s3://{bucket}/schema"
agent = Agent(csv_path, schema_path, aws_s3=True, access_key_id=access_key_id, secret_access_key=secret_access_key)
작업 공간에 가입하십시오 : 슬랙