{"id":14181815,"url":"https://github.com/taoyds/typesql","last_synced_at":"2025-08-07T14:31:39.271Z","repository":{"id":32124768,"uuid":"129334631","full_name":"taoyds/typesql","owner":"taoyds","description":"TypeSQL: Knowledge-based Type-Aware Neural Text-to-SQL Generation","archived":false,"fork":false,"pushed_at":"2022-04-15T17:19:31.000Z","size":42,"stargazers_count":112,"open_issues_count":4,"forks_count":31,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-08-18T11:13:40.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taoyds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-13T02:08:43.000Z","updated_at":"2024-05-20T17:22:58.000Z","dependencies_parsed_at":"2022-08-07T17:15:22.869Z","dependency_job_id":null,"html_url":"https://github.com/taoyds/typesql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taoyds%2Ftypesql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taoyds%2Ftypesql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taoyds%2Ftypesql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taoyds%2Ftypesql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taoyds","download_url":"https://codeload.github.com/taoyds/typesql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229052496,"owners_count":18012564,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-18T11:04:14.134Z","updated_at":"2024-12-10T11:30:19.003Z","avatar_url":"https://github.com/taoyds.png","language":"Python","funding_links":[],"categories":["💬 Classic Model","Python"],"sub_categories":[],"readme":"## TypeSQL\n\nSource code accompanying our NAACL 2018 paper:[TypeSQL: Knowledge-based Type-Aware Neural Text-to-SQL Generation\n](https://arxiv.org/abs/1804.09769)\n\n:+1: `03/20/2022`: **We open-sourced a simple but SOTA model (just T5) for the task! Please check out our code in the [UnifiedSKG repo](https://github.com/hkunlp/unifiedskg)!!**\n\n#### Environment Setup\n\n1. The code uses Python 2.7 and [Pytorch 0.2.0](https://pytorch.org/previous-versions/) GPU.\n2. Install Python dependency: `pip install -r requirements.txt`\n3. Install Pytorch 0.2.0: `conda install pytorch=0.2.0 cuda91 -c pytorch`. Replace cuda91 to whichever cuda version you have.\n\n#### Download Data and Embeddings\n\n1. Download the zip data file at the [Google Drive](https://drive.google.com/file/d/1CGIRCjwf2bgmWl3UyjY1yJpP4nU---Q0/view?usp=sharing), and put it in the root dir.\n2. Download the pretrained [Glove](https://nlp.stanford.edu/data/wordvecs/glove.42B.300d.zip) and the [paraphrase embedding](https://drive.google.com/file/d/1iWTowxEG1-KZyq-fHP6cb6dNqMh4eHiN/view?usp=sharing) `para-nmt-50m/data/paragram_sl999_czeng.txt`. Put the unziped glove and para-nmt-50m folders in the root dir.\n\n#### Train Models\n\n1. To use knowledge graph types:\n```\n  mkdir saved_model_kg\n  python train.py --sd saved_model_kg\n```\n\n2. To use DB content types:\n```\n   mkdir saved_model_con\n   python train.py --sd saved_model_con --db_content 1\n```\n\n#### Test Models\n\n1. Test Model with knowledge graph types:\n```\npython test.py --sd saved_model_kg\n```\n2. Test Model with knowledge graph types:\n```\npython test.py --sd saved_model_con --db_content 1\n```\n\n#### Get Data Types\n\n1. Get a Google Knowledge Graph Search API Key by following the [link](https://developers.google.com/knowledge-graph/)\n2. Search knowledge graph to get entities:\n```\npython get_kg_entities.py [Google freebase API Key] [input json file] [output json file]\n```\n3. Use detected knowledge graph entites and DB content to group questions and create type attributes in data files:\n```\npython data_process_test.py --tok [output json file generated at step 2] --table TABLE_FILE --out OUTPUT_FILE [--data_dir DATA_DIRECTORY] [--out_dir OUTPUT_DIRECTORY]\n\npython data_process_train_dev.py --tok [output json file generated at step 2] --table TABLE_FILE --out OUTPUT_FILE [--data_dir DATA_DIRECTORY] [--out_dir OUTPUT_DIRECTORY]\n```\n\n#### Acknowledgement\n\nThe implementation is based on [SQLNet](https://github.com/xiaojunxu/SQLNet). Please cite it too if you use this code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaoyds%2Ftypesql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaoyds%2Ftypesql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaoyds%2Ftypesql/lists"}