Sponsored by
Vmake Labs Video Enhancer
-Vmake Labs Video Enhancer uses AI to improve video quality, restore details, reduce blur, and upscale videos to 8K.
Introduction of query-context-pruner-multilingual-Qwen3-4B
Model Details of query-context-pruner-multilingual-Qwen3-4B
query-context-pruner-multilingual
A multilingual model designed to remove contexts irrelevant to queries. Since this model is a relatively large LLM, practical pruning methods like
Provence
are needed for speed-critical information retrieval tasks. This model is particularly well-suited for generating teacher labels for training such efficient pruning models.
We offer two model sizes:
4B model
for accuracy-focused label generation where precision matters more than speed, and
1.7B model
for high-speed label generation.
Why This Model is Valuable
Based on the Provence paper, context pruning addresses critical challenges in RAG systems:
Context Noise Problem
: Retrieved documents often contain irrelevant sentences that mislead LLMs and degrade response quality
Computational Overhead
: Long contexts slow down generation and increase costs significantly
Performance Degradation
: Irrelevant information leads to hallucinations and poor answer quality
Our model enables efficient training data generation for lightweight context pruners that can:
Reduce context length by 70-90% while maintaining accuracy
Achieve almost zero-cost pruning when unified with reranking (as shown in Provence)
Work out-of-the-box across diverse domains and languages
Dynamically detect optimal pruning ratios (0-100%) per context
This addresses the practical need for robust, adaptable context pruners that can be deployed in production RAG systems without compromising performance.
đ Quick Start
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Choose model size
MODEL_NAME = "hotchpotch/query-context-pruner-multilingual-Qwen3-4B"# Recommended (best balance)# MODEL_NAME = "hotchpotch/query-context-pruner-multilingual-Qwen3-1.7B" # Faster alternative
model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME,
torch_dtype=torch.bfloat16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
defcreate_user_prompt(query: str, contexts: list[str]) -> str:
"""Create a formatted prompt from query and context chunks."""
context_str = "\n".join([f"[{i+1}] {ctx}"for i, ctx inenumerate(contexts)])
returnf"{query}\n---\n{context_str}"# Example: Python documentation split into chunks
query = "How do you read and write files in Python?"
contexts = [
"Python is a high-level programming language known for its simplicity and readability.",
"To read a file in Python, you use the open() function with the 'r' mode. For example: with open('file.txt', 'r') as f: content = f.read()",
"Writing to files in Python also uses open() with 'w' mode for writing or 'a' mode for appending. Example: with open('file.txt', 'w') as f: f.write('Hello')",
"Python supports multiple programming paradigms including object-oriented and functional programming.",
"The 'with' statement ensures proper file handling by automatically closing files after use, preventing resource leaks.",
"Python has various built-in functions like len(), range(), and type() that are commonly used in everyday programming."
]
# Generate response
prompt = create_user_prompt(query, contexts)
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128, temperature=0.1, do_sample=True)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(f"Relevant chunks: {response}") # Expected: "2,3,5" (reading, writing, and proper file handling)# Note: The model's output indices start from 1, not 0
đ Model Description
Query-Context Pruner is designed to solve the context overload problem in RAG systems by identifying which text chunks contain information relevant to answering a query. This enables:
Efficient RAG pipelines
: Reduce context length by 70-90% while maintaining accuracy
Training data generation
: Create high-quality labels for smaller bi-encoder models
Multilingual information retrieval
: Works across 20 languages with varying performance
Context compression
: Eliminate irrelevant information before passing to LLMs
đ Supported Languages
The model supports 20 languages with varying performance levels.
Important: While some languages show excellent performance, others have limited effectiveness. Please carefully review your target language's performance before use.
Note on Evaluation
: Many test datasets (especially MIRACL) have very small sample sizes, making test scores less reliable. We report averaged F1 scores (test + validation) for more robust evaluation.
Language Performance Summary (4B Model)
Language
Avg F1
Test F1
Val F1
Test Samples
Val Samples
Performance Tier
High Performance Languages (F1 > 0.85)
Russian (ru)
0.901
0.910
0.891
82
82
đ Excellent
Arabic (ar)
0.899
0.916
0.882
61
61
đ Excellent
Finnish (fi)
0.877
0.874
0.880
48
48
đ Excellent
Indonesian (id)
0.871
0.858
0.883
64
64
đ Excellent
Japanese (ja)*
0.865
0.860
0.870
478
478
đ Excellent
Good Performance Languages (F1 0.75-0.85)
English (en)*
0.847
0.874
0.819
682
682
â Very Good
Korean (ko)
0.849
0.910
0.787
30
30
â Very Goodâ
German (de)
0.843
0.776
0.909
14
14
â Very Goodâ
Persian (fa)
0.818
0.739
0.896
27
27
â Very Goodâ
Swahili (sw)
0.806
0.767
0.845
37
37
â Very Good
Chinese (zh)
0.805
0.777
0.833
38
38
â Good
Moderate Performance Languages (F1 0.60-0.75)
Spanish (es)
0.715
0.800
0.629
31
31
⥠ModerateâĄ
Yoruba (yo)
0.662
0.630
0.694
18
18
⥠Moderateâ
French (fr)
0.622
0.774
0.470
29
29
⥠ModerateâĄ
Limited Performance Languages (F1 < 0.60)
Thai (th)
0.378
0.239
0.516
56
56
â ď¸ Poor
Hindi (hi)
0.348
0.538
0.158
36
36
â ď¸ PoorâĄ
Bengali (bn)
0.217
0.222
0.212
23
23
â ď¸ Very Poor
Telugu (te)
0.109
0.067
0.150
61
61
â ď¸ Very Poor
* Average across multiple datasets (Japanese: 8 datasets, English: MS-MARCO + MIRACL)
â Very small test set - interpret with caution
⥠High variance between test/validation - less stable performance
Note: Performance varies by domain. Languages with more training data generally perform better.
đ Model Evaluation
We evaluated four model sizes on 28 datasets covering multiple languages and domains. Results shown are combined test+validation scores for robustness.
Note: We show both test and validation scores because some datasets have small test sets, making validation scores more reliable. Large differences between splits (>0.1) may indicate data quality issues.
â Important:
All MIRACL datasets have fewer than 100 test samples, with many having fewer than 50. During dataset creation, we should have allocated more samples to the test sets for MIRACL languages. The small sample sizes raise concerns about the statistical reliability of the reported metrics. Performance on these datasets should be interpreted with caution, as the confidence intervals are likely to be wide.
English
: MS-MARCO dataset for robust English QA performance
Japanese
: Various Japanese QA datasets (JaQuAD, JSQuAD, JQARA, Quiz datasets) for comprehensive coverage
Multilingual
: MIRACL dataset covering 18 languages for broad multilingual support
Important Note
: Relevance labels were generated using DeepSeek-V3-0324, an LLM, without human verification. Therefore, the ground truth data itself may contain errors and should not be considered perfect annotations.
Base Model
: Qwen-3 series
Method
: Supervised Fine-Tuning (SFT)
Training Strategy
: Multi-language curriculum learning
đ§ Technical Implementation
The model implements context pruning as described in:
Provence: Efficient and Robust Context Pruning for Retrieval-Augmented Generation
Zhang et al., 2025 (
arXiv:2501.16214
)
Key features:
Citation-style output format (e.g., "1,3" for chunks 1 and 3)
query-context-pruner-multilingual-Qwen3-4B huggingface.co is an AI model on huggingface.co that provides query-context-pruner-multilingual-Qwen3-4B's model effect (), which can be used instantly with this hotchpotch query-context-pruner-multilingual-Qwen3-4B model. huggingface.co supports a free trial of the query-context-pruner-multilingual-Qwen3-4B model, and also provides paid use of the query-context-pruner-multilingual-Qwen3-4B. Support call query-context-pruner-multilingual-Qwen3-4B model through api, including Node.js, Python, http.
query-context-pruner-multilingual-Qwen3-4B huggingface.co is an online trial and call api platform, which integrates query-context-pruner-multilingual-Qwen3-4B's modeling effects, including api services, and provides a free online trial of query-context-pruner-multilingual-Qwen3-4B, you can try query-context-pruner-multilingual-Qwen3-4B online for free by clicking the link below.
hotchpotch query-context-pruner-multilingual-Qwen3-4B online free url in huggingface.co:
query-context-pruner-multilingual-Qwen3-4B is an open source model from GitHub that offers a free installation service, and any user can find query-context-pruner-multilingual-Qwen3-4B on GitHub to install. At the same time, huggingface.co provides the effect of query-context-pruner-multilingual-Qwen3-4B install, users can directly use query-context-pruner-multilingual-Qwen3-4B installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
query-context-pruner-multilingual-Qwen3-4B install url in huggingface.co: