File size: 1,289 Bytes
25c0dc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ea8d4ac
25c0dc5
eb0038f
ea8d4ac
 
 
 
 
eb0038f
ea8d4ac
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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