INNER CODE UNIT · Python
AbstractLanguageChecker
HendrikStrobelt/detecting-fake-text · backend/api.py:10
class AbstractLanguageChecker:
"""
Abstract Class that defines the Backend API of GLTR.
To extend the GLTR interface, you need to inherit this and
fill in the defined functions.
"""
def __init__(self):
"""
In the subclass, you need to load all necessary components
for the other functions.
Typically, this will comprise a tokenizer and a model.
"""
self.device = torch.device(
"cuda" if torch.cuda.is_available() else "cpu")
def check_probabilities(self, in_text, topk=40):