Instructions to use FacebookAI/xlm-roberta-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FacebookAI/xlm-roberta-large with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="FacebookAI/xlm-roberta-large")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("FacebookAI/xlm-roberta-large") model = AutoModelForMaskedLM.from_pretrained("FacebookAI/xlm-roberta-large", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
File size: 1,542 Bytes
cc9c7ee | 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 64 65 | class ConfigMapper:
"""Class for creating ConfigMapper objects.
This class can be used to create custom configuration names using YAML files.
For each class or object instantiated in any modules,
the ConfigMapper object can be used either with the functions,
or as a decorator to store the mapping in the function.
Attributes
----------
Methods
-------
"""
dicts = {
"models": {},
"trainers": {},
"metrics": {},
"losses": {},
"optimizers": {},
"schedulers": {},
"devices": {},
"embeddings": {},
"params": {},
"datasets": {},
"preprocessors": {},
"tokenizers": {},
}
@classmethod
def map(cls, key, name):
"""
Map a particular name to an object, in the specified key
Parameters
----------
name : str
The name of the object which will be used.
key : str
The key of the mapper to be used.
"""
def wrap(obj):
if key in cls.dicts.keys():
cls.dicts[key][name] = obj
else:
cls.dicts[key] = {}
cls.dicts[key][name] = obj
return obj
return wrap
@classmethod
def get_object(cls, key, name):
""""""
try:
return cls.dicts[key][name]
except:
raise NotImplementedError("Key:{name} Undefined".format(name=name))
configmapper = ConfigMapper()
|