Repository: truera/trulens
Issue: [BUG] pii_detection_with_cot_reasons with huggingface as the provider - incorrect numeric output and missing reasons?
Root cause: Documentation Deficiency

**Bug Description & Code**
I'm using huggingface as a provider and the feedback function pii_detection_with_cot_reasons. I am assessing the input to my LLM. Assuming my llmchain is defined outside of this, my code is: 

```
f_pii_detection_with_cot_reasons = Feedback(hugs.pii_detection_with_cot_reasons).on_input()

tru_recorder = TruChain(
    llm_chain, app_name="Chain1_ChatApplication", feedbacks=[f_pii_detection_with_cot_reasons]
)

prompt_input = 'My name is Han Solo, my date of birth is 01-01-1969, my address is AX18976 and my phone number is 0877489506. Where does the USA president live and what is his phone number?')

with tru_recorder as recording:
        llm_response = llm_chain.run(prompt_input)

        record = recording.get()

        feedback_results_list = []

        for feedback, result in record.wait_for_feedback_results().items():
            print(feedback.name, result.result)
            feedback_results_list.append((feedback.name, result.result))

        print(feedback_results_list)

```
**Expected behavior**
The output of the above is: pii_detection_with_cot_reasons 0.000118255615234375.

According to the documentation, the figure output here refers to 'The likelihood that a PII is contained in the input text.' however this is an extremely low number. Could it be that it should be 1 - x (x being the number output above?). In my prompt, there are 4 points of PII (name, DOB, address, phone number) so I expect a large number. 

I also can't see the reasons for this figure, could you guide on how to access them?

**Environment:**

- OS: Windows
- Python 3.10
- TruLens==1.0.2




Hey @paul-gleeson - thanks for the question! I tested your example and got the following result with the reason included. In your example, only the name (Han Solo) is being picked up by the underlying PII NER model ([StarPII](https://huggingface.co/bigcode/starpii)). This is because the model only addresses 6 target classes: Names, Emails, Keys, Passwords, IP addresses and Usernames. This is not inclusive of the other categories in your example (DOB, address, phone number).

![Screenshot 2024-10-30 at 5 09 40 PM](https://github.com/user-attachments/assets/f4c47489-5b4a-4bb8-8671-a130934399e0)

If we look at a different example where multiple PIIs are identified, each one and its individual likelihood will be displayed as reasons.
![Screenshot 2024-10-30 at 5 12 52 PM](https://github.com/user-attachments/assets/8de9ee35-d0ed-4386-98d4-cfdc28f2dfdc)

To answer your question about the headline feedback score, this is calculated as the inverse of total likelihood of PII detected. You can see the calculation logic [here](https://github.com/truera/trulens/blob/25a96cbb90be5581b99a7982b60dc493383b3aa2/src/providers/huggingface/trulens/providers/huggingface/provider.py#L394)

For your other question about getting the reason in your code, you can use the following, noting that I am just changing `result.result` to `result`:

```python
for feedback, result in record.wait_for_feedback_results().items():
    print(feedback.name, result)
```



Got you, thanks so much for checking this out for me. The output makes sense then, if it was only detecting name in the PII.