Classification¶
summ.classify.Classes
¶
Bases: StrEnum
The parent class for all custom sets of tags.
To define a set of custom tags, inherit from this class and use Pyhon Enum syntax to define them, using the category name as the prefix for each tag.
Example
class MyClasses(Classes):
ROLE_IC = auto()
ROLE_MANAGER = auto()
SECTOR_TECH = auto()
SECTOR_FINANCE = auto()
Source code in summ/classify/classes.py
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 |
|
get(val: str) -> Optional[Self]
classmethod
¶
:meta private:
Source code in summ/classify/classes.py
24 25 26 27 28 29 30 31 32 33 34 |
|
summ.classify.Classifier
¶
The base class for specifying custom classifiers to apply tags to an interview.
Source code in summ/classify/classifier.py
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
CATEGORY: str
class-attribute
¶
The name of the category to tag. Must be the prefix of a set of tags in your Classes
subclass.
VARS: dict[str, str]
class-attribute
¶
A dictionary mapping variable names to descriptions. These will be used to generate the prompt.
EXAMPLES: list[dict[str, str]]
class-attribute
¶
A list of few-shot examples. Each example should be a dictionary with keys corresponding to the keys in VARS
.
PREFIX: str = 'Your job is to classify the following interview into one of the following categories.'
class-attribute
¶
The prompt prefix.
SUFFIX: str = ''
class-attribute
¶
The prompt suffix.
classifiers: dict[str, Type[Self]] = {}
class-attribute
¶
A registry of subclasses implementing custom classifiers.
check()
classmethod
¶
Ensures that the supplied constants are sound.
Source code in summ/classify/classifier.py
45 46 47 48 49 50 51 52 53 54 |
|
classify_all(docs: list[Document]) -> dict[str, list[C]]
classmethod
¶
Runs a Document through all registered subclasses.
Source code in summ/classify/classifier.py
56 57 58 59 60 |
|
example_template(dynamic = set()) -> str
¶
The template used to construct one example in the prompt.
Source code in summ/classify/classifier.py
62 63 64 65 66 67 68 69 70 |
|
prompt_template()
¶
The template used to construct the prompt.
Source code in summ/classify/classifier.py
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 97 98 99 100 |
|
debug_prompt(**kwargs: dict[str, str]) -> str
¶
Returns the prompt with the given variables filled in.
Source code in summ/classify/classifier.py
102 103 104 105 |
|
run(docs: list[Document]) -> list[C]
¶
Runs a Document through the classifier and returns the tags.
Source code in summ/classify/classifier.py
112 113 114 115 116 117 118 119 120 121 |
|
classify(docs: list[Document]) -> dict[str, str]
abstractmethod
¶
Extracts a set of VARS from a list of Documents. This method must be implemented by subclasses.
PARAMETER | DESCRIPTION |
---|---|
docs |
The Documents resulting from apply the Splitter to an import source.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, str]
|
A dictionary mapping variable names to values. The keys should be a subset of the keys in |
Source code in summ/classify/classifier.py
123 124 125 126 127 128 129 130 131 132 133 134 |
|