Downloads · 30 days
12
16% of all-time downloads
SIRIS-Lab/impuls-salamandra-7b-query-parser
impuls-salamandra-7b-query-parser is a text generation model from SIRIS-Lab. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
A fine-tuned version of BSC-LT/salamandra-7b-instruct-tools for converting natural language queries into structured JSON for R&D project semantic search.
Downloads · 30 days
12
16% of all-time downloads
All-time downloads
73
Public
Parameters
7.8B
15.6 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors15.5 GB · 100%
From the Hugging Face model README
A fine-tuned version of BSC-LT/salamandra-7b-instruct-tools for converting natural language queries into structured JSON for R&D project semantic search.
This model was developed as part of the IMPULS project (AINA Challenge 2024), a collaboration between SIRIS Academic and Generalitat de Catalunya to build a multilingual semantic search system for Catalonia's R&D ecosystem (RIS3-MCAT platform).
The model converts natural language queries in Catalan, Spanish, and English into structured JSON containing:
Input (Catalan):
projectes d'IA en salut finançats per H2020 des de 2020
Output:
{
"doc_type": "projects",
"filters": {
"programme": "Horizon 2020",
"year": ">=2020"
},
"organisations": [],
"semantic_query": "intel·ligència artificial salut",
"query_rewrite": "Projectes sobre IA en salut del programa H2020 des de 2020",
"meta": {
"lang": "CA"
}
}
| Parameter | Value |
|---|---|
| Rank (r) | 16 |
| Alpha | 32 |
| Dropout | 0.05 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Parameter | Value |
|---|---|
| Epochs | 3 |
| Batch size | 16 (effective) |
| Learning rate | 2e-4 |
| Sequence length | 2048 |
| Precision | FP16 (mixed) |
| Optimizer | AdamW |
| LR scheduler | Cosine |
| Warmup ratio | 0.1 |
| Metric | Base Model | Fine-tuned |
|---|---|---|
| JSON Validity | 100% | 100% |
| Strict Accuracy | 15% | 51% |
| Relaxed Accuracy | 29% | 65% |
| Language Match | 53% | 87% |
| Semantic Query Accuracy | 44% | 86% |
| Component | Accuracy |
|---|---|
| Programme (H2020, FEDER, etc.) | 96% |
| Year extraction | 98% |
| Location | 91% |
| Organizations | 77% |
| Semantic Query | 86% |
| Language | Relaxed Accuracy |
|---|---|
| English | 72% |
| Catalan | 64% |
| Spanish | 52% |
| Model | Strict Accuracy | Relaxed Accuracy | JSON Valid |
|---|---|---|---|
| Salamandra-7B (ours) | 51% | 65% | 100% |
| Qwen 2.5-7B | 47% | 65% | 100% |
| Mistral-7B | 24% | 55% | 100% |
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "SIRIS-Lab/impuls-salamandra-7b-query-parser"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto"
)
# System prompt (simplified version)
system_prompt = """Convert natural language queries into structured JSON for R&D project search.
Output only valid JSON with the required schema."""
query = "projectes d'hidrogen finançats per H2020 des de 2020"
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": query}
]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.1,
do_sample=True
)
response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
print(response)
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_quant_type="nf4"
)
model = AutoModelForCausalLM.from_pretrained(
"SIRIS-Lab/impuls-salamandra-7b-query-parser",
quantization_config=quantization_config,
device_map="auto"
)
# Reduces memory from ~14GB to ~3.5GB
{
"doc_type": "projects",
"filters": {
"programme": "string | null",
"funding_level": "string | null",
"year": "string | null",
"location": "string | null",
"location_level": "region | province | country | null"
},
"organisations": [
{
"type": "university | research_center | hospital | company | null",
"name": "string | null",
"location": "string | null",
"location_level": "string | null"
}
],
"semantic_query": "string | null",
"query_rewrite": "string",
"meta": {
"lang": "CA | ES | EN",
"notes": "string | null"
}
}
| Configuration | VRAM Required |
|---|---|
| FP16 (full precision) | ~14 GB |
| 4-bit quantization | ~3.5 GB |
Recommended: GPU with 24GB+ VRAM (A100) or 4-bit quantization on consumer GPUs.
This model is designed for:
If you use this model, please cite:
@misc{impuls-salamandra-2024,
author = {SIRIS Academic},
title = {IMPULS-Salamandra-7B-Query-Parser: Multilingual Query Parsing for R&D Semantic Search},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/SIRIS-Lab/impuls-salamandra-7b-query-parser}}
}
This model is released under the Apache 2.0 License, consistent with the base Salamandra model.