Update README.md
Browse files
README.md
CHANGED
|
@@ -4,6 +4,7 @@ Example Usage:
|
|
| 4 |
```
|
| 5 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 6 |
import torch
|
|
|
|
| 7 |
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained("will4381/inference_confidence_model")
|
| 9 |
model = AutoModelForSequenceClassification.from_pretrained("will4381/inference_confidence_model")
|
|
@@ -14,9 +15,11 @@ inference = "The Great Barrier Reef is experiencing a decline in biodiversity du
|
|
| 14 |
inputs = tokenizer(passage, inference, return_tensors="pt", truncation=True, max_length=512, padding="max_length")
|
| 15 |
|
| 16 |
model.eval()
|
|
|
|
| 17 |
with torch.no_grad():
|
| 18 |
outputs = model(**inputs)
|
| 19 |
|
| 20 |
-
predicted_confidence = outputs.logits.item()
|
|
|
|
| 21 |
print(f"Predicted confidence: {predicted_confidence:.4f}")
|
| 22 |
```
|
|
|
|
| 4 |
```
|
| 5 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 6 |
import torch
|
| 7 |
+
import torch.nn.functional as F
|
| 8 |
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained("will4381/inference_confidence_model")
|
| 10 |
model = AutoModelForSequenceClassification.from_pretrained("will4381/inference_confidence_model")
|
|
|
|
| 15 |
inputs = tokenizer(passage, inference, return_tensors="pt", truncation=True, max_length=512, padding="max_length")
|
| 16 |
|
| 17 |
model.eval()
|
| 18 |
+
|
| 19 |
with torch.no_grad():
|
| 20 |
outputs = model(**inputs)
|
| 21 |
|
| 22 |
+
predicted_confidence = torch.sigmoid(outputs.logits).item()
|
| 23 |
+
|
| 24 |
print(f"Predicted confidence: {predicted_confidence:.4f}")
|
| 25 |
```
|