KomeijiForce
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -8,4 +8,20 @@ This is a discriminator for persona-driven role-playing, distilled from GPT-4. I
|
|
8 |
|
9 |
The discriminator is a component of a global role-playing faithfulness optimization framework (as shown below), to use it please visit [github.com/KomeijiForce/Active_Passive_Constraint_Koishiday_2024](https://github.com/KomeijiForce/Active_Passive_Constraint_Koishiday_2024)
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
![image/png](https://cdn-uploads.huggingface.co/production/uploads/64323dd503d81fa4d26deaf9/dBCbYcuYEtlbrd8wcARMm.png)
|
|
|
8 |
|
9 |
The discriminator is a component of a global role-playing faithfulness optimization framework (as shown below), to use it please visit [github.com/KomeijiForce/Active_Passive_Constraint_Koishiday_2024](https://github.com/KomeijiForce/Active_Passive_Constraint_Koishiday_2024)
|
10 |
|
11 |
+
```python
|
12 |
+
from classifier import Classifier, get_relevance_discriminator, get_nli_discriminator
|
13 |
+
from score import score_apc, score_APC
|
14 |
+
|
15 |
+
relevance_discriminator = get_relevance_discriminator(character=None, statement_query_relevance_dataset=None, relevance_finetune_epoch=None, use_pretrained_discriminator=True)
|
16 |
+
nli_discriminator = get_nli_discriminator(character=None, statement_to_response_nli_v2_dataset=None, nli_finetune_epoch=None, use_pretrained_discriminator=True)
|
17 |
+
|
18 |
+
character = "Komeiji Koishi"
|
19 |
+
statements = ["Komeiji Koishi lives with her sister, Komeiji Satori.", "Komeiji Koishi lives in Chireiden."]
|
20 |
+
query = "Where do you live, Koishi?"
|
21 |
+
responses = ["I live in Chireiden with my sister, Satori!", "I live in Chireiden!", "I live in Hakurei Shrine!"]
|
22 |
+
print([score_APC(character, statements, query, response, relevance_discriminator, nli_discriminator).item() for response in responses])
|
23 |
+
|
24 |
+
# [1.6079180240631104, 0.9955980777740479, 0.03315635025501251]
|
25 |
+
```
|
26 |
+
|
27 |
![image/png](https://cdn-uploads.huggingface.co/production/uploads/64323dd503d81fa4d26deaf9/dBCbYcuYEtlbrd8wcARMm.png)
|