How wangpinggl/treqs works
TREQS is a PyTorch text-to-SQL system for questions about MIMIC-III electronic medical records. The principal workflow takes tokenized natural-language questions and generates SQL through a seq2seq model; the README describes training, validation, testing, and query evaluation. A separate data-preparation branch builds sampled MIMICSQL tables from MIMIC-III data. The source excerpts show model construction and parts of batch processing, but not the full decoding or evaluation path, so those links are limited to documented or directly evidenced relationships.
Main entry points: model.py Seq2SQL model · main.py Task entry point · model_seq2seq_base.py Seq2seq engine · process_batch_cqa_v1.py SQL batch processor
Components 21
Model runtime
- Task entry point
main.py - Seq2SQL model
model.py - Seq2seq engine
seq2sql/model_seq2seq_base.py - Token embeddings
LeafNATS/modules/embedding/nats_embedding.py - RNN encoder
LeafNATS/modules/encoder/encoder_rnn.py - Encoder bridge
LeafNATS/modules/encoder2decoder/nats_encoder2decoder.py - Encoder attention
LeafNATS/modules/attention/nats_attention_encoder.py - Decoder attention
LeafNATS/modules/attention/nats_attention_decoder.py - Word copying
LeafNATS/modules/decoding/word_copy.py - Generated SQL
Question and data
- SQL batch processor
LeafNATS/data/seq2sql/process_batch_cqa_v1.py - Vocabulary utilities
LeafNATS/data/utils.py - MIMICSQL questions
Medical data preparation
- MIMIC-III source data
- Database preparation
evaluation/process_mimic_db.py - Clinical table builders
evaluation/process_mimic_db/process_tables.py - Sampled patient database
Evaluation
- Query evaluation
evaluation/utils.py - Generation evaluation
LeafNATS/eval_scripts/eval_pyrouge_v2.py
Other components
- Question author
- Evaluation operator
Connections 21
- Question author → Task entry point: submits task
main.py - Task entry point → Seq2SQL model: instantiates
main.py - Seq2SQL model → Seq2seq engine: inherits from
model.py - Seq2SQL model → SQL batch processor: processes batches
model.py - Seq2seq engine → Vocabulary utilities: builds vocabulary
seq2sql/model_seq2seq_base.py - Seq2SQL model → Token embeddings: constructs and uses
model.py - Seq2SQL model → RNN encoder: constructs and calls
model.py - Seq2SQL model → Encoder bridge: calls
model.py - Seq2SQL model → Encoder attention: constructs
model.py - Seq2SQL model → Decoder attention: constructs
model.py - Seq2seq engine → Word copying: uses for decoding
seq2sql/model_seq2seq_base.py - MIMICSQL questions → SQL batch processor: provides tokenized questions
- SQL batch processor → Seq2SQL model: provides tensors
model.py - Seq2SQL model → Generated SQL: generates
- MIMIC-III source data → Clinical table builders: supplies records
evaluation/process_mimic_db/process_tables.py - Database preparation → Clinical table builders: calls builders
evaluation/process_mimic_db.py - Database preparation → Sampled patient database: writes sampled tables
evaluation/process_mimic_db.py - Evaluation operator → Query evaluation: runs query evaluation
- Task entry point → Generation evaluation: dispatches evaluate
main.py - Generated SQL → Query evaluation: evaluated against
- Sampled patient database → Query evaluation: provides database