Skip to content

Task

Alignment Task

AlignmentTask

Encapsulates the specification of an alignment problem.

Parameters:

  • domain (Domain) –

    Domain of the alignment task.

  • objective (str) –

    Description of the alignment objective.

  • preference (str) –

    Description of the objective preference.

Domain

Domain

A domain is a combination of DomainComponents along with a weight for each component.

Note: We do not enforce that the weights be normalized.

Parameters:

  • components (List[DomainComponent]) –

    List of DomainComponents that constitute the domain.

  • weights (Optional[List[NonNegativeFloat]]) –

    Weights given to each constituent component (uniform if not specified).

Raises:

  • ValueError

    If the list of components is empty.

  • ValueError

    If the number of weights matches the number of components.

  • ValueError

    If any of the provided weights are negative.

Attributes:

  • num_components (int) –

    int: The number of components associated with this Domain.

num_components property

num_components: int

int: The number of components associated with this Domain.

Domain Component

DomainComponent

A domain component is an alias for a set of 'seed words' describing a specific body of knowledge.

Parameters:

  • name (str) –

    The name that describes the content of the domain component.

  • seed_words (List[str]) –

    The list of seed words that describe the domain component.

  • description (Optional[str]) –

    An optional description of the domain component.

Raises:

Seed Words

seed_words

Functions:

  • get_seed_words

    Get the aliased seed word vocabulary for the correspodning seed word alias.

get_seed_words

get_seed_words(seed_word_alias: str) -> List[str]

Get the aliased seed word vocabulary for the correspodning seed word alias.

Parameters:

  • seed_word_alias (str) –

    The seed word alias to get seed word vocabulary for.

Returns:

  • List ( str ) –

    The list of seed words associated with the seed_word_alias.

Raises:

  • ValueError

    If the seed word alias has no known seed word vocabularies.

Source code in aif_gen/task/seed_words/__init__.py
 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
def get_seed_words(seed_word_alias: str) -> List[str]:
    """Get the aliased seed word vocabulary for the correspodning seed word alias.

    Args:
        seed_word_alias (str): The seed word alias to get seed word vocabulary for.

    Returns:
        List(str): The list of seed words associated with the seed_word_alias.

    Raises:
        ValueError: If the seed word alias has no known seed word vocabularies.
    """
    seed_word_map = {
        'education': EDUCATION_SEED_WORDS,
        'finance': FINANCE_SEED_WORDS,
        'healthcare': HEALTHCARE_SEED_WORDS,
        'politics': POLITICS_SEED_WORDS,
        'technology': TECHNOLOGY_SEED_WORDS,
    }

    if seed_word_alias not in seed_word_map:
        raise ValueError(
            f'No known seed word vocabulary for {seed_word_alias}, '
            f'expected one of {list(seed_word_map.keys())}'
        )

    return seed_word_map[seed_word_alias]