BAMBINO-0.1 / modeling_matformer.py
mrinaldi's picture
Update modeling_matformer.py
eb0038f verified
# modeling_matformer.py
import os
import sys
matformer_root = os.getenv("MATFORMER_ROOT")
if matformer_root:
matformer_root = os.path.abspath(os.path.expanduser(matformer_root))
if matformer_root not in sys.path:
sys.path.insert(0, matformer_root)
try:
from matformer.modelling_matformer import (
MatformerForCausalLM,
MatformerForSequenceClassification,
MatformerModel,
MatformerConfig )
except ImportError as e:
print("To use this model, please install the Matformer library: ")
print("pip install matformer (not ready yet;))")
print("Or set MATFORMER_ROOT environment variable to a local clone")
print("Insert the matformer path here:")
path=input()
sys.path.append(path)
try:
from matformer.modelling_matformer import (
MatformerForCausalLM,
MatformerForSequenceClassification,
MatformerModel,
MatformerConfig )
except:
raise ImportError(
"To use this model, please install the Matformer library: "
"`pip install matformer`\\n"
"Alternatively, set the `MATFORMER_ROOT` environment variable to a local clone:\\n"
" export MATFORMER_ROOT=/path/to/matformer"
) from e