File size: 1,713 Bytes
31c8699 11bec6e 56de430 11bec6e 56de430 11bec6e 31c8699 56de430 31c8699 56de430 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
---
language:
- cs
license: cc-by-sa-4.0
library_name: peft
datasets:
- ctu-aic/csfever_v2
metrics:
- accuracy
- f1
- recall
- precision
pipeline_tag: text-classification
base_model: deepset/xlm-roberta-large-squad2
---
# Model card for lora-xlm-roberta-large-squad2-csfever_v2-f1
## Model details
Model for natural language inference.
## Training procedure
### Framework versions
- PEFT 0.4.0
## Uses
### PEFT (Transformers)
```python
from peft import PeftModel, PeftConfig
from transformers import AutoModelForSequenceClassification, Pipeline, AutoTokenizer
config = PeftConfig.from_pretrained("ctu-aic/lora-xlm-roberta-large-squad2-csfever_v2-f1")
model = AutoModelForSequenceClassification.from_pretrained(config.base_model_name_or_path)
model = PeftModel.from_pretrained(model, config)
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
#pipeline for NLI
class NliPipeline(Pipeline):
def _sanitize_parameters(self, **kwargs):
preprocess_kwargs = {}
if "evidence" in kwargs:
preprocess_kwargs["evidence"] = kwargs["evidence"]
return preprocess_kwargs, {}, {}
def preprocess(self, claim, evidence=""):
model_input = self.tokenizer(claim, evidence, return_tensors=self.framework, truncation=True)
return model_input
def _forward(self, model_inputs):
outputs = self.model(**model_inputs)
return outputs
def postprocess(self, model_outputs):
logits = model_outputs.logits
predictions = torch.argmax(logits, dim=-1)
return {"logits": logits, "label": int(predictions[0])}
nli_pipeline = NliPipeline(model=model, tokenizer=tokenizer)
nli_pipeline("claim", "evidence")
``` |