Skip to content

qbxlvnf11/sql-where-clause-extraction-from-user-query

Repository files navigation

SQL Extraction with LLM

- SQL Extraction Example (GPT4o)

Output Example 1
  • Query: Please recommend an industrial public works program that can be supported until 2018.
{
   "sql_where_clause": "end_date >= '2018-01-01'",
   "explanation": "Filtering for programs that were available for support until at least the year 2018."
}
Output Example 2
  • Query: Youth Support Programs Available in 2022.
{
   "sql_where_clause": "target_audience = 'youth' AND start_date <= '2022-12-31' AND end_date >= '2022-01-01'",
   "explanation": "The filter condition searches for programs targeted at 'youth' that were available at any time during the year 2022."
}

- SQL Extraction Example (GPT-OSS 20b)

Output Example 1
  • Query: ...
...

Docker Environment

- Docker Build

docker build -t sql_extraction_test .

- Docker Run

docker run -it --gpus all --name sql_extraction_test_env --shm-size=64G -p {port}:{port} -e GRANT_SUDO=yes --user root -v {root_folder}:/workspace/sql_extraction_test -w /workspace/sql_extraction_test sql_extraction_test bash

- Docker Exec

docker exec -it sql_extraction_test_env bash

SQL Extraction Test

- SQL Extraction (GPT4o)

  • When using the GPT API, enter the API KEY (token) in the '.env' file created after executing the initialization command
python sql_extraction.py --config_path config/llm_config.yaml --user_query "{user_query}" --llm gpt_api

- SQL Extraction (GPT-OSS 20b)

python sql_extraction.py --config_path config/llm_config.yaml --user_query "{user_query}" --llm gpt_oss_20b

Author

About

"SQL Where Clause" Extraction from User Chat Query with LLM

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages