Skip to content

Fix evaluator class reference and add prompt template - #69

Merged
DzmitryPihulski merged 3 commits into
mainfrom
ViktoriaNov-patch-1
Feb 8, 2026
Merged

Fix evaluator class reference and add prompt template#69
DzmitryPihulski merged 3 commits into
mainfrom
ViktoriaNov-patch-1

Conversation

@ViktoriaNov

Copy link
Copy Markdown
Collaborator

Updated evaluator class reference and added prompt template section with examples.

Updated evaluator class reference and added prompt template section with examples.
@codecov

codecov Bot commented Feb 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread README.md Outdated
output_file="path_to_your_outputs.jsonl",
- Use [`llmsql.inference_transformers`](./llmsql/inference/inference_transformers.py) (the function for transformers inference) for generation of SQL predictions with your model. If you want to do vllm based inference, use [`llmsql.inference_vllm`](./llmsql/inference/inference_vllm.py). Works both with HF model id, e.g. `Qwen/Qwen2.5-1.5B-Instruct` and model instance passed directly, e.g. `inference_transformers(model_or_model_name_or_path=model, ...)`
- Evaluate results against the benchmark with the [`llmsql.LLMSQLEvaluator`](./llmsql/evaluation/evaluator.py) evaluator class.
- Evaluate results against the benchmark with the [`llmsql.evaluate`](./llmsql/evaluation/evaluator.py) evaluator class.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evaluate() is a function, not evaluator class

Comment thread README.md Outdated

## Prompt Template

The prompt defines explicit constraints on the generated output. The model is instructed to output only a valid SQL `SELECT` query, to use a fixed table name (`"Table"`), to quote all table and column names, and to restrict generation to the specified SQL functions, condition operators, and keywords. The full prompt specification is provided in the prompt template.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add that "Table" will be replaced with actual table name in process of evaluation.

The "Table" word is used just to not confuse the model with the table names.

Comment thread README.md Outdated
Comment on lines +167 to +200
```python
def build_prompt_1shot(
question: str,
headers: list[str],
types: list[str],
sample_row: list[str | float | int],
) -> str:
return f"""You are an expert SQLite SQL query generator.
Your task: Given a question and a table schema, output ONLY a valid SQL SELECT query.
⚠️ STRICT RULES:
- Output ONLY SQL (no explanations, no markdown, no ``` fences)
- Use table name "Table"
- Allowed functions: ['MAX', 'MIN', 'COUNT', 'SUM', 'AVG']
- Allowed condition operators: ['=', '>', '<', '!=']
- Allowed SQL keywords: ['SELECT', 'WHERE', 'AND']
- Always use "" with all column names and table name

### EXAMPLE 1:
Question: What is the price of the Samsung Galaxy S23?
Columns: ['Brand', 'Model', 'Price', 'Storage', 'Color']
Types: ['text', 'text', 'real', 'text', 'text']
Sample row: ['Apple', 'iPhone 14', 899.99, '128GB', 'White']
SQL: SELECT "Price" FROM "Table" WHERE "Brand" = "Samsung" AND "Model" = "Galaxy S23";

### NOW ANSWER:
Question: {question}
Columns: {headers}
Types: {types}
Sample row: {sample_row}
SQL:"""
```

Implementations of 0-shot, 1-shot, and 5-shot prompt templates are available here:
👉 [link-to-file](./llmsql/prompts/prompts.py)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we do not need a function, we need a text (prompt it self).

It is also better to add 5 shot version, not 1 shot.

@DzmitryPihulski DzmitryPihulski added documentation Improvements or additions to documentation bug Something isn't working labels Feb 7, 2026
Updated README
@ViktoriaNov

Copy link
Copy Markdown
Collaborator Author

README updated according to reviewer’s suggestions

@DzmitryPihulski DzmitryPihulski linked an issue Feb 8, 2026 that may be closed by this pull request
@DzmitryPihulski
DzmitryPihulski merged commit 890887c into main Feb 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation: llmsql.LLMSQLEvaluator is deprecated

2 participants