Table of Contents
Fetching ...

Local Language Models for Context-Aware Adaptive Anonymization of Sensitive Text

Aisvarya Adeseye, Jouni Isoaho, Seppo Virtanen, Mohammad Tahir

TL;DR

This work introduces the Structured Framework for Adaptive Anonymizer (SFAA), a three-step, context-aware anonymization pipeline that leverages locally hosted LLMs to detect, classify, and adaptively anonymize sensitive information in qualitative transcripts. It combines manual review with LLM-assisted processing and evaluates two offline models, LLaMA v3.2 and Phi v3.2, on two case studies totaling 175 transcripts to assess privacy protection and analytical integrity. Results show LLMs, especially Phi, achieve higher recall and strong precision, with context-aware rewriting preserving meaning and sentiment alignment, while rule-based methods maximize precision for direct identifiers. The framework demonstrates that privacy-preserving, scalable anonymization is feasible in qualitative research using local models, maintaining analytical validity and data sovereignty, and points to future multilingual and prompting-strategy refinements to further reduce hallucinations.

Abstract

Qualitative research often contains personal, contextual, and organizational details that pose privacy risks if not handled appropriately. Manual anonymization is time-consuming, inconsistent, and frequently omits critical identifiers. Existing automated tools tend to rely on pattern matching or fixed rules, which fail to capture context and may alter the meaning of the data. This study uses local LLMs to build a reliable, repeatable, and context-aware anonymization process for detecting and anonymizing sensitive data in qualitative transcripts. We introduce a Structured Framework for Adaptive Anonymizer (SFAA) that includes three steps: detection, classification, and adaptive anonymization. The SFAA incorporates four anonymization strategies: rule-based substitution, context-aware rewriting, generalization, and suppression. These strategies are applied based on the identifier type and the risk level. The identifiers handled by the SFAA are guided by major international privacy and research ethics standards, including the GDPR, HIPAA, and OECD guidelines. This study followed a dual-method evaluation that combined manual and LLM-assisted processing. Two case studies were used to support the evaluation. The first includes 82 face-to-face interviews on gamification in organizations. The second involves 93 machine-led interviews using an AI-powered interviewer to test LLM awareness and workplace privacy. Two local models, LLaMA and Phi were used to evaluate the performance of the proposed framework. The results indicate that the LLMs found more sensitive data than a human reviewer. Phi outperformed LLaMA in finding sensitive data, but made slightly more errors. Phi was able to find over 91% of the sensitive data and 94.8% kept the same sentiment as the original text, which means it was very accurate, hence, it does not affect the analysis of the qualitative data.

Local Language Models for Context-Aware Adaptive Anonymization of Sensitive Text

TL;DR

This work introduces the Structured Framework for Adaptive Anonymizer (SFAA), a three-step, context-aware anonymization pipeline that leverages locally hosted LLMs to detect, classify, and adaptively anonymize sensitive information in qualitative transcripts. It combines manual review with LLM-assisted processing and evaluates two offline models, LLaMA v3.2 and Phi v3.2, on two case studies totaling 175 transcripts to assess privacy protection and analytical integrity. Results show LLMs, especially Phi, achieve higher recall and strong precision, with context-aware rewriting preserving meaning and sentiment alignment, while rule-based methods maximize precision for direct identifiers. The framework demonstrates that privacy-preserving, scalable anonymization is feasible in qualitative research using local models, maintaining analytical validity and data sovereignty, and points to future multilingual and prompting-strategy refinements to further reduce hallucinations.

Abstract

Qualitative research often contains personal, contextual, and organizational details that pose privacy risks if not handled appropriately. Manual anonymization is time-consuming, inconsistent, and frequently omits critical identifiers. Existing automated tools tend to rely on pattern matching or fixed rules, which fail to capture context and may alter the meaning of the data. This study uses local LLMs to build a reliable, repeatable, and context-aware anonymization process for detecting and anonymizing sensitive data in qualitative transcripts. We introduce a Structured Framework for Adaptive Anonymizer (SFAA) that includes three steps: detection, classification, and adaptive anonymization. The SFAA incorporates four anonymization strategies: rule-based substitution, context-aware rewriting, generalization, and suppression. These strategies are applied based on the identifier type and the risk level. The identifiers handled by the SFAA are guided by major international privacy and research ethics standards, including the GDPR, HIPAA, and OECD guidelines. This study followed a dual-method evaluation that combined manual and LLM-assisted processing. Two case studies were used to support the evaluation. The first includes 82 face-to-face interviews on gamification in organizations. The second involves 93 machine-led interviews using an AI-powered interviewer to test LLM awareness and workplace privacy. Two local models, LLaMA and Phi were used to evaluate the performance of the proposed framework. The results indicate that the LLMs found more sensitive data than a human reviewer. Phi outperformed LLaMA in finding sensitive data, but made slightly more errors. Phi was able to find over 91% of the sensitive data and 94.8% kept the same sentiment as the original text, which means it was very accurate, hence, it does not affect the analysis of the qualitative data.
Paper Structure (15 sections, 9 figures, 1 table)

This paper contains 15 sections, 9 figures, 1 table.

Figures (9)

  • Figure 1: Hybrid Anonymization Workflow Integrating Manual Review and LLM-Assisted Processing for Sensitive Qualitative Data.
  • Figure 2: Structured Framework for Adaptive Anonymizer (SFAA): A Three-Step Process for Identifying, Classifying, and Anonymizing Sensitive Information in Qualitative Transcripts.
  • Figure 3: Comprehensive Identifier Categories for Detecting Sensitive Information in Qualitative Transcripts
  • Figure 4: Three-Level Classification of Sensitive Information Identifiers Based on Re-identification Risk: Direct, Strong Indirect, and Weak Indirect Categories to Guide Privacy-Preserving Strategies.
  • Figure 5: Overview of Adaptive Anonymization Strategies: A Four-Part Framework Including Rule-Based Substitution, Context-Aware Rewriting, Generalization, and Suppression for Protecting Sensitive Information in Qualitative Data.
  • ...and 4 more figures