PII
节点后处理器模块。
PIINodePostprocessor #
PII 节点处理器。
注意:这是一个 Beta 功能,API 可能会发生变化。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
llm
|
LLM
|
用于预测的本地 LLM。 |
必需 |
pii_str_tmpl
|
str
|
|
'The current context information is provided. \nA task is also provided to mask the PII within the context. \nReturn the text, with all PII masked out, and a mapping of the original PII to the masked PII. \nReturn the output of the task in JSON. \nContext:\nHello Zhang Wei, I am John. Your AnyCompany Financial Services, LLC credit card account 1111-0000-1111-0008 has a minimum payment of $24.53 that is due by July 31st. Based on your autopay settings, we will withdraw your payment. Task: Mask out the PII, replace each PII with a tag, and return the text. Return the mapping in JSON. \nOutput: \nHello [NAME1], I am [NAME2]. Your AnyCompany Financial Services, LLC credit card account [CREDIT_CARD_NUMBER] has a minimum payment of $24.53 that is due by [DATE_TIME]. Based on your autopay settings, we will withdraw your payment. Output Mapping:\n{{"NAME1": "Zhang Wei", "NAME2": "John", "CREDIT_CARD_NUMBER": "1111-0000-1111-0008", "DATE_TIME": "July 31st"}}\nContext:\n{context_str}\nTask: {query_str}\nOutput: \n'
|
pii_node_info_key
|
str
|
|
'__pii_node_info__'
|
源代码位于 llama-index-core/llama_index/core/postprocessor/pii.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
mask_pii #
mask_pii(text: str) -> Tuple[str, Dict]
对文本中的 PII 进行脱敏。
源代码位于 llama-index-core/llama_index/core/postprocessor/pii.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|