Instructions to use Syigen/rgcm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Syigen/rgcm with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Syigen/rgcm")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Syigen/rgcm", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,250 Bytes
3155e2a | 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 | from __future__ import annotations
from dataclasses import dataclass, field
from typing import Literal, TypeAlias
from torch import Tensor
QuestionType: TypeAlias = Literal["choice", "score", "noul"]
@dataclass(frozen=True)
class Criterion:
id: str
description: str
@dataclass(frozen=True)
class Question:
id: str
type: QuestionType
instructions: str
criteria: list[Criterion | str | dict[str, str]] = field(default_factory=list)
def normalized_criteria(self) -> list[Criterion]:
result: list[Criterion] = []
for index, item in enumerate(self.criteria):
if isinstance(item, Criterion):
result.append(item)
elif isinstance(item, str):
result.append(Criterion(str(index), item))
else:
result.append(Criterion(item.get("id", str(index)), item["description"]))
if self.type in ("choice", "score") and not result:
raise ValueError(f"Question {self.id!r} of type {self.type!r} needs criteria")
return result
@dataclass
class TaskOutput:
question_id: str
type: QuestionType
logits: object
probabilities: Tensor
prediction: object
expected_score: object | None = None
|