mjwong commited on
Commit
bde5676
·
verified ·
1 Parent(s): a3060a2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +4 -0
README.md CHANGED
@@ -74,13 +74,17 @@ The model can also be applied on NLI tasks like so:
74
  ```python
75
  import torch
76
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
 
77
  # device = "cuda:0" or "cpu"
78
  device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
 
79
  model_name = "mjwong/gte-multilingual-base-xnli"
80
  tokenizer = AutoTokenizer.from_pretrained(model_name)
81
  model = AutoModelForSequenceClassification.from_pretrained(model_name, trust_remote_code=True)
 
82
  premise = "But I thought you'd sworn off coffee."
83
  hypothesis = "I thought that you vowed to drink more coffee."
 
84
  input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
85
  output = model(input["input_ids"].to(device))
86
  prediction = torch.softmax(output["logits"][0], -1).tolist()
 
74
  ```python
75
  import torch
76
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
77
+
78
  # device = "cuda:0" or "cpu"
79
  device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
80
+
81
  model_name = "mjwong/gte-multilingual-base-xnli"
82
  tokenizer = AutoTokenizer.from_pretrained(model_name)
83
  model = AutoModelForSequenceClassification.from_pretrained(model_name, trust_remote_code=True)
84
+
85
  premise = "But I thought you'd sworn off coffee."
86
  hypothesis = "I thought that you vowed to drink more coffee."
87
+
88
  input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
89
  output = model(input["input_ids"].to(device))
90
  prediction = torch.softmax(output["logits"][0], -1).tolist()