Skip to content

Commit

Permalink
improve doc
Browse files Browse the repository at this point in the history
  • Loading branch information
davebulaval committed Feb 11, 2024
1 parent 18c44c4 commit f972dc9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,30 @@ model = AutoModelForSequenceClassification.from_pretrained("davebulaval/MeaningB

or you can use MeaningBERT as a metric for evaluation (no retrain) using the following with HuggingFace

## Code Examples

```python
import torch

from transformers import AutoTokenizer, AutoModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("davebulaval/MeaningBERT")
scorer = AutoModelForSequenceClassification.from_pretrained("davebulaval/MeaningBERT")
scorer.eval()

documents = ["He wanted to make them pay.", "This sandwich looks delicious.", "He wants to eat."]
simplifications = ["He wanted to make them pay.", "This sandwich looks delicious.",
"Whatever, whenever, this is a sentence."]

# We tokenize the text as a pair and return Pytorch Tensors
tokenize_text = tokenizer(documents, simplifications, truncation=True, padding=True, return_tensors="pt")

with torch.no_grad():
# We process the text
scores = scorer(**tokenize_text)

print(scores.logits.tolist())
```


------------------
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ target-version = ['py38', 'py39', 'py310', 'py311']

line-length = 120
skip-string-normalization = true
required-version = "23.9.1"
extend-exclude = "/(slides)/"

0 comments on commit f972dc9

Please sign in to comment.