Implementation:Datajuicer Data juicer QueryIntentDetectionMapper
| Knowledge Sources | |
|---|---|
| Domains | Data_Processing, Mapping |
| Last Updated | 2026-02-14 16:00 GMT |
Overview
Concrete tool for detecting user intent in queries provided by Data-Juicer.
Description
QueryIntentDetectionMapper is a mapper operator that classifies the user intent of queries by predicting an intent label and confidence score using a Hugging Face text-classification model. It optionally translates Chinese queries to English before classification using a translation model. The predicted intent label and score are stored in the sample metadata fields. Samples that already contain intent annotations are skipped. Requires CUDA acceleration and operates in batched mode.
Usage
Use when you need to automatically tag query intent in training data to enable downstream filtering or analysis by intent category.
Code Reference
Source Location
- Repository: Datajuicer_Data_juicer
- File: data_juicer/ops/mapper/query_intent_detection_mapper.py
Signature
@OPERATORS.register_module("query_intent_detection_mapper")
class QueryIntentDetectionMapper(Mapper):
def __init__(
self,
hf_model: str = "bespin-global/klue-roberta-small-3i4k-intent-classification",
zh_to_en_hf_model: Optional[str] = "Helsinki-NLP/opus-mt-zh-en",
model_params: Dict = {},
zh_to_en_model_params: Dict = {},
*,
label_key: str = MetaKeys.query_intent_label,
score_key: str = MetaKeys.query_intent_score,
**kwargs,
):
Import
from data_juicer.ops.mapper.query_intent_detection_mapper import QueryIntentDetectionMapper
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| hf_model | str | No | HuggingFace model ID for intent classification (default: bespin-global/klue-roberta-small-3i4k-intent-classification) |
| zh_to_en_hf_model | Optional[str] | No | Translation model from Chinese to English (default: Helsinki-NLP/opus-mt-zh-en) |
| model_params | Dict | No | Model parameters for the classification model |
| zh_to_en_model_params | Dict | No | Model parameters for the translation model |
| label_key | str | No | Key name in meta field for the output label (default: query_intent_label) |
| score_key | str | No | Key name in meta field for the output score (default: query_intent_score) |
Outputs
| Name | Type | Description |
|---|---|---|
| meta[label_key] | str | Predicted intent label |
| meta[score_key] | float | Confidence score for the predicted intent |
Usage Examples
process:
- query_intent_detection_mapper:
hf_model: 'bespin-global/klue-roberta-small-3i4k-intent-classification'
zh_to_en_hf_model: 'Helsinki-NLP/opus-mt-zh-en'