File size: 2,043 Bytes
e814211
 
 
 
f8c21da
e814211
 
 
 
f8c21da
e814211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f8c21da
 
 
e814211
f8c21da
 
 
 
 
e814211
 
 
f8c21da
 
 
 
e814211
f8c21da
e814211
f8c21da
 
e814211
f8c21da
 
e814211
f8c21da
 
e814211
f8c21da
 
e814211
f8c21da
 
e814211
f8c21da
 
 
e814211
f8c21da
 
e814211
f8c21da
e814211
f8c21da
 
e814211
f8c21da
 
 
e814211
 
f8c21da
 
 
 
 
 
 
e814211
f8c21da
e814211
 
 
f8c21da
e814211
f8c21da
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import pytest

import markdown
from bs4 import BeautifulSoup
from compliance_checks.intended_purpose import (
    IntendedPurposeCheck, IntendedPurposeResult,
)


model_card_template = """\
## Uses

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->

### Direct Use

Here is some info about direct uses...

### Downstream Use [optional]

<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->

[More Information Needed]

### Out-of-Scope Use

<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->

Here is some info about out-of-scope uses...
"""
albert_base_v2 = """\
# ALBERT Base v2

## Intended uses & limitations
Here is some info about direct uses...
"""
distilbert_base_cased_distilled_squad = """\
# DistilBERT base cased distilled SQuAD

## Uses

This model can be used for question answering.
"""
distilroberta_base = """\
# Model Card for DistilRoBERTa base

# Uses

You can use the raw model for masked language modeling, but it's mostly intended to be fine-tuned on a downstream task.
"""

openai_clip_vit_base_patch = """\
# Model Card: CLIP

## Model Use
Stuff.

### Intended Use
Stuff.

#### Primary intended uses
Stuff.

### Out-of-Scope Use Cases
Stuff.
"""

sentence_transformers = """\
# all-MiniLM-L6-v2

## Intended uses

Our model is intented to be used as a sentence and short paragraph encoder.
"""

success_result = IntendedPurposeResult(
    status=True
)


@pytest.mark.parametrize("card", [
    model_card_template,
    albert_base_v2,
    distilbert_base_cased_distilled_squad,
    distilroberta_base,
    openai_clip_vit_base_patch,
    sentence_transformers,
])
def test_run_checks(card):
    model_card_html = markdown.markdown(card)
    card_soup = BeautifulSoup(model_card_html, features="html.parser")

    results = IntendedPurposeCheck().run_check(card_soup)

    assert results == success_result