Update README.md
Browse files
README.md
CHANGED
@@ -35,4 +35,35 @@ The model is trained to identify tokens in the answer text that are not supporte
|
|
35 |
|
36 |
### Installation
|
37 |
|
38 |
-
Install the 'lettucedetect' repository
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
### Installation
|
37 |
|
38 |
+
Install the 'lettucedetect' repository
|
39 |
+
|
40 |
+
```bash
|
41 |
+
pip install lettucedetect
|
42 |
+
```
|
43 |
+
|
44 |
+
### Using the model
|
45 |
+
|
46 |
+
```python
|
47 |
+
from lettucedetect.models.inference import HallucinationDetector
|
48 |
+
|
49 |
+
# Initialize the detector with the transformer-based approach.
|
50 |
+
detector = HallucinationDetector(method="transformer", model_path="KRLabsOrg/lettucedect-base-modernbert-en-v1")
|
51 |
+
|
52 |
+
|
53 |
+
context = """Briefly answer the following question:
|
54 |
+
What is the capital of France? What is the population of France?
|
55 |
+
|
56 |
+
Bear in mind that your response should be strictly based on the following three passages:
|
57 |
+
passage 1: France is a country in Europe. The capital of France is Paris. The population of France is 67 million.
|
58 |
+
|
59 |
+
output:
|
60 |
+
"""
|
61 |
+
|
62 |
+
answer = "The capital of France is Paris. The population of France is 69 million."
|
63 |
+
|
64 |
+
# Get span-level predictions indicating which parts of the answer are considered hallucinated.
|
65 |
+
predictions = detector.predict(context, answer, output_format="spans")
|
66 |
+
print("Predictions:", predictions)
|
67 |
+
|
68 |
+
# Predictions: [{'start': 31, 'end': 71, 'confidence': 0.9944414496421814, 'text': ' The population of France is 69 million.'}]
|
69 |
+
```
|