{"id":19520165,"url":"https://github.com/osu-nlp-group/fl4semanticparsing","last_synced_at":"2025-06-20T10:08:42.864Z","repository":{"id":170854881,"uuid":"643807021","full_name":"OSU-NLP-Group/FL4SemanticParsing","owner":"OSU-NLP-Group","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-04T02:20:57.000Z","size":13423,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-26T00:26:02.061Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OSU-NLP-Group.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-05-22T07:43:54.000Z","updated_at":"2024-03-02T16:25:50.000Z","dependencies_parsed_at":"2024-03-04T03:52:44.752Z","dependency_job_id":null,"html_url":"https://github.com/OSU-NLP-Group/FL4SemanticParsing","commit_stats":null,"previous_names":["osu-nlp-group/fl4semanticparsing"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OSU-NLP-Group/FL4SemanticParsing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OSU-NLP-Group%2FFL4SemanticParsing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OSU-NLP-Group%2FFL4SemanticParsing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OSU-NLP-Group%2FFL4SemanticParsing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OSU-NLP-Group%2FFL4SemanticParsing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OSU-NLP-Group","download_url":"https://codeload.github.com/OSU-NLP-Group/FL4SemanticParsing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OSU-NLP-Group%2FFL4SemanticParsing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260924534,"owners_count":23083524,"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-11-11T00:24:09.069Z","updated_at":"2025-06-20T10:08:37.829Z","avatar_url":"https://github.com/OSU-NLP-Group.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lorar\nCode and datasets for the ACL'23 long paper \"[Federated Learning for Semantic Parsing: Task Formulation, Evaluation Setup, New Algorithms](https://arxiv.org/abs/2305.17221)\"\n\nPlease kindly cite the paper if you use the code or any resources in this repo:\n\n```bib\n@inproceedings{zhang2023federated,\n      title={Federated Learning for Semantic Parsing: Task Formulation, Evaluation Setup, New Algorithms}, \n      author={Tianshu Zhang and Changchang Liu and Wei-Han Lee and Yu Su and Huan Sun},\n      booktitle={Proceedings of the 61th Annual Meeting of the Association for Computational Linguistics},\n      year={2023},\n}\n```\n\nRelease progress:\n- :ballot_box_with_check: Dataset for FL training and evaluation (completed)\n- :ballot_box_with_check: Code for FL training and evaluation (completed)\n- :ballot_box_with_check: Dataset for Fine-tuning and Centralized training and evaluation (completed)\n- :ballot_box_with_check: Code for Fine-tuning and Centralized training and evaluation (completed)\n\u003c!-- - :white_large_square: Code for Fine-tuning and Centralized training (TODO) --\u003e\n\nThe figure below is the overall structure of Lorar.\n![avatar](Lorar.png)\n\n## Dataset\nWe release our dataset (both for training and evaluation) for three training paradigms (finetune, centralized training, FL):\"[data_release.zip](https://buckeyemailosu-my.sharepoint.com/:u:/g/personal/zhang_11535_buckeyemail_osu_edu/EU1DeWXZQ4VNg7W6YlClmp4BBtsIffGcUMcyDTpRYk0p4A?e=qiaUWL)\".\nDownload the data and upzip the folder. Put the data folder to the path as `/Lorar/text2sql/data_release/`.\n\n\n## Installation\nAfter `git clone` this repository, please run the following command to install our dependencies.\n\n```bash\ncd Lorar/text2sql\nconda env create -f Lorar.yaml\nconda activate Lorar\nsudo apt install libopenmpi-dev\nconda install mpi4py\npip install -r Lorar_requirements.txt\n```\n\n### WandB setup\n\nSetup [WandB](https://wandb.ai/) for logging (registration needed):\n``````shell\nexport WANDB_API_KEY=YOUR_WANDB_API_KEY\nexport WANDB_PROJECT=YOUR_PROJECT_NAME\nexport WANDB_ENTITY=YOUR_TEAM_NAME\n``````\n\n\n## How to run the examples\n\nWe provide 4 different weighting mechanisms for three FL algorithms: FedOPT, FedAvg and FedProx. We provide examples for fedOPT and its four weighting mechanisms and also provide steps on how to run them below. We have provided scripts for FedAvg and FedProx as well.\n\nFor each of these make sure the datapaths and the gpu config paths are given correctly in the `fedXXX_8clients.yaml` file and also make sure the number of clients per round and number of workers match\n\n**FedOPT**\n\n\u003c!-- Read `data/README.md` for more details of datasets available (TODO) --\u003e\n\nAdjust the hyperparameters in `text2sql/config/fedopt_8clients.yaml` and make sure data file paths are correct. More specifically, set the `data_file_path` as `/Lorar/text2sql/data_release/FL_data/question_split_full_michigan_data_w_dev_revise_table_schema.h5`, and set the `data_partition_file_path` as `/Lorar/text2sql/data_release/FL_data/michigan_question_split_full_partition_index_w_dev_revise_table_schema.h5`.\n\nIn this file, set `weighting_mechanism` as `original` for FedOPT, `loss_reduction_only` for FedOPT_lr (only loss reduction based weight, no training size control), `equal` for FedOPT_equal (all clients have the equal weight during the global model update), `lorar` for FedOPT_lorar (our proposed re-weighting mechanism).\n\nTo run FedOPT using MPI simulator on 8 clients follow the following steps:\n\n\n```bash\n1. cd text2sql/\n2. bash run_fedopt_8clients.sh 8\n```\n\n**Finetuning**\n\nTake GeoQuery as an example:\n\nBefore run the scripts below, first change the data path in `text2sql/third_party_UnifiedSKG/train.py`. More specifically, set two `cache_root` as `/Lorar/text2sql/data_release/finetune_centralized_data/cache`; set `table_dict_path` as `/Lorar/text2sql/data_release/finetune_centralized_data/table_dict.json`.\n\nTrain\n```bash\n1. cd text2sql/third_party_UnifiedSKG/\n2. python train.py --seed 2002 --cfg Salesforce/T5_base_finetune_geoquery_with_cell_value.cfg --run_name T5_base_finetune_geoquery --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 8 --metric_for_best_model eval_META_TUNING/geoquery_with_cell.cfg/exact_string_match --greater_is_better true --save_strategy steps --save_steps 8 --save_total_limit 2 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 100 --adafactor true --learning_rate 1e-4 --do_train --do_eval --do_predict --predict_with_generate --output_dir  ./output --overwrite_output_dir --per_device_train_batch_size 8 --per_device_eval_batch_size 128 --generation_num_beams 1 --generation_max_length 512 --input_max_length 1024 --ddp_find_unused_parameters false\n```\n\nInference\n```bash\n1. cd text2sql/third_party_UnifiedSKG/\n2. python train.py --seed 2002 --cfg Salesforce/T5_base_finetune_geoquery_with_cell_value.cfg --run_name T5_base_finetune_geoquery_inference --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 8 --metric_for_best_model eval_META_TUNING/geoquery_with_cell.cfg/exact_string_match --greater_is_better true --save_strategy steps --save_steps 8 --save_total_limit 2 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 0.0001 --adafactor true --learning_rate 1e-4 --do_train false --do_eval false --do_predict --predict_with_generate --output_dir  ./output --overwrite_output_dir --per_device_train_batch_size 8 --per_device_eval_batch_size 128 --generation_num_beams 1 --generation_max_length 512 --input_max_length 1024 --ddp_find_unused_parameters false --load_weights_from /home/zhang.11535/Lorar/text2sql/output/third_party_UnifiedSKG/T5_base_finetune_geoquery\n```\n\n**Centralized Training**\n\nBefore run the scripts below, first change the data path in `text2sql/third_party_UnifiedSKG/train_centralized_test_predictions_question_split.py`. More specifically, set two `cache_root` as `/Lorar/text2sql/data_release/finetune_centralized_data/cache`; set `table_dict_path` as `/Lorar/text2sql/data_release/finetune_centralized_data/table_dict.json`.\n\nTrain\n```bash\n1. cd text2sql/third_party_UnifiedSKG/\n2. python train_centralized_test_predictions_question_split.py --seed 1002 --cfg Salesforce/T5_base_finetune_centralized_with_cell_value_question_mix_eval.cfg --run_name T5_base_finetune_centralized --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 400 --metric_for_best_model eval_META_TUNING/centralized_with_cell.cfg/exact_string_match --greater_is_better true --save_strategy steps --save_steps 400 --save_total_limit 2 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 200 --adafactor true --learning_rate 1e-4 --do_train --do_eval --do_predict --predict_with_generate --output_dir ./output --overwrite_output_dir --per_device_train_batch_size 8 --per_device_eval_batch_size 16 --generation_num_beams 1 --generation_max_length 512 --input_max_length 1024 --ddp_find_unused_parameters false\n```\n\nInference\n```bash\n1. cd text2sql/third_party_UnifiedSKG/\n2. python train_centralized_test_predictions_question_split.py --seed 1002 --cfg Salesforce/T5_base_finetune_centralized_with_cell_value_question_mix_eval.cfg --run_name T5_base_finetune_centralized_inference --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 1 --metric_for_best_model eval_META_TUNING/centralized_with_cell.cfg/exact_string_match --greater_is_better true --save_strategy steps --save_steps 1 --save_total_limit 2 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 0.0002 --adafactor true --learning_rate 1e-4 --do_train false --do_eval false --do_predict --predict_with_generate --output_dir ./output --overwrite_output_dir --per_device_train_batch_size 16 --per_device_eval_batch_size 128 --generation_num_beams 1 --generation_max_length 512 --input_max_length 1024 --ddp_find_unused_parameters false --load_weights_from /home/zhang.11535/Lorar/text2sql/third_party_UnifiedSKG/output/T5_base_finetune_centralized\n```\n\n## Misc\n\nOur codebase is adapted from UnifiedSKG, FedML, FedNLP and Picard. We will keep maintaining and cleaning our code. \nIf you have any questions, please feel free to contact zhang.11535[AT]buckeyemail[DOT]osu[DOT]edu or open an issue so we can help you better and quicker :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosu-nlp-group%2Ffl4semanticparsing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosu-nlp-group%2Ffl4semanticparsing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosu-nlp-group%2Ffl4semanticparsing/lists"}