Text Generation
Transformers
Safetensors
GGUF
English
llama
sql
forensics
text-to-sql
fine-tuned
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use pawlaszc/DigitalForensicsText2SQLite with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pawlaszc/DigitalForensicsText2SQLite with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pawlaszc/DigitalForensicsText2SQLite") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("pawlaszc/DigitalForensicsText2SQLite") model = AutoModelForCausalLM.from_pretrained("pawlaszc/DigitalForensicsText2SQLite") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - llama-cpp-python
How to use pawlaszc/DigitalForensicsText2SQLite with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="pawlaszc/DigitalForensicsText2SQLite", filename="forensic-sqlite-llama-3.2-3b-Q4_K_M.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use pawlaszc/DigitalForensicsText2SQLite with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M # Run inference directly in the terminal: llama-cli -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M # Run inference directly in the terminal: llama-cli -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
Use Docker
docker model run hf.co/pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use pawlaszc/DigitalForensicsText2SQLite with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pawlaszc/DigitalForensicsText2SQLite" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pawlaszc/DigitalForensicsText2SQLite", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
- SGLang
How to use pawlaszc/DigitalForensicsText2SQLite with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "pawlaszc/DigitalForensicsText2SQLite" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pawlaszc/DigitalForensicsText2SQLite", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "pawlaszc/DigitalForensicsText2SQLite" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pawlaszc/DigitalForensicsText2SQLite", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use pawlaszc/DigitalForensicsText2SQLite with Ollama:
ollama run hf.co/pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
- Unsloth Studio new
How to use pawlaszc/DigitalForensicsText2SQLite with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for pawlaszc/DigitalForensicsText2SQLite to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for pawlaszc/DigitalForensicsText2SQLite to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for pawlaszc/DigitalForensicsText2SQLite to start chatting
- Pi new
How to use pawlaszc/DigitalForensicsText2SQLite with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "pawlaszc/DigitalForensicsText2SQLite:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use pawlaszc/DigitalForensicsText2SQLite with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use pawlaszc/DigitalForensicsText2SQLite with Docker Model Runner:
docker model run hf.co/pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
- Lemonade
How to use pawlaszc/DigitalForensicsText2SQLite with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull pawlaszc/DigitalForensicsText2SQLite:Q4_K_M
Run and chat with the model
lemonade run user.DigitalForensicsText2SQLite-Q4_K_M
List all available models
lemonade list
| license: apache-2.0 | |
| language: | |
| - en | |
| base_model: | |
| - unsloth/Llama-3.2-3B-Instruct | |
| tags: | |
| - digital | |
| - forensics | |
| - sqlite | |
| datasets: | |
| - pawlaszc/mobile-forensics-sql | |
| metrics: | |
| - accuracy | |
| model-index: | |
| - name: ForensicSQL-Llama-3.2-3B | |
| results: | |
| - task: | |
| type: text-to-sql | |
| name: Text-to-SQL Generation | |
| dataset: | |
| type: mobile-forensics | |
| name: Mobile Forensics SQL Dataset | |
| metrics: | |
| - type: accuracy | |
| value: 79.0 | |
| name: Overall Accuracy | |
| - type: accuracy | |
| value: 94.3 | |
| name: Easy Queries Accuracy | |
| - type: accuracy | |
| value: 80.6 | |
| name: Medium Queries Accuracy | |
| - type: accuracy | |
| value: 61.8 | |
| name: Hard Queries Accuracy | |
| # ForensicSQL-Llama-3.2-3B | |
| ## Model Description | |
| **ForensicSQL** is a fine-tuned Llama 3.2 3B model specialised for generating SQLite queries for mobile forensics databases. The model converts natural language forensic investigation requests into executable SQL queries across various mobile app databases (WhatsApp, Signal, iOS Health, Android SMS, etc.). | |
| This model was developed as part of a research project investigating LLM fine-tuning for forensic database analysis. | |
| ## Model Details | |
| - **Base Model:** Llama 3.2 3B Instruct | |
| - **Fine-tuning Method:** LoRA (Low-Rank Adaptation) | |
| - **Training Dataset:** 768 forensic SQL examples across 148 categories | |
| - **Training Framework:** Hugging Face Transformers + PEFT | |
| - **Model Size:** | |
| - Full (FP16): ~6 GB | |
| - GGUF Q4_K_M: ~2.3 GB | |
| - GGUF Q5_K_M: ~2.8 GB | |
| - GGUF Q8_0: ~3.8 GB | |
| ## Performance | |
| ### Overall Results | |
| - **Overall Accuracy:** 79.0% | |
| - **Schema Generation Errors:** 0% (completely eliminated) | |
| - **Executable Queries:** 79% | |
| ### Breakdown by Difficulty | |
| | Difficulty | Accuracy | Examples | | |
| |------------------------|----------|----------| | |
| | Easy (single-table) | 94.3% | 33/35 | | |
| | Medium (simple joins) | 80.6% | 25/31 | | |
| | Hard (complex queries) | 61.8% | 21/34 | | |
| ### Error Analysis | |
| | Error Type | Percentage | Description | | |
| |----------------------|------------|------------------------------------| | |
| | Column Hallucination | 18% | References non-existent columns | | |
| | Syntax Errors | 3% | Invalid SQL syntax | | |
| | Schema Generation | 0% | Eliminated through proper training | | |
| ## Intended Use | |
| ### Primary Use Cases | |
| - Mobile forensics investigations | |
| - Automated SQL query generation for forensic databases | |
| - Educational tool for learning forensic database analysis | |
| - Research in text-to-SQL for specialized domains | |
| ### Out-of-Scope Use | |
| - General-purpose SQL generation (use specialized models) | |
| - Production systems requiring >95% accuracy | |
| - Real-time critical forensic decisions without human review | |
| ## How to Use | |
| ### Quick Start (Transformers) | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import torch | |
| # Load model and tokenizer | |
| model_name = "pawlaszc/ForensicSQL-Llama-3.2-3B" | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_name, | |
| torch_dtype=torch.float16, | |
| device_map="auto" | |
| ) | |
| # Prepare input | |
| schema = """ | |
| CREATE TABLE messages ( | |
| _id INTEGER PRIMARY KEY, | |
| address TEXT, | |
| body TEXT, | |
| date INTEGER, | |
| read INTEGER | |
| ); | |
| """ | |
| request = "Find all unread messages from yesterday" | |
| prompt = f"""Generate a valid SQLite query for this forensic database request. | |
| Database Schema: | |
| {schema} | |
| Request: {request} | |
| SQLite Query: | |
| """ | |
| # Generate SQL | |
| inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=2048) | |
| inputs = {k: v.to(model.device) for k, v in inputs.items()} | |
| with torch.no_grad(): | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=200, | |
| do_sample=False, | |
| ) | |
| # Decode only the generated part | |
| input_length = inputs['input_ids'].shape[1] | |
| generated_tokens = outputs[0][input_length:] | |
| sql = tokenizer.decode(generated_tokens, skip_special_tokens=True) | |
| print(sql.strip()) | |
| # Output: SELECT * FROM messages WHERE read = 0 AND date > ... | |
| ``` | |
| ### Using GGUF Files (llama.cpp / Ollama) | |
| **With llama.cpp:** | |
| ```bash | |
| # Download GGUF file | |
| wget https://huggingface.co/pawlaszc/ForensicSQL-Llama-3.2-3B/resolve/main/forensic-sql-q4_k_m.gguf | |
| # Run inference | |
| ./llama-cli -m forensic-sql-q4_k_m.gguf -p "Generate SQL..." | |
| ``` | |
| **With Ollama:** | |
| ```bash | |
| # Create Modelfile | |
| FROM ./forensic-sql-q4_k_m.gguf | |
| PARAMETER temperature 0 | |
| PARAMETER top_p 0.9 | |
| # Import | |
| ollama create forensic-sql -f Modelfile | |
| # Use | |
| ollama run forensic-sql "Schema: ...\nRequest: Find messages\nSQL:" | |
| ``` | |
| ### Python Helper Class | |
| ```python | |
| class ForensicSQLGenerator: | |
| def __init__(self, model_name="pawalaszc/ForensicSQL-Llama-3.2-3B"): | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import torch | |
| self.tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| self.model = AutoModelForCausalLM.from_pretrained( | |
| model_name, | |
| torch_dtype=torch.float16, | |
| device_map="auto" | |
| ) | |
| self.model.eval() | |
| def generate_sql(self, schema: str, request: str) -> str: | |
| prompt = f"""Generate a valid SQLite query for this forensic database request. | |
| Database Schema: | |
| {schema} | |
| Request: {request} | |
| SQLite Query: | |
| """ | |
| inputs = self.tokenizer( | |
| prompt, | |
| return_tensors="pt", | |
| truncation=True, | |
| max_length=2048 | |
| ) | |
| inputs = {k: v.to(self.model.device) for k, v in inputs.items()} | |
| input_length = inputs['input_ids'].shape[1] | |
| with torch.no_grad(): | |
| outputs = self.model.generate( | |
| **inputs, | |
| max_new_tokens=200, | |
| do_sample=False, | |
| ) | |
| generated_tokens = outputs[0][input_length:] | |
| sql = self.tokenizer.decode(generated_tokens, skip_special_tokens=True) | |
| return sql.strip().split("\n")[0].strip().rstrip(";") + ";" | |
| # Usage | |
| generator = ForensicSQLGenerator() | |
| sql = generator.generate_sql(schema, request) | |
| ``` | |
| ## Training Details | |
| ### Training Data | |
| - **Size:** 768 examples (original) → 2,304 examples (with augmentation) | |
| - **Categories:** 148 forensic database categories | |
| - **Sources:** WhatsApp, Signal, iMessage, SMS, iOS apps, Android apps | |
| - **Augmentation:** 3x paraphrase augmentation per example | |
| ### Training Procedure | |
| - **Method:** LoRA fine-tuning | |
| - **LoRA Rank:** 16 | |
| - **LoRA Alpha:** 32 | |
| - **Target Modules:** q_proj, k_proj, v_proj, o_proj | |
| - **Epochs:** 5 | |
| - **Learning Rate:** 2e-5 | |
| - **Batch Size:** 1 (gradient accumulation: 4) | |
| - **Max Sequence Length:** 2048 (critical for preventing truncation) | |
| - **Optimizer:** AdamW | |
| - **Scheduler:** Cosine with warmup (10%) | |
| - **Hardware:** Apple M2 (MPS) | |
| - **Training Time:** ~3.5 hours | |
| ### Key Training Insights | |
| **Critical Discovery: Sequence Length Matters** | |
| Initial training attempts with `max_seq_length=512` resulted in only 50% accuracy because 92% of training examples were truncated. The model learned to generate schema definitions (CREATE TABLE) instead of queries. | |
| Increasing to `max_seq_length=2048` eliminated truncation and improved accuracy from 50% to 79% (+29pp). | |
| **Lesson:** Data preprocessing and proper sequence length configuration are critical for fine-tuning success. | |
| ## Limitations | |
| ### Known Issues | |
| 1. **Column Hallucination (18%):** Model sometimes references non-existent columns | |
| 2. **Complex Joins:** Performance drops on multi-table queries requiring JOINs (62%) | |
| 3. **Schema Understanding:** Limited understanding of foreign key relationships | |
| ### When to Use Human Review | |
| - Complex multi-table queries | |
| - Critical forensic investigations | |
| - Queries involving data deletion or modification | |
| - When accuracy >95% is required | |
| ## Evaluation | |
| ### Test Set | |
| - **Size:** 100 queries (random sample from held-out data) | |
| - **Seed:** 42 (reproducible) | |
| - **Evaluation Metric:** Exact match (query results must match expected results) | |
| ### Ablation Studies | |
| | Configuration | Accuracy | Notes | | |
| |--------------------------------|----------|----------------------| | |
| | Zero-shot baseline | 45% | No fine-tuning | | |
| | Final training (max_len=2048) | 79% | No truncation | | |
| ## Citation | |
| If you use this model in your research, please cite: | |
| ```bibtex | |
| @misc{dirk_pawlaszczyk_2026, | |
| author = { Dirk Pawlaszczyk and Ronny Bodach and Christian Hummert and Philipp Engler}, | |
| title = { DigitalForensicsText2SQLite}, | |
| year = 2026, | |
| url = { https://huggingface.co/pawlaszc/DigitalForensicsText2SQLite }, | |
| doi = { 10.57967/hf/7675 }, | |
| publisher = { Hugging Face } | |
| } | |
| ``` | |
| ## Model Card Authors | |
| Dirk Pawlaszczyk | |
| ## Model Card Contact | |
| For questions or issues, please open an issue on the (https://github.com/pawlaszczyk/fqlite) or contact pawlaszc@hs-mittweida.de. | |
| ## License | |
| This model is released under the Apache 2.0 License, following the base Llama 3.2 license. | |
| ## Acknowledgments | |
| - Base model: Meta's Llama 3.2 3B Instruct | |
| - Training framework: Hugging Face Transformers, PEFT | |
| - Dataset creation: Custom forensic database schemas | |
| - Inspiration: Text-to-SQL research community | |
| ## Additional Resources | |
| - **Dataset:** pawlaszc/mobile-forensics-sql | |
| - **GitHub:** https://github.com/pawlaszczyk/fqlite | |
| - **Paper:** [Link when published] | |
| --- | |
| **Disclaimer:** This model is intended for research and educational purposes. Always validate generated SQL queries before execution in production forensic investigations. The model may produce incorrect queries that could lead to data loss or incorrect conclusions if used without proper review. | |